From 53e8b479c720d5bd5c8d279c3fd6eacb7fa1603b Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@63.com> Date: 星期二, 07 六月 2022 10:28:53 +0800 Subject: [PATCH] Merge branch 'jkasrs' of http://47.97.1.152:5880/r/zy-asrs into jkasrs --- src/main/java/com/zy/common/utils/QrCode.java | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/zy/common/utils/QrCode.java b/src/main/java/com/zy/common/utils/QrCode.java index d2e86c6..ee63247 100644 --- a/src/main/java/com/zy/common/utils/QrCode.java +++ b/src/main/java/com/zy/common/utils/QrCode.java @@ -23,11 +23,15 @@ private static final int QRCODE_SIZE = 150; public static BufferedImage createImg(String content) throws WriterException { - ConcurrentHashMap hints = new ConcurrentHashMap(); + return createImg(content, QRCODE_SIZE, QRCODE_SIZE); + } + + public static BufferedImage createImg(String content, Integer wid, Integer hei) throws WriterException { + ConcurrentHashMap<EncodeHintType, Object> hints = new ConcurrentHashMap<>(); hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); hints.put(EncodeHintType.CHARACTER_SET, CHARSET); hints.put(EncodeHintType.MARGIN, 1); - BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, QRCODE_SIZE, QRCODE_SIZE, hints); + BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, wid, hei, hints); int width = bitMatrix.getWidth(); int height = bitMatrix.getHeight(); BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); -- Gitblit v1.9.1