自动化立体仓库 - WMS系统
pang.jiabao
2024-11-10 b42da56f5b8fa7a2c7b78485142ed96ac4ea3571
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);