zxing
zxing copied to clipboard
不支持直接传入bitmap进行识别么
同问
这样:
public static String decodeShareImage(Bitmap obmp) { String text = ""; int width = obmp.getWidth(); int height = obmp.getHeight(); int[] data = new int[width * height]; obmp.getPixels(data, 0, width, 0, 0, width, height); Result result = null; BinaryBitmap zbitmap = new BinaryBitmap(new HybridBinarizer(new RGBLuminanceSource(width, height, data))); QRCodeReader reader = new QRCodeReader(); try { result = reader.decode(zbitmap); ParsedResult parsedResult = ResultParser.parseResult(result); text = parsedResult.toString(); } catch (OutOfMemoryError e) { } catch (Exception e) { } return text; }