bug
jiangqs
2023-07-26 add86a49cc69b6882500c95dd67a2ac826c35526
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.ruoyi.file.utils;
 
import cn.hutool.core.img.ImgUtil;
 
import java.awt.*;
import java.io.*;
 
 
public class ImgUtils {
 
 
    /**
     * 使用hutool 工具类
     */
    public void SyntheticImages2(File codeImage,File backImage) throws FileNotFoundException {
        // 生成的二维码
//        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
//        QrCodeUtil.generate("https://hutool.cn/", 516, 516, ImgUtil.IMAGE_TYPE_JPG, outputStream);
 
        // 要输出的图片
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        InputStream codeStream = new FileInputStream(codeImage);
        InputStream backStream = new FileInputStream(backImage);
        // 将图片合成在一起
        ImgUtil.pressImage(
                backStream, // 主图片
                out, // 输出图片
                ImgUtil.read(codeStream).getScaledInstance(516, 516, Image.SCALE_DEFAULT), //水印图片
                0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
                0, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
                1.0f
        );
        InputStream inputStream = new ByteArrayInputStream(out.toByteArray());
 
    }
}