1.生成二维码
public static byte[] generateQRCodeImages(String text, int width, int height) throws WriterException, IOException {
String binary = null;
QRCodeWriter qrCodeWriter = new QRCodeWriter();
//调整白边大小
Hashtable<EncodeHintType, Object> hints = new Hashtable<>();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
hints.put(EncodeHintType.MARGIN, 1);
BitMatrix bitMatrix = qrCodeWriter.encode(text, BarcodeFormat.QR_CODE, width, height,hints);
//BitMatrix bitMatrix = qrCodeWriter.encode(text, BarcodeFormat.QR_CODE, width, height);
//bitMatrix = deleteWhite(bitMatrix);
ByteArrayOutputStream out = new ByteArrayOutputStream();
MatrixToImageWriter.writeToStream(bitMatrix,"PNG",out);
byte[] byteArray = out.toByteArray

最低0.47元/天 解锁文章
1831

被折叠的 条评论
为什么被折叠?



