Android的zxing NotFoundException [英] Android zxing NotFoundException

查看:123
本文介绍了Android的zxing NotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用zxing脱code QR code图像,但它总是返回NotFoundException。网上去codeR在 http://zxing.org/w/de$c $ c.jspx 扫描这些图像完全没有问题,所以它应该是能够做到这一点在我的应用程序。 我使用这个code:

I'm using zxing to decode QRcode images, but it always returns a NotFoundException. The online decoder at http://zxing.org/w/decode.jspx scans these images perfectly fine, so it should be able to do so in my app. I'm using this code :

String path = Environment.getExternalStorageDirectory().getPath()+"/QRPictures/QRTest.bmp";
Bitmap bmp = BitmapFactory.decodeFile(path);
int[] pixels = new int[bmp.getWidth()*bmp.getHeight()];
bmp.getPixels(pixels, 0, bmp.getWidth(), 0, 0, bmp.getWidth(), bmp.getHeight());
LuminanceSource source = new RGBLuminanceSource(bmp.getWidth(), bmp.getHeight(), pixels); 
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Reader reader = new MultiFormatReader();
try {
    Result result = reader.decode(bitmap);
    String contents = result.getText(); 
    Log.d(TAG, content);
} catch (NotFoundException e) {
    Log.d(TAG, "NFE");
} catch (ChecksumException e) {
    Log.d(TAG, "CSE");
} catch (FormatException e) {
    Log.d(TAG, "FE");
} 

你能帮助这个好吗?

Could you help with this please ?

推荐答案

我有这个问题了。我解决了它。 尝试添加此提示您code:

I had this problem too. And I solved it. Try add this hint to your code:

hints.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE);

这篇关于Android的zxing NotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆