微信分享海报、头像、图片、二维码合成(java)

海报生成自定义二维码canvas合成 1.引入生成二维码的js ///自行下载js库,引入你本地地址 <script src="jquery-2.1.1.js"></script> <script src="qrcode.min.js"></script> 2.html <div id="qrcode" style="display: none;"></div>... 阅读详情

最近做一个微信小应用,最后的保存分享海报页面,需要将海报上面展示当前用户的微信头像,二维码、添加参数等,最终合成一张海报展示,分享使用:

需求原型:

 

如上图所示:就是在原始海报上叠加上当前登录用户的相关信息等,输出成图片进行展示:

直接上代码:分享图片操作工具类

SharedImageUtils
package com.javen.utils;

import javax.imageio.*;
import javax.imageio.stream.ImageInputStream;
import java.awt.*;
import java.awt.geom.Area;
import java.awt.geom.RoundRectangle2D;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.URL;
import java.util.Iterator;

import static java.lang.System.out;

/**
 * @Auther: liux
 * @Date: 2019/06/15 15:17
 * @Description: 生成朋友圈分享图相关接口
 */
public class SharedImageUtils {
    private SharedImageUtils() {
        throw new IllegalStateException("Utility class");
    }

    /* 要放置的二维码寬度 */
    public static final int QRCODE_WIDTH = 230;
    /* 要放置的二维码長度 */
    public static final int QRCODE_LENGTH = 230;
    /* 要放置的二维码Y位置 往下为大值,往上为小值 */
    public static final int QRCODE_Y = 1070;
    /*要放置的二维码X位置 往下为大值,往上为小值 */
    public static final int QRCODE_X = 740;
    /* 要放置的头像半径 */
    public static final int PROFILE_RADIUS = 88;
    /* 要放置的头像y坐标 */
    public static final int PROFILE_Y = 34;
    /* 要放置的头像X坐标 */
    public static final int PROFILE_X = 56;
    /* 昵称的Y位置 */
    public static final int FONT_Y = 1110;
    /*昵称的X位置*/
    public static final int FONT_X = 190;
    /* 推广文案的Y位置 */
    public static final int COPYWRITER_Y = 1200;
    /* 推广文案的X位置 */
    public static final int COPYWRITER_X = 150;
    /* 商店图案Y位置 */
    public static final int SHOP_PIC_Y = 70;
    /*商店图案位置*/
    public static final int SHOP_PIC_X = 93;
    /* 商店图案寬度 */
    public static final int SHOP_PIC_WIDTH = 900;
    /* 商店图案長度 */
    public static final int SHOP_PIC_LENGTH = 950;





    /**
     * 裁剪图片
     *
     * @param img          the img
     * @param originWidth  the origin width
     * @param originHeight the origin height
     * @return the buffered image
     * @throws Exception the exception
     */
    public static BufferedImage cutPicture(BufferedImage img, int originWidth, int originHeight) throws IOException {
        int width = img.getWidth();  // 原图的宽度
        int height = img.getHeight();  //原图的高度

        int newImageX = 0; // 要截图的坐标
        int newImageY = 0; // 要截图的坐标
        if (width > originWidth) {
            newImageX = (width - originWidth) / 2;
        }
        if (height > originHeight) {
            newImageY = height - originHeight;
        }
        return cutJPG(img, newImageX, newImageY, originWidth, originHeight);
    }

    /**
     * 图片拉伸
     *
     * @param originalImage the original image
     * @param originWidth   the origin width
     * @param originHeight  the origin height
     * @return the buffered image
     * @throws Exception the exception
     */
    public static BufferedImage zoomPicture(String originalImage, int originWidth, int originHeight) {

        BufferedImage img = null;
        BufferedImage bufferedImage = null;
        try {
            // 原来的图片
            img = ImageIO.read(new File(originalImage));
            int width = img.getWidth();  // 原图的宽度
            int height = img.getHeight();  //原图的高度

            int scaledWidth = width;
            int scaledHeight = height;
            // 如果不是正方形
            if (width == height) {
                // 按照originHeight进行缩放
                scaledWidth = originHeight;
                scaledHeight = originHeight;
            } else {
                if (width > height) {
                    // 按照originHeight进行缩放
                    scaledWidth = (scaledWidth * originHeight) / scaledHeight;
                    scaledHeight = originHeight;
                } else {
                    // 宽高比例
                    int originPercent = (originHeight * 100) / originWidth;
                    int newPercent = (height * 100) / width;
                    if (newPercent >= originPercent) {
                        // 按照originWidth进行缩放
                        scaledWidth = originWidth;
                        scaledHeight = (originHeight * scaledWidth) / scaledWidth;
                    } else {
                        // 按照originHeight进行缩放
                        scaledWidth = (scaledWidth * originHeight) / scaledHeight;
                        scaledHeight = originHeight;
                    }
                }
            }
            Image schedImage = img.getScaledInstance(scaledWidth, scaledHeight, Image.SCALE_SMOOTH);
            // 新的图片
            bufferedImage = new BufferedImage(scaledWidth, scaledHeight, img.getType());
            Graphics2D g = bufferedImage.createGraphics();
            // 绘制
            g.drawImage(schedImage, 0, 0, null);
            g.dispose();
        } catch (IOException e) {

        }

        return bufferedImage;
    }

    /**
     * 进行裁剪操作
     *
     * @param originalImage the original image
     * @param x             the x
     * @param y             the y
     * @param width         the width
     * @param height        the height
     * @return the buffered image
     * @throws IOException the io exception
     */
    public static BufferedImage cutJPG(BufferedImage originalImage, int x, int y, int width, int height) throws IOException {
        Iterator<ImageReader> iterator = ImageIO.getImageReadersByFormatName("jpg");
        ImageReader reader = iterator.next();
        // 转换成字节流
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        // writeToJPEG(1080,originalImage,0.5f,outputStream);
        ImageIO.write(originalImage, "jpg", outputStream);
        InputStream is = new ByteArrayInputStream(outputStream.toByteArray());
        ImageInputStream iis = ImageIO.createImageInputStream(is);
        reader.setInput(iis, true);
        ImageReadParam param = reader.getDefaultReadParam();
        Rectangle rect = new Rectangle(x, y, width, height);
        param.setSourceRegion(rect);
        return reader.read(0, param);
    }

    /**
     * 合并头像和昵称
     *
     * @param baseLayer
     * @param topLayer
     * @param nickName
     * @param locationX
     * @param locationY
     * @param locationWidth
     * @param locationLength
     * @return
     * @throws IOException
     */
    public static BufferedImage mergePicture(BufferedImage baseLayer,
                                             BufferedImage topLayer,
                                             String nickName,
                                             String eq,
                                             int locationX,
                                             int locationY,
                                             int locationWidth,
                                             int locationLength) throws IOException {

        int width = baseLayer.getWidth(null); //底图的宽度
        int height = baseLayer.getHeight(null); //底图的高度
        // 按照底图的宽高生成新的图片
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics g = image.createGraphics();
        g.drawImage(baseLayer, 0, 0, width, height, null);

        //int smallWidth = topLayer.getWidth(null);   // 上层图片的宽度
        // 设置上层图片放置的位置的坐标及大小
        g.drawImage(topLayer, locationX, locationY, locationWidth, locationLength, null);
        if (nickName != null) {
            // 普通字体(ps:字体是微软雅黑,linux不具备有,需要安装,)
            Font font = new Font("微软雅黑", Font.BOLD, 36);
            g.setFont(font);
            g.setColor(new Color(241, 178, 44));
            FontMetrics fm = g.getFontMetrics(font);
            // 字体放置的位置
            //int textWidth = fm.stringWidth(nickName);
            g.drawString(nickName, 497, 240);
        }
        if (eq != null) {
            // 普通字体(ps:字体是微软雅黑,linux不具备有,需要安装,)
            Font font = new Font("微软雅黑", Font.BOLD, 36);
            g.setFont(font);
            g.setColor(new Color(75, 75, 75));
            FontMetrics fm = g.getFontMetrics(font);
            // 字体放置的位置
            //int textWidth = fm.stringWidth(nickName);
            g.drawString(eq, 423, 240);
        }

        g.dispose();

        return image;
    }


    /**
     * 按指定的字节数截取字符串(一个中文字符占3个字节,一个英文字符或数字占1个字节)
     *
     * @param sourceString 源字符串
     * @param cutBytes     要截取的字节数
     * @return
     */
    public static String cutString(String sourceString, int cutBytes) {
        if (sourceString == null || "".equals(sourceString.trim())) {
            return "";
        }
        int lastIndex = 0;
        boolean stopFlag = false;
        int totalBytes = 0;
        for (int i = 0; i < sourceString.length(); i++) {
            String s = Integer.toBinaryString(sourceString.charAt(i));
            if (s.length() > 8) {
                totalBytes += 3;
            } else {
                totalBytes += 1;
            }
            if (!stopFlag) {
                if (totalBytes == cutBytes) {
                    lastIndex = i;
                    stopFlag = true;
                } else if (totalBytes > cutBytes) {
                    lastIndex = i - 1;
                    stopFlag = true;
                }
            }
        }
        if (!stopFlag) {
            return sourceString;
        } else {
            return sourceString.substring(0, lastIndex + 1);
        }
    }

    /**
     * 合并二维码附带使用说明
     *
     * @param baseImage
     * @param qrcodeBufferImage
     * @param text
     * @param locationX
     * @param locationY
     * @param locationWidth
     * @param locationLength
     * @return
     * @throws IOException
     */
    public static BufferedImage mergeQrcode(BufferedImage baseImage,
                                            BufferedImage qrcodeBufferImage,
                                            String text,
                                            int locationX,
                                            int locationY,
                                            int locationWidth,
                                            int locationLength) throws IOException {


        // BufferedImage qrcodeBufferImage = ImageIO.read(qrcodeFile);

        int width = baseImage.getWidth(null); //底图的宽度
        int height = baseImage.getHeight(null); //底图的高度

        // 按照底图的宽高生成新的图片
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics g = image.createGraphics();
        g.drawImage(baseImage, 0, 0, width, height, null);

        // 设置上层图片放置的位置的坐标及大小,坐标居中
        g.drawImage(qrcodeBufferImage, locationX, locationY, locationWidth, locationLength, null);
        if (text != null) {
            // 普通字体
            Font font = new Font("微软雅黑", Font.PLAIN, 25);
            g.setFont(font);
            g.setColor(new Color(129, 129, 129));
            FontMetrics fm = g.getFontMetrics(font);
            // 字体放置的位置
            //int textWidth = fm.stringWidth(nickName);
            g.drawString(text, 748, 1330);
        }
        g.dispose();
        return image;
    }

    /**
     * 图片上添加文字
     *
     * @param src        the src
     * @param copywriter the copywriter
     * @return the buffered image
     * @throws Exception the exception
     */
    public static BufferedImage drawTextInImage(BufferedImage src, String copywriter) {
        int width = src.getWidth(null);
        int height = src.getHeight(null);
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics2D g = image.createGraphics();
        g.drawImage(src, 0, 0, width, height, null);

        // 长度和位置
        Font font = new Font("微软雅黑", Font.PLAIN, 35);
        g.setFont(font);
        FontMetrics fm = g.getFontMetrics(font);
        int textWidth = fm.stringWidth(copywriter);
        g.setColor(new Color(47, 47, 47));
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        // 先按字节来换行,英文单词空格问题暂时未考虑
        if (copywriter.getBytes().length > 63) {
            String firstLine = cutString(copywriter, 63);
            String secondLine = copywriter.substring(firstLine.length(), copywriter.length());
            g.drawString(firstLine, (width - fm.stringWidth(firstLine)) / 2, COPYWRITER_Y);
            g.drawString(secondLine, (width - fm.stringWidth(secondLine)) / 2, COPYWRITER_Y + 35);
        } else {
            g.drawString(copywriter, COPYWRITER_X, COPYWRITER_Y);
        }
        g.dispose();

        return image;
    }

    public static BufferedImage drawTextInImage(BufferedImage src, String copywriter, int x, int y) {
        int width = src.getWidth(null);
        int height = src.getHeight(null);
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics2D g = image.createGraphics();
        g.drawImage(src, 0, 0, width, height, null);

        // 长度和位置
        Font font = new Font("微软雅黑", Font.PLAIN, 35);
        g.setFont(font);
        FontMetrics fm = g.getFontMetrics(font);
        int textWidth = fm.stringWidth(copywriter);
        g.setColor(new Color(62, 62, 62));
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.drawString(copywriter, x, y);
        g.dispose();

        return image;
    }

    /**
     * 方形转为圆形
     *
     * @param img    the img
     * @param radius the radius 半径
     * @return the buffered image
     * @throws Exception the exception
     */
    public static BufferedImage convertRoundedImage(BufferedImage img, int radius) {
        BufferedImage result = new BufferedImage(radius, radius, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = result.createGraphics();
        //在适当的位置画图
        g.drawImage(img, (radius - img.getWidth(null)) / 2, (radius - img.getHeight(null)) / 2, null);

        //圆角
        RoundRectangle2D round = new RoundRectangle2D.Double(0, 0, radius, radius, radius * 2, radius * 2);
        Area clear = new Area(new Rectangle(0, 0, radius, radius));
        clear.subtract(new Area(round));
        g.setComposite(AlphaComposite.Clear);

        //抗锯齿
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.fill(clear);
        g.dispose();

        return result;
    }

    /**
     * 图像等比例缩放
     *
     * @param img     the img
     * @param maxSize the max size
     * @param type    the type
     * @return the scaled image
     */
    private static BufferedImage getScaledImage(BufferedImage img, int maxSize, int type) {
        int w0 = img.getWidth();
        int h0 = img.getHeight();
        int w = w0;
        int h = h0;
        // 头像如果是长方形:
        // 1:高度与宽度的最大值为maxSize进行等比缩放,
        // 2:高度与宽度的最小值为maxSize进行等比缩放
        if (type == 1) {
            w = w0 > h0 ? maxSize : (maxSize * w0 / h0);
            h = w0 > h0 ? (maxSize * h0 / w0) : maxSize;
        } else if (type == 2) {
            w = w0 > h0 ? (maxSize * w0 / h0) : maxSize;
            h = w0 > h0 ? maxSize : (maxSize * h0 / w0);
        }
        Image schedImage = img.getScaledInstance(w, h, Image.SCALE_SMOOTH);
        BufferedImage bufferedImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = bufferedImage.createGraphics();
        g.drawImage(schedImage, 0, 0, null);
        return bufferedImage;
    }

    /**
     * 对头像处理
     *
     * @param in   of  the image
     * @param radius the radius
     * @return the buffered image
     * @throws Exception the exception
     */
    public static BufferedImage createRoundedImage(InputStream in, int radius) {
        BufferedImage img = null;
        BufferedImage fixedImg = null;
        BufferedImage bufferedImage = null;
        try {
            img = ImageIO.read(in);
            // 1. 按原比例缩减
            fixedImg = getScaledImage(img, radius, 2);
            // 2. 居中裁剪
            fixedImg = cutPicture(fixedImg, radius, radius);
            // 3. 把正方形生成圆形
            bufferedImage = convertRoundedImage(fixedImg, radius);
        } catch (IOException e) {
        }
        return bufferedImage;
    }

    public static void main(String[] args) {
        out.println(Thread.currentThread().getContextClassLoader().getParent().getResource(""));
    }
}

调用处理类:(我这里的处理主要是把合成的图片写到了我想要目录下面,实际应用中可以根据你们的需求写到指定目录下或者以输出流的形式返回给页面)

public  void  imageHandle(){
		String openId = getSessionAttr("openId");

		try {
			String grade = getPara("grade");
			String flag = getPara("flag");
			if(StringUtils.isBlank(grade)){
				renderJson(result.addError("无对应信息!"));
			}
			if (StrKit.notBlank(openId)) {
				Users users = Users.me.findByOpenId(openId);
				if (users == null) {
					log.error("未找到相关用户信息");
					renderJson(result.addError("不存在相关用户信息!"));
					return;
				}
				int gradei = Integer.valueOf(grade);
				String imageUrl = "";
					if (gradei < 80) {
						imageUrl = "0-79.png";
					} else if (79 < gradei && gradei < 90) {
						imageUrl = "80-89.png";
					} else if (89 < gradei && gradei < 100) {
						imageUrl = "90-99.png";
					} else if (99 < gradei && gradei < 110) {
						imageUrl = "100-109.png";
					} else if (109 < gradei && gradei < 120) {
						imageUrl = "110-119.png";
					} else if (119 < gradei && gradei < 130) {
						imageUrl = "120-129.png";
					} else if (129 < gradei && gradei < 135) {
						imageUrl = "130-134.png";
					} else if (134 < gradei && gradei < 140) {
						imageUrl = "135-139.png";
					} else if (139 < gradei && gradei < 145) {
						imageUrl = "140-144.png";
					}  else if (144 < gradei && gradei < 1150) {
						imageUrl = "145-149.png";
					} else if (149 < gradei && gradei < 160) {
						imageUrl = "150-159.png";
					}else if (gradei == 160) {
						imageUrl = "160.png";
					} else if (160 < gradei) {
						imageUrl = "160以上_.png";
					}
				String url = PropKit.get("domain")+ "/wxGame/test/img/" + imageUrl;
				InputStream background = new URL(url).openStream();
				BufferedImage zoomPicture = ImageIO.read(background);
				BufferedImage roundedImage = SharedImageUtils.createRoundedImage(new URL(users.get("headimgurl").toString()).openStream(),
						SharedImageUtils.PROFILE_RADIUS);//头像裁剪
				BufferedImage profileImage = SharedImageUtils.mergePicture(zoomPicture,
						roundedImage, grade," EQ:",
						SharedImageUtils.PROFILE_X,
						SharedImageUtils.PROFILE_Y,
						SharedImageUtils.PROFILE_RADIUS,
						SharedImageUtils.PROFILE_RADIUS);
				
				// 5. 生成分享图
				/*ServletOutputStream outputStream = getResponse().getOutputStream();*/
				String imagesUrl = ProjectPathUtil.getRootPath();
				File files = new File(imagesUrl);
				files = new File(files.getParent());
				//files = new File(files.getParent());
				imagesUrl = files.getParent();
				String imgName= System.currentTimeMillis()+ new Random().nextInt(10000)+"";
				File file = new File(imagesUrl+"/test/",imgName+".jpg");
				ImageIO.write(profileImage, "jpg",file );
				Map map = new HashMap();
				map.put("imgUrl",imgName+".jpg");
				/*outputStream.flush();
				outputStream.close();*/
				result.setData(map);
				renderJson(result.addSuccess("获取成功"));
			}
		}catch (Exception e){
e.printStackTrace();
		}
	}

意思就是合成图片的全部代码,如有疑问欢迎留言;

二维码合成海报基于canvas实现 基于vue2和canvas实现的二维码合成海报的代码,可以直接使用,里面有对应的使用组件教程和reanme文件,父组件和子组件均存在,直接按照组件的使用方式进行使用即可,需要的可以直接获取即可。 立即下载

相关推荐

利用java实现二维码和背景图的合并

本文介绍如何使用java代码将自动生成的二维码放入背景模板中,对于java学习者或许有帮助,一起来看看。

小程序画布合成二维码海报图,并保存到相册

小程序画布合成二维码海报图,并保存到相册 实现效果如下图: 步骤分析 1,先获取需要合成的海报和二维码。 2,获取图片的本地路径,如果图片不是网络连接则不需要此操作。 3,通过手机型号,根据屏幕的大小计算出海报的长宽比例,适配不同的手机。 4,操作小程序cavnas把二维码和海报,合成一张图。 设置好wxml页面 <button bindtap="canvasCode">海报合成&l...

qq_41855739的博客 2213

java 生成分享图片(二维码,图片拼接,文字编辑)

需求背景 之前遇到过需要后端,根据每个用户生成带背景宣传图带二维码带用户图片带文字的合成图片的需求,自己当时花了半天的时间整理了资料,今天把自己写的代码分享出来,如果有同样需求的人,希望能给个好评,有其他建议的童鞋,可以一起讨论交流。 文章下面贴有项目地址,感谢star 项目整合了二维码和日志,有需要的童鞋也可以做参考 图片缓冲类 BufferedImage BufferedImage类是Image的实现类,是可以把图片加载到内存的缓冲类,我写的代码中就基本上都是基于该类实现对图片的操作。 图片加载 Thumbnails Thumbnails是谷歌开源的一套图片工具类 当我需要把本地图片加载进

生成二维码合成海报并下载

生成二维码合成海报并下载

css兼容浏览器的各种背景渐变 639

AI视频生成提示词工程:结构化公式与实战案例详解

在实际使用 AI 生成视频或图像时,最常遇到的困惑是:为什么我的提示词(Prompt)生成的画面总是不理想?是模型能力不足,还是我的描述有问题?答案往往是后者。提示词工程(Prompt Engineering)并非简单的“翻译”需求,而是一门需要结构化思维和精准描述的技能。它决定了 AI 能否准确理解你的意图,并生成符合预期的视觉内容。 本文将通过两个核心案例,深入拆解提示词的构建逻辑。第一个案例聚焦于“文生视频”,我们将学习如何将一个简单的想法,如“小猫在雪地里玩雪球”,通过结构化公式扩展为一段富有细节和

weixin_30800987的博客 565

Hi3516CV610 YOLOv8模型转换与部署实战:从源码到板端推理全流程解析

本文详细解析了将YOLOv8模型部署到Hi3516CV610开发板的全流程。内容涵盖从Ubuntu环境搭建、模型获取与验证,到关键的PyTorch模型转换为ONNX格式,并利用海思工具链量化生成板端可执行的.wk文件。最后,指导开发者编写板端C程序,完成视频流处理、NNIE推理及结果后处理,并提供了部署调试与性能优化的实用技巧。

weixin_29215815的博客 271

JAVA生成微信小程序分享海报图片

由于小程序里面分享产品,不能直接到朋友圈,因此很多系统的做法是生成一张带有二维码,或者小程序码的海报图片。用户保存到本地,然后分享到朋友圈。 生成海报,有两种方式 (1)前端小程通过canvs绘图到模式进行合成 (2)前端小程序请求到后台服务器进行合成 在本场 Chat 中,会讲到如下内容: 如何使用JAVA图片JDK进行图片操作 如何进行图片裁剪 如何进行图片缩放 如何进行图片合成 适合人群: ...

GitChat 2685

STM32+HX711实战:5分钟搞定拉力传感器数据采集(附完整代码)

本文详细介绍了如何使用STM32微控制器和HX711模数转换器快速搭建高精度拉力测量系统。通过硬件连接指南、驱动实现代码和校准方法,帮助开发者在5分钟内完成拉力传感器数据采集,适用于工业自动化和消费电子等场景。

y7z8a9的博客 877

JAVA后台生成海报分享图片(简单配置轻松生成)

生而为人 谁不付出 谁不努力 微信小程序端有关于一篇文章生成一张海报图片,用于用户保存之后分享,实际开发的过程中遇到的一些问题如下: 1:开发编辑器里面生成存在的情况 A:生成的海报时候需要获取一张网络图片,但是小程序手机端测试是需要使用wx.getImageInfo()方法处理之后才可以 wx.getImageInfo(Object...

tanqingfu1的博客 1万+

超越音频!STM32 SAI接口在AD7768高速ADC采集中的妙用(含PCB布局指南)

本文深入探讨了如何将STM32的SAI接口应用于AD7768高速ADC的数据采集系统,超越了其传统的音频应用范畴。文章详细解析了SAI协议与ADC时序的匹配方法,提供了从CubeMX配置、DMA数据搬运到关键PCB布局指南的完整实战方案,旨在帮助工程师实现稳定、高精度的工业级高速数据采集。

efc12345678的博客 305

C8T6和ZET6选型更换过程中出现.\Obj\Project.sct(7): error: L6235E: More than one section matches selector - cann

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录前言一、问题原因二、解决方法三、现象总结 前言 又一件离谱的事情发生了,我之前转换过程中没有发生的错误,今天拿出来程序重新编译了一下,结果他奶奶滴一个新的错误出现了,而且我还完全不知道是什么原因导致的,先上图: 一、问题原因 之前我已经尝试过更换芯片选型,但是没有出现此类问题,今天更改的时候发现了,我还以为是个偶然错误,结果换来换去,还是有这个问题,那我之前说c8t6的程序更改成zet6上跑只需改芯片选型和宏定义岂不是啪啪打.

wx18045623090的博客 1491

Java后台生成海报分享图片

微信小程序端有关于一篇文章生成一张海报图片,用于用户保存之后分享,实际开发的过程中遇到的一些问题如下: 1:开发编辑器里面生成存在的情况 A:生成的海报时候需要获取一张网络图片,但是小程序手机端测试是需要使用wx.getImageInfo()方法处理之后才可以 wx.getImageInfo(Object object) 获取图片信息。网络图片需先配置download域名才能生效。 参数 Object object 属性 类型 默认值 必填 说明 src string 是 图片的路

安藤青司的博客 1399

游戏开发实战:5种AOI算法对比(九宫格 vs 灯塔 vs 十字链表)

本文深入对比了游戏开发中五种主流AOI算法(九宫格、灯塔、十字链表等)的性能与适用场景,帮助开发者根据项目规模选择最优解决方案。通过详细的技术分析和实战数据,揭示不同算法在万人同屏等极端场景下的表现差异,为MMORPG等大型多人在线游戏提供关键性能优化指南。

weixin_29268385的博客 476

java 获取微信头像和昵称 生成图片

优快云账户申请好久了一直在论坛上面浏览别人的的东西,自己也没有写过什么正经东西,好多自己看到和用到的东西也渐渐忘记了,趁没忘干净之前自己总结下,方便以后查阅,闲话不多说了上干货。 需求来源于公司目前做的一个营销活动,需要生成一张营销海报,海报上带有用户二维码、头像、昵称这些简答的资料。我只用java生成图片,大概思路是以下几个步骤。 1、获取用户昵称和头像。 2、生成二维码。 3、设置背...

pai_zi的博客 7570

使用python获取同花顺免费版和同花顺远航版自选股数据用于量化交易

在做量化交易时,有时需要在盘中实时监控同花顺自选股的数量,以便灵活地自定义提醒、捕捉买卖时点等。那么,如何使用python获取同花顺自选股数据呢?

tzzqn2008的专栏 3687

基于Transformer的股票市场多因子量化选股模型,深度解析:基于Transformer的股票市场多因子量化选股模型

传统多因子模型通常采用线性回归、岭回归或Lasso回归来估计因子权重,其核心假设是因子与未来收益之间存在线性关系。然而,现实中的股票市场具有典型的非线性、非平稳和高噪声特征。卷积神经网络(CNN)擅长提取局部特征,但难以捕捉全市场股票之间的全局依赖关系;循环神经网络(RNN)及其变体LSTM虽然能处理时间序列,但存在梯度消失问题且难以并行计算。Transformer的self-attention机制能够:直接建模任意两只股票之间的相关性动态计算因子权重而非静态线性组合。

YOLO 251

开箱即用的fastposter海报生成器

fastposter 海报生成器是一款快速开发海报的工具。

wbsu2004的博客 7241

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

ggplot2 声明式数据可视化全景:从 aes 映射到分层渲染一次讲透

ggplot2 是 R 里最主流的声明式数据可视化引擎,核心思路是把"哪个变量画到哪个视觉属性"这条规则统一交给它管。写分析脚本时最容易翻车的,常常是图层叠不上、比例尺互相打架、导出的图跟屏幕差一截——下面把这条链路拆开看。 [![ggplot2 声明式数据可视化生成的散点图,按车型分色的 displ 与 hwy 关系](https://raw.gitcode.com/gh_mirrors/gg

gitblog_00671的博客 680

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

微信小程序生成分享海报

先看效果图 public static void main(String[] args) { //创建图片(海报尺寸750*1234) BufferedImage img = new BufferedImage(750, 1234, BufferedImage.TYPE_INT_RGB); //开启画图 Graphics g = img.getGraphics(); //背景 -- 读取互联网图片(先生成一张背景图) BufferedImage

李逍遥的博客 1880

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

JAVA海报制作

文章目录JAVA海报制作前言效果图代码 JAVA海报制作 前言 最近一直在忙着做小程序的分享盆友圈,分享朋友和群,好物推荐,好物圈等等推广方面的事情。有大概一个礼拜没有更博客了。就想着写一篇关于海报制作方面的博客。关于分享朋友圈这个功能,我刚开始的想法是后台用代码画一张海报出来,然后上传到云服务器返回url,我就想着图片url都有了,微信应该有提供接口可以把这张图分享到盆友圈吧,可是后面海报画出来...

LiuRenyou的博客 1499

Java5分钟制作海报

一、需求背景我们经常在多终端应用开发中会遇到这样的需求:用户在浏览商品时觉得不错,希望分享给朋友。此时终端(安卓、苹果、H5等)生成一张精美的商品海报,通过微信或者其他途径分享给他人。也可能会遇到需求:制作个人名片打印出来或者分享给他人。效果大概是这样的:也可能是这样(上面的图都是我从网上临时找的,只做参考学习,避免广告已经做了部分处理。) 刚开始设计这个需求的时候,我们是在前端来完成的,即由安卓...

HBLOG 1527

Java如何绘制一张漂亮的海报(附源码)

Java如何绘制一张漂亮的海报 需求说明 最近呢看着前端的同学使用canvas绘制漂亮的海报,刚好这次又碰到产品说又有了大展身手的机会了,果断报名,后端来完成试试。因为是B端需求,对性能也没过多的要求, 果断报名了。 效果图如下 这张图主要是用于投放或者老师给同学们的商品外链图,用于传播和分享。 上图中除了背景图之外,其他的像顶部的企业log和企业名称,当然也可以理解为头像和昵称都可以的。 还有中间商品的链接图,商品描述文字,二维码的生成,都是后期绘制上去的。也就是接下来所要说的重点。 核心技术点 Ja

冉野 、 2056

教你Java5分钟制作海报、彻底解决APP兼容性问题

我们经常在多终端应用开发中会遇到这样的需求:用户在浏览商品时觉得不错,希望分享给朋友。此时终端(安卓、苹果、H5等)生成一张精美的商品海报,通过微信或者其他途径分享给他人。也可能会遇到需求:制作个人名片打印出来或者分享给他人。

乃青的博客 2431

微信引流活动:生成带参二维码、发送海报、

参加活动-生成带参数二维码-将二维码与海报进行合并-推动给客户-客户分享到朋友圈-朋友圈里朋友通过二维码关注公众号-再次生成二维码海报-循环往复-引流! 代码实现: 1.获取临时二维码ticket /// <summary> /// 获取临时二维码ticket /// </summary> /// &l...

weixin_30443075的博客 451

微信扫码跳转添加好友

1. **编码**:使用 `MultiFormatWriter` 将字符串(如 URL 或 ID)转换成黑白相间的矩阵数据(`BitMatrix`)。2. **绘图**:利用 Java AWT (`Graphics2D`) 在内存中创建画布,先画上二维码矩阵,再贴上 Logo 图片,最后写上文字。3. **输出**:将绘制好的内存图片返回给调用者,由 Controller 决定是存到本地、上传到 OSS 还是直接响应给浏览器。**注意**:

qq_62076269的博客 536

探秘FastPoster:一款高效易用的海报生成神器

![fast-poster logo](https://fastposter.net/dassets/dragonfly2x.png) 在数字化时代,无论是电商平台还是社交媒体,引人注目的海报始终是吸引眼球的关键元素。而【FastPoster】正是这样一款强大的海报生成工具,它将帮你快速、轻松地创造个性化海报,极大地提升你的设计效率。 ## 项目简介 FastPoster是一个基于Pytho...

gitblog_00721的博客 1350
上一篇: 微信自定义分享(java)config:fail,Error: invalid signature,updateTimelineShareData:fail the permission value
下一篇: springBoot 使用自定义配置文件集成 redis
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值