支持带logo图片
引入包
<!--二维码工具类--><dependency><groupId>com.google.zxing</groupId><artifactId>core</artifactId><version>3.3.3</version></dependency><dependency><groupId>com.google.zxing</groupId><artifactId>javase</artifactId><version>3.3.3</version></dependency>
工具类
import cn.hutool.core.util.StrUtil;
import com.google.zxing.*;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.**.healthcardadapter.exception.BusinessException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;import javax.annotation.PostConstruct;
import javax.imageio.ImageIO;
import javax.swing.filechooser.FileSystemView;
import java.awt.*;
import java.awt.geom.RoundRectangle2D;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.URL;
import java.util.Base64;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;/*** 二维码、条形码工具类*/
@Slf4j
public class QRCodeUtils {/*** CODE_WIDTH:二维码宽度,单位像素*/private static final int CODE_WIDTH = 200;/*** CODE_HEIGHT:二维码高度,单位像素*/private static final int CODE_HEIGHT = 200;/*** FRONT_COLOR:二维码前景色,0x000000 表示黑色*/private static final int FRONT_COLOR = 0x000000;/*** BACKGROUND_COLOR:二维码背景色,0xFFFFFF 表示白色* 演示用 16 进制表示,和前端页面 CSS 的取色是一样的,注意前后景颜色应该对比明显,如常见的黑白*/private static final int BACKGROUND_COLOR = 0xFFFFFF;/*** 默认图片格式*/private static final String DEFAULT_IMG = "JPG";/*** LOGO宽度*/private static final int WIDTH = 60;/*** LOGO高度*/private static final int HEIGHT = 60;private static final String CHARSET = "UTF-8";private static final String DEFAULT_LOGO_FILE = "./img/logger.JPG";/*** window 临时存放目录*/private static String WIN_TEMP_PATH = "C:\\Temp\\";/*** linux临时存放目录*/private static String LINUX_TEMP_PATH = "/temp/";@Autowiredprivate Environment env;@PostConstructpublic void init() {// 初始化配置WIN_TEMP_PATH = env.getProperty("ehc.winTempPath");LINUX_TEMP_PATH = env.getProperty("ehc.linuxTempPath");}/*** 生成二维码 并 保存为图片:write(RenderedImage im,String formatName,File output)** @param codeContent :二维码参数内容,如果是一个网页地址,如 https://www.baidu.com/ 则 微信扫一扫会直接进入此地址* 如果是一些参数,如 1541656080837,则微信扫一扫会直接回显这些参数值* @param codeImgFileSaveDir :二维码图片保存的目录,如 D:/codes* @param fileName :二维码图片文件名称,带格式,如 123.png*/public static void createCodeToFile(String codeContent, File codeImgFileSaveDir, String fileName) {try {/** 参数检验*/if (codeContent == null || "".equals(codeContent.trim())) {return;}codeContent = codeContent.trim();if (codeImgFileSaveDir == null || codeImgFileSaveDir.isFile()) {codeImgFileSaveDir = FileSystemView.getFileSystemView().getHomeDirectory();}if (!codeImgFileSaveDir.exists()) {codeImgFileSaveDir.mkdirs();}if (fileName == null || "".equals(fileName)) {fileName = System.currentTimeMillis() + "." + DEFAULT_IMG;}/**com.google.zxing.EncodeHintType:编码提示类型,枚举类型* EncodeHintType.CHARACTER_SET:设置字符编码类型* EncodeHintType.ERROR_CORRECTION:设置误差校正* ErrorCorrectionLevel:误差校正等级,L = ~7% correction、M = ~15% correction、Q = ~25% correction、H = ~30% correction* 不设置时,默认为 L 等级,等级不一样,生成的图案不同,但扫描的结果是一样的* EncodeHintType.MARGIN:设置二维码边距,单位像素,值越小,二维码距离四周越近* */Map<EncodeHintType, Object> hints = new HashMap();hints.put(EncodeHintType.CHARACTER_SET, CHARSET);hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);hints.put(EncodeHintType.MARGIN, 1);/*** MultiFormatWriter:多格式写入,这是一个工厂类,里面重载了两个 encode 方法,用于写入条形码或二维码* encode(String contents,BarcodeFormat format,int width, int height,Map<EncodeHintType,?> hints)* contents:条形码/二维码内容* format:编码类型,如 条形码,二维码 等* width:码的宽度* height:码的高度* hints:码内容的编码类型* BarcodeFormat:枚举该程序包已知的条形码格式,即创建何种码,如 1 维的条形码,2 维的二维码 等* BitMatrix:位(比特)矩阵或叫2D矩阵,也就是需要的二维码*/MultiFormatWriter multiFormatWriter = new MultiFormatWriter();BitMatrix bitMatrix = multiFormatWriter.encode(codeContent, BarcodeFormat.QR_CODE, CODE_WIDTH, CODE_HEIGHT, hints);/**java.awt.image.BufferedImage:具有图像数据的可访问缓冲图像,实现了 RenderedImage 接口* BitMatrix 的 get(int x, int y) 获取比特矩阵内容,指定位置有值,则返回true,将其设置为前景色,否则设置为背景色* BufferedImage 的 setRGB(int x, int y, int rgb) 方法设置图像像素* x:像素位置的横坐标,即列* y:像素位置的纵坐标,即行* rgb:像素的值,采用 16 进制,如 0xFFFFFF 白色*/BufferedImage bufferedImage = new BufferedImage(CODE_WIDTH, CODE_HEIGHT, BufferedImage.TYPE_INT_BGR);for (int x = 0; x < CODE_WIDTH; x++) {for (int y = 0; y < CODE_HEIGHT; y++) {bufferedImage.setRGB(x, y, bitMatrix.get(x, y) ? FRONT_COLOR : BACKGROUND_COLOR);}}/**javax.imageio.ImageIO java 扩展的图像IO* write(RenderedImage im,String formatName,File output)* im:待写入的图像* formatName:图像写入的格式* output:写入的图像文件,文件不存在时会自动创建** 即将保存的二维码图片文件*/File codeImgFile = new File(codeImgFileSaveDir, fileName);ImageIO.write(bufferedImage, DEFAULT_IMG, codeImgFile);log.info("二维码图片生成成功:" + codeImgFile.getPath());} catch (Exception e) {e.printStackTrace();}}/*** 生成二维码 并 输出到输出流————通常用于输出到网页上进行显示* 输出到网页与输出到磁盘上的文件中,区别在于最后一句 ImageIO.write* write(RenderedImage im,String formatName,File output):写到文件中* write(RenderedImage im,String formatName,OutputStream output):输出到输出流中** @param codeContent :二维码内容* @param outputStream :输出流,比如 HttpServletResponse 的 getOutputStream*/public static void createCodeToOutputStream(String codeContent, OutputStream outputStream) {try {/** 参数检验*/if (codeContent == null || "".equals(codeContent.trim())) {System.out.println("二维码内容为空,不进行操作...");return;}codeContent = codeContent.trim();/**com.google.zxing.EncodeHintType:编码提示类型,枚举类型* EncodeHintType.CHARACTER_SET:设置字符编码类型* EncodeHintType.ERROR_CORRECTION:设置误差校正* ErrorCorrectionLevel:误差校正等级,L = ~7% correction、M = ~15% correction、Q = ~25% correction、H = ~30% correction* 不设置时,默认为 L 等级,等级不一样,生成的图案不同,但扫描的结果是一样的* EncodeHintType.MARGIN:设置二维码边距,单位像素,值越小,二维码距离四周越近* */Map<EncodeHintType, Object> hints = new HashMap();hints.put(EncodeHintType.CHARACTER_SET, CHARSET);hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);hints.put(EncodeHintType.MARGIN, 1);/*** MultiFormatWriter:多格式写入,这是一个工厂类,里面重载了两个 encode 方法,用于写入条形码或二维码* encode(String contents,BarcodeFormat format,int width, int height,Map<EncodeHintType,?> hints)* contents:条形码/二维码内容* format:编码类型,如 条形码,二维码 等* width:码的宽度* height:码的高度* hints:码内容的编码类型* BarcodeFormat:枚举该程序包已知的条形码格式,即创建何种码,如 1 维的条形码,2 维的二维码 等* BitMatrix:位(比特)矩阵或叫2D矩阵,也就是需要的二维码*/MultiFormatWriter multiFormatWriter = new MultiFormatWriter();BitMatrix bitMatrix = multiFormatWriter.encode(codeContent, BarcodeFormat.QR_CODE, CODE_WIDTH, CODE_HEIGHT, hints);/**java.awt.image.BufferedImage:具有图像数据的可访问缓冲图像,实现了 RenderedImage 接口* BitMatrix 的 get(int x, int y) 获取比特矩阵内容,指定位置有值,则返回true,将其设置为前景色,否则设置为背景色* BufferedImage 的 setRGB(int x, int y, int rgb) 方法设置图像像素* x:像素位置的横坐标,即列* y:像素位置的纵坐标,即行* rgb:像素的值,采用 16 进制,如 0xFFFFFF 白色*/BufferedImage bufferedImage = new BufferedImage(CODE_WIDTH, CODE_HEIGHT, BufferedImage.TYPE_INT_BGR);for (int x = 0; x < CODE_WIDTH; x++) {for (int y = 0; y < CODE_HEIGHT; y++) {bufferedImage.setRGB(x, y, bitMatrix.get(x, y) ? FRONT_COLOR : BACKGROUND_COLOR);}}/*** 区别就是以一句,输出到输出流中,如果第三个参数是 File,则输出到文件中*/ImageIO.write(bufferedImage, DEFAULT_IMG, outputStream);log.info("二维码图片生成到输出流成功...");} catch (Exception e) {e.printStackTrace();}}/*** Description 内容转二维码图片并将图片进行Base64编码返回字符串** @param codeContent codeContent* @return void* @date 11:36 2022/8/5*/public static String createImgCodeBase64Str(String codeContent) {/** 参数检验*/if (codeContent == null || "".equals(codeContent.trim())) {System.out.println("二维码内容为空,不进行操作...");return "";}codeContent = codeContent.trim();try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {Map<EncodeHintType, Object> hints = new HashMap();hints.put(EncodeHintType.CHARACTER_SET, CHARSET);hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);hints.put(EncodeHintType.MARGIN, 1);MultiFormatWriter multiFormatWriter = new MultiFormatWriter();BitMatrix bitMatrix = multiFormatWriter.encode(codeContent, BarcodeFormat.QR_CODE, CODE_WIDTH, CODE_HEIGHT, hints);BufferedImage bufferedImage = new BufferedImage(CODE_WIDTH, CODE_HEIGHT, BufferedImage.TYPE_INT_BGR);for (int x = 0; x < CODE_WIDTH; x++) {for (int y = 0; y < CODE_HEIGHT; y++) {bufferedImage.setRGB(x, y, bitMatrix.get(x, y) ? FRONT_COLOR : BACKGROUND_COLOR);}}ImageIO.write(bufferedImage, DEFAULT_IMG, byteArrayOutputStream);String base64Str = Base64.getEncoder().encodeToString(byteArrayOutputStream.toByteArray());log.info("二维码base64输出流:" + base64Str);return base64Str;} catch (Exception e) {log.error("二维码base64转化失败:" + e.getMessage());}return "";}/*** Description 内容转带logo二维码图片并将图片进行Base64编码返回字符串** @param codeContent codeContent* @param imgPath logo图片地址* @return void* @date 11:36 2022/8/5*/public static String createLogoImgCodeBase64Str(String codeContent, String imgPath) {/** 参数检验*/if (StrUtil.isEmpty(codeContent)) {System.out.println("二维码内容为空,不进行操作...");return "";}if (StrUtil.isEmpty(imgPath)) {imgPath = DEFAULT_LOGO_FILE;}codeContent = codeContent.trim();try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {BufferedImage bufferedImage = createImageWithLogo(codeContent, imgPath, true);ImageIO.write(bufferedImage, DEFAULT_IMG, byteArrayOutputStream);String base64Str = Base64.getEncoder().encodeToString(byteArrayOutputStream.toByteArray());log.info("二维码base64输出流:" + base64Str);return base64Str;} catch (Exception e) {log.error("二维码base64转化失败:" + e.getMessage());}return "";}/*** Description 解码base64位的图片的内容** @param base64Str base64Str加密字符串* @return void* @date 11:36 2022/8/5* */public static String parseQRCodeFromBase64Str(String base64Str) {String resultStr = null;try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(Base64.getDecoder().decode(base64Str))) {/**ImageIO 的 BufferedImage read(URL input) 方法用于读取网络图片文件转为内存缓冲图像* 同理还有:read(File input)、read(InputStream input)、、read(ImageInputStream stream)*/BufferedImage bufferedImage = ImageIO.read(byteArrayInputStream);/*** com.google.zxing.client.j2se.BufferedImageLuminanceSource:缓冲图像亮度源* 将 java.awt.image.BufferedImage 转为 zxing 的 缓冲图像亮度源* 关键就是下面这几句:HybridBinarizer 用于读取二维码图像数据,BinaryBitmap 二进制位图*/BufferedImageLuminanceSource source = new BufferedImageLuminanceSource(bufferedImage);BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));Hashtable hints = new Hashtable();hints.put(DecodeHintType.CHARACTER_SET, CHARSET);/*** 如果图片不是二维码图片,则 decode 抛异常:com.google.zxing.NotFoundException* MultiFormatWriter 的 encode 用于对内容进行编码成 2D 矩阵* MultiFormatReader 的 decode 用于读取二进制位图数据*/resultStr = new MultiFormatReader().decode(bitmap, hints).getText();log.info("识别base64解码后内容为" + resultStr);} catch (Exception e) {e.printStackTrace();log.error("识别base64字符串失败");}return resultStr;}/*** 根据本地二维码图片————————解析二维码内容* (注:图片必须是二维码图片,但也可以是微信用户二维码名片,上面有名称、头像也是可以的)** @param file 本地二维码图片文件,如 E:\\logs\\2.jpg* @return* @throws Exception*/public static String parseQRCodeByFile(File file) {String resultStr = null;if (file == null || file.isDirectory() || !file.exists()) {return resultStr;}try {/**ImageIO 的 BufferedImage read(URL input) 方法用于读取网络图片文件转为内存缓冲图像* 同理还有:read(File input)、read(InputStream input)、、read(ImageInputStream stream)*/BufferedImage bufferedImage = ImageIO.read(file);/*** com.google.zxing.client.j2se.BufferedImageLuminanceSource:缓冲图像亮度源* 将 java.awt.image.BufferedImage 转为 zxing 的 缓冲图像亮度源* 关键就是下面这几句:HybridBinarizer 用于读取二维码图像数据,BinaryBitmap 二进制位图*/BufferedImageLuminanceSource source = new BufferedImageLuminanceSource(bufferedImage);BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));Hashtable hints = new Hashtable();hints.put(DecodeHintType.CHARACTER_SET, CHARSET);/*** 如果图片不是二维码图片,则 decode 抛异常:com.google.zxing.NotFoundException* MultiFormatWriter 的 encode 用于对内容进行编码成 2D 矩阵* MultiFormatReader 的 decode 用于读取二进制位图数据*/resultStr = new MultiFormatReader().decode(bitmap, hints).getText();} catch (IOException e) {e.printStackTrace();} catch (NotFoundException e) {e.printStackTrace();log.error("-----图片非二维码图片:" + file.getPath());}return resultStr;}/*** 根据网络二维码图片————————解析二维码内容* (区别仅仅在于 ImageIO.read(url); 这一个重载的方法)** @param url 二维码图片网络地址,如 https://res.wx.qq.com/mpres/htmledition/images/mp_qrcode3a7b38.gif* @return* @throws Exception*/public static String parseQRCodeByUrl(URL url) {String resultStr = null;if (url == null) {return resultStr;}try {/**ImageIO 的 BufferedImage read(URL input) 方法用于读取网络图片文件转为内存缓冲图像* 同理还有:read(File input)、read(InputStream input)、、read(ImageInputStream stream)** 如果图片网络地址错误,比如不能访问,则 read 抛异常:javax.imageio.IIOException: Can't get input stream from URL!*/BufferedImage bufferedImage = ImageIO.read(url);/*** com.google.zxing.client.j2se.BufferedImageLuminanceSource:缓冲图像亮度源* 将 java.awt.image.BufferedImage 转为 zxing 的 缓冲图像亮度源* 关键就是下面这几句:HybridBinarizer 用于读取二维码图像数据,BinaryBitmap 二进制位图*/BufferedImageLuminanceSource source = new BufferedImageLuminanceSource(bufferedImage);BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));Hashtable hints = new Hashtable();/*** 如果内容包含中文,则解码的字符集格式应该和编码时一致*/hints.put(DecodeHintType.CHARACTER_SET, CHARSET);/*** 如果图片不是二维码图片,则 decode 抛异常:com.google.zxing.NotFoundException* MultiFormatWriter 的 encode 用于对内容进行编码成 2D 矩阵* MultiFormatReader 的 decode 用于读取二进制位图数据*/resultStr = new MultiFormatReader().decode(bitmap, hints).getText();} catch (IOException e) {e.printStackTrace();log.error("-----二维码图片地址错误:" + url);} catch (NotFoundException e) {e.printStackTrace();log.error(("-----图片非二维码图片:" + url));}return resultStr;}/*** Description base64存储的图片字节码转出成图片** @param base64Str base64Str* @return void* @date 16:09 2022/8/5* */public static void parseBase64ImgStrToFile(String base64Str, String filePath) {String fileName = System.currentTimeMillis() + "." + DEFAULT_IMG;if (StrUtil.isEmpty(filePath)) {filePath = getDefaultFileSavePath();}try (FileOutputStream fileOutputStream = new FileOutputStream(filePath + fileName)) {byte[] bytes = Base64.getDecoder().decode(base64Str);fileOutputStream.write(bytes);} catch (Exception e) {e.getMessage();log.error("解析base64转图片失败" + e.getMessage());}}// 带logo的二维码图片/*** Description 生成带logo的二维码图片** @param content 图片内容* @param imgPath logo图片地址* @param needCompress 是否需要log图片压缩* @return java.awt.image.BufferedImage* @date 11:13 2022/8/8* */private static BufferedImage createImageWithLogo(String content, String imgPath, boolean needCompress) {Hashtable hints = new Hashtable();hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);hints.put(EncodeHintType.CHARACTER_SET, CHARSET);hints.put(EncodeHintType.MARGIN, 1);BitMatrix bitMatrix = null;try {bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, CODE_WIDTH, CODE_HEIGHT,hints);} catch (WriterException e) {log.error("创建logo二维码图片失败" + e.getMessage());throw BusinessException.create("创建logo二维码图片失败");}int width = bitMatrix.getWidth();int height = bitMatrix.getHeight();BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);for (int x = 0; x < width; x++) {for (int y = 0; y < height; y++) {image.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF);}}if (imgPath == null || "".equals(imgPath)) {return image;}// 插入图片QRCodeUtils.insertImage(image, imgPath, needCompress);return image;}/*** Description 插入logo图片** @param source BufferedImage源* @param imgPath logo图片地址* @param needCompress 是否压缩* @return void* @date 11:45 2022/8/8* */private static void insertImage(BufferedImage source, String imgPath, boolean needCompress) {File file = new File(imgPath);if (!file.exists()) {log.info("logo文件不存在!");return;}try {Image src = ImageIO.read(new File(imgPath));int width = src.getWidth(null);int height = src.getHeight(null);if (needCompress) { // 压缩LOGOif (width > WIDTH) {width = WIDTH;}if (height > HEIGHT) {height = HEIGHT;}Image image = src.getScaledInstance(width, height, Image.SCALE_SMOOTH);BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);Graphics g = tag.getGraphics();g.drawImage(image, 0, 0, null); // 绘制缩小后的图g.dispose();src = image;}// 插入LOGOGraphics2D graph = source.createGraphics();int x = (CODE_WIDTH - width) / 2;int y = (CODE_HEIGHT - height) / 2;graph.drawImage(src, x, y, width, height, null);Shape shape = new RoundRectangle2D.Float(x, y, width, width, 6, 6);graph.setStroke(new BasicStroke(3f));graph.draw(shape);graph.dispose();} catch (IOException e) {e.printStackTrace();log.error("插入logo图片失败" + e.getMessage());throw BusinessException.create("插入logo图片失败");}}/*** Description 生成logo二维码** @param content content* @param imgPath logo图片位置* @param destPath 生成二维码存储位置* @param needCompress needCompress* @return void* @author 汪少明* @date 12:37 2022/8/8* */public static void createLogoImgToFile(String content, String imgPath, String destPath, boolean needCompress) {BufferedImage image = QRCodeUtils.createImageWithLogo(content, imgPath, needCompress);mkdirs(destPath);String fileName = "";if (fileName == null || "".equals(fileName)) {fileName = System.currentTimeMillis() + "." + DEFAULT_IMG;}String path = getDefaultFileSavePath();try {ImageIO.write(image, DEFAULT_IMG, new File(path + fileName));} catch (IOException e) {e.printStackTrace();throw BusinessException.create("生成二维码失败");}}/*** Description 生成logo二维码** @param content 二维码内容* @param imgPath logo图片地址* @param needCompress needCompress* @date 12:39 2022/8/8* */private static void createLogoImgToFile(String content, String imgPath, boolean needCompress) {String destPath = getDefaultFileSavePath();createLogoImgToFile(content, imgPath, destPath, needCompress);}/*** Description 生成logo二维码** @param content content* @param imgPath logo图片地址* @param destPath 二维码生成存储位置* @return void* @date 11:43 2022/8/8* */public static void createLogoImgToFile(String content, String imgPath, String destPath) throws Exception {QRCodeUtils.createLogoImgToFile(content, imgPath, destPath, false);}/*** Description 生成logo二维码** @param content content* @param destPath 二维码生成存储位置* @return void* @date 11:43 2022/8/8* */public static void createLogoImgToFile(String content, String destPath) throws Exception {QRCodeUtils.createLogoImgToFile(content, null, destPath, false);}/*** Description 生成logo二维码** @param content content* @param imgPath logo图片地址* @param output 输出流* @param needCompress 是否压缩* @return void* @date 11:43 2022/8/8* */public static void createLogoImgToFile(String content, String imgPath, OutputStream output, boolean needCompress)throws Exception {BufferedImage image = QRCodeUtils.createImageWithLogo(content, imgPath, needCompress);ImageIO.write(image, DEFAULT_IMG, output);}/*** Description 生成logo二维码** @param content content* @param output 输出流* @return void* @date 11:43 2022/8/8* */public static void createLogoImgToFile(String content, OutputStream output) throws Exception {QRCodeUtils.createLogoImgToFile(content, null, output, false);}private static void mkdirs(String destPath) {if (StrUtil.isEmpty(destPath)) {// win 默认桌面 linuxdestPath = getDefaultFileSavePath();}File file = new File(destPath);// 当文件夹不存在时,mkdirs会自动创建多层目录,区别于mkdir.(mkdir如果父目录不存在则会抛出异常)if (!file.exists() && !file.isDirectory()) {file.mkdirs();}}/*** * Description 区分操作系统* * @param* * @return java.lang.String* * @date 11:43 2022/8/8* */private static String getDefaultFileSavePath() {String os = System.getProperties().getProperty("os.name");String tempPath = "";if (os.startsWith("win") || os.startsWith("Win")) {tempPath = WIN_TEMP_PATH;mkdirs(tempPath);} else {tempPath = LINUX_TEMP_PATH;}return tempPath;}public static void main(String[] args) {//String contentStr = "FEDB812F9F3A7B6AE1584C1132C1A333B1DC3389332FFA0E7C458B2F96323ED0:1";// String contentStr = "FEDB812F9F3A7B6AE1584C1132C1A333B1DC3389332FFA0E7C458B2F96323ED0:1";// String imgPath = "C:\\Users\\wangsm\\Desktop\\test\\logger.JPG";//createCodeToFile(contentStr,new File("C:\\Users\\wangsm\\Desktop\\test"), "");// URL url = new URL("https://res.wx.qq.com/mpres/htmledition/images/mp_qrcode3a7b38.gif");// String netQRcodeContent = parseQRCodeByUrl(url);//System.out.println(url + " 二维码内容:" + netQRcodeContent);// String base64Str = createImgCodeBase64Str(contentStr);// base64串转图片//String base64Str = createImgCodeBase64Str(contentStr);// log.info("base64加密串:" + base64Str);// base64加密串转图片// parseBase64ImgStrToFile(base64Str);// 识别base64图片内容//String demoBase64Str = "/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCADIAMgDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+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DaXggjWcTiMiJllIBVgQuGyMYHIxXUUUAeP8Awy8E+IpP7U/4WVp/9p48r7B/as0d95f3/M2ZZ9mf3eemcDrivSLHwn4b0y8jvLDw/pVpdR52TQWUcbrkEHDAZGQSPxrYooAy9S8NaDrNwtxqmiabfTqgRZLq1SVguScAsCcZJOPc15v8WfhjFqvhW1g8H+GNNTUFvUeQ2sMNu3lbHByx25G4rxn09K9cooA+bPBvgX4s6Hr2iRSrqVtotvexPPAmrJ5SxeYGk/drJggjcSAOcnrmvQ/jBo3jnV/7G/4QuW+j8rz/ALX9kvxbZz5ezOXXd0f1xz616hRQBl+Gob628K6RBqhkOoR2UKXRkk3sZQgD5bJ3HdnnJzWpRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH/2Q==";//parseQRCodeFromBase64Str(base64Str);// 读取文件内容/* File localFile = new File("C:\\Users\\wangsm\\Desktop\\test\\1659922451114.JPG");String localQRcodeContent = parseQRCodeByFile(localFile);System.out.println(localFile + " 二维码内容:" + localQRcodeContent);*/// 生成带logo的二维码图片// createLogoImgToFile(contentStr, imgPath, true);// 解析带二维码的图片//decodeLogoImg("C:\\Users\\wangsm\\Desktop\\test\\1659936905494.JPG");// 带logo图片base64加密// String logBase64Str = createLogoImgCodeBase64Str(contentStr, null);// 解析带logo的base64字符串内容// parseQRCodeFromBase64Str(logBase64Str);// 识别带logo二维码图片内容// File localFile = new File("C:\\Users\\wangsm\\Desktop\\test\\1659937481369.JPG");// String localQRcodeContent = parseQRCodeByFile(localFile);// System.out.println(localFile + " 二维码内容:" + localQRcodeContent);// 识别带logo的base64串转图片//parseBase64ImgStrToFile(logBase64Str, null);}
}
参考:java实现二维码的生成与解析_jam_fanatic的博客-CSDN博客_java二维码解析
在线检验工具:Convert Base64 to Image - Online Image Tools