public static void main(String[] args) {
File file = new File("G:/imooc/code/qrCodeImg.png");
try {
BufferedImage bi = ImageIO.read(file);
QRCodeDecoder decoder = new QRCodeDecoder();
System.out.println("开始解析...");
byte[] data = decoder.decode(new MyQRCodeImage(bi));
String result = new String(data , "UTF-8");
System.out.println("解析出来的数据为:" + result);
} catch (DecodingFailedException dfe) {
System.out.println("Error: " + dfe.getMessage());
dfe.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
在做QRCode测试解析二维码的时候报了这个错误
Error: Give up decoding
jp.sourceforge.qrcode.exception.DecodingFailedException: Give up decoding
at jp.sourceforge.qrcode.QRCodeDecoder.decode(QRCodeDecoder.java:88)
at cn.zhang.qrcode.ReadQRCode_test.main(ReadQRCode_test.java:29)
在网上查了很多资料,没有找到解决办法