I want decode the QrCode Image with zxing, below is my code:
public class Test {
public static void main(String[] args) {
String path = "E:\\study\\QRCode\\someimages\\qq.png";
try {
Map<DecodeHintType, Object> tmpHintsMap = new EnumMap<DecodeHintType, Object>(
DecodeHintType.class);
tmpHintsMap.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(
new BufferedImageLuminanceSource(
ImageIO.read(new FileInputStream(path)))));
Result qrCodeResult = new MultiFormatReader().decode(binaryBitmap,
tmpHintsMap);
System.out.println(qrCodeResult.getText());
} catch (Exception e) {
e.printStackTrace();
}
}
}
My QrCode image is qq_qrcode_image.png, get it from attachment file. I got it from website:
http://www.qrstuff.com/,see the attachment file generate_qrcodeimage.png.
I can’t decode this image successfully with my code, but this can be decoded successfully with other qrcode tool.
I follow the debug stack, find the real reason is the dimension be computed is 17.I this case, the Qr version will be zero. The exception “com.google.zxing.NotFoundException” will be thrown. see the attachment file the_debug_stacktrace.png.
I don’t why, could you give me some advice?
Thanks in advanced!
Tom