//产生二维码
try {
BitMatrix bm = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hm);
Path file = new File("D:\\QRCodeImage\\qr.png").toPath();
MatrixToImageWriter.writeToPath(bm, format, file);
System.out.println("二维码创建成功!");
} catch (Exception e) {
e.printStackTrace();
}
}
解析二维码
private static void readZxing() throws IOException, NotFoundException {
MultiFormatReader read = new MultiFormatReader();
File file = new File("D:\\QRCodeImage\\qr.png");
BufferedImage image = ImageIO.read(file);
Binarizer binarizer = new HybridBinarizer(new BufferedImageLuminanceSource(image));
BinaryBitmap binaryBitmap = new BinaryBitmap(binarizer);
Result res = read.decode(binaryBitmap);
我发你源码
使用道具 举报