package cn.qrcode; import java.awt.image.BufferedImage; import java.io.File; import java.util.HashMap; import java.util.Map; import javax.imageio.ImageIO; import com.google.zxing.BarcodeFormat; import com.google.zxing.Binarizer; import com.google.zxing.BinaryBitmap; import com.google.zxing.EncodeHintType; import com.google.zxing.LuminanceSource; import com.google.zxing.MultiFormatReader; import com.google.zxing.MultiFormatWriter; import com.google.zxing.Result; import com.google.zxing.client.j2se.BufferedImageLuminanceSource; import com.google.zxing.client.j2se.MatrixToImageWriter; import com.google.zxing.common.BitMatrix; import com.google.zxing.common.HybridBinarizer; /** * * */ public class QRTest { public static void main(String[] args) { //create(); parse(); } private static void create() { try { String content = "120605181003;http://www.cnblogs.com/jtmjx"; String path = "src"; MultiFormatWriter multiFormatWriter = new MultiFormatWriter(); Map hints = new HashMap(); hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); // QR_CODE: //这里是二维码 // CODE_128: //这个可以生成 // PDF_417: //这个可以生成 BitMatrix bitMatrix = multiFormatWriter.encode(content, BarcodeFormat.QR_CODE, 400, 400, hints); File file1 = new File(path, "dd.jpg"); MatrixToImageWriter.writeToFile(bitMatrix, "jpg", file1); System.out.println("图片完成!"); } catch (Exception e) { e.printStackTrace(); } } /** * */ public static void parse() { try { MultiFormatReader formatReader = new MultiFormatReader(); String filePath = "src/a.jpg"; File file = new File(filePath); BufferedImage image = ImageIO.read(file); LuminanceSource source = new BufferedImageLuminanceSource(image); Binarizer binarizer = new HybridBinarizer(source); BinaryBitmap binaryBitmap = new BinaryBitmap(binarizer); Map hints = new HashMap(); hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); Result result = formatReader.decode(binaryBitmap, hints); System.out.println("result = " + result.toString()); System.out.println("resultFormat = " + result.getBarcodeFormat()); System.out.println("resultText = " + result.getText()); } catch (Exception e) { e.printStackTrace(); } } }

lwt123456 LV1
2021年12月1日
newbag LV9
2021年8月9日
wyx065747 LV67
2021年7月9日
17587079094 LV6
2021年4月27日
robinyu1022 LV1
2021年1月22日
yccycc2002 LV1
2020年9月2日
739520942 LV8
2020年8月6日
huasir2018 LV14
2020年5月9日
没文化 LV1
2020年4月23日
雨泽ta姓郝 LV2
2020年4月15日