自动化立体仓库 - WMS系统
13
zhang
2 天以前 82de5a307466894bbb0258f8a63a26a7bb96d80d
src/main/java/com/zy/common/utils/QrCode.java
@@ -20,15 +20,18 @@
    private static final String CHARSET = "utf-8";
    private static final String FORMAT_NAME = "JPG";
    // 二维码尺寸
    private static final int QRCODE_SIZE = 60;
    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);
@@ -45,7 +48,7 @@
        return image;
    }
    private static InputStream convert(BufferedImage image){
    private static InputStream convert(BufferedImage image) {
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        try {
            ImageIO.write(image, FORMAT_NAME, os);
@@ -85,7 +88,6 @@
//        response.getOutputStream().flush();
//        response.getOutputStream().close();
    }
}