예제 #1
0
 public static void main(String[] args) {
   try {
     BufferedImage qrCodeImg = get2CodeImage("http://www.dajie.com");
     addLogo2CodeImg(qrCodeImg, getLogoPath());
     System.out.println("decode qrcode, content=" + decodeQrcode("D:\\qrcode.png"));
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
예제 #2
0
 private static String decodeQrcode(String filePath) {
   String content = "";
   try {
     BufferedImage image = ImageIO.read(new File(filePath));
     MultiFormatReader reader = new MultiFormatReader();
     LuminanceSource source = new BufferedImageLuminanceSource(image);
     BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
     Result result = reader.decode(bitmap, getDecodeHints());
     content = result.getText();
   } catch (Exception e) {
     e.printStackTrace();
   }
   return content;
 }