我有一个从服务器接收二维码的应用程序。我想解码它(不是用意图和相机)并在我的应用程序中显示它包含的文本。我已经在 Java SE 中使用来自 zxing 的 jars 使用以下代码完成了此操作:
private class QRCodeDecoder {
public String decode(File imageFile) {
BufferedImage image;
try {
image = ImageIO.read(imageFile);
} catch (IOException e1) {
return "io outch";
}
// creating luminance source
LuminanceSource lumSource = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(lumSource));
// barcode decoding
QRCodeReader reader = new QRCodeReader();
Result result = null;
try {
result = reader.decode(bitmap);
} catch (ReaderException e) {
return "reader error";
}
return result.getText();
}
}
但在 Android 上,找不到 BufferedImage。有没有人从手机上存储的图像中解码出安卓上的二维码?肿瘤坏死因子。