我正在使用 zxing 解码 QRcode 图像,但它总是返回 NotFoundException。http://zxing.org/w/decode.jspx上的在线解码器可以完美地扫描这些图像,所以它应该能够在我的应用程序中这样做。我正在使用这段代码:
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");
}
你能帮忙吗?