Java Code Examples for com.google.zxing.MultiFormatReader#reset()
The following examples show how to use
com.google.zxing.MultiFormatReader#reset() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DecodeUtils.java From myapplication with Apache License 2.0 | 6 votes |
public Result decodeWithZxing(Bitmap bitmap) { MultiFormatReader multiFormatReader = new MultiFormatReader(); multiFormatReader.setHints(changeZXingDecodeDataMode()); int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] pixels = new int[width * height]; bitmap.getPixels(pixels, 0, width, 0, 0, width, height); Result rawResult = null; RGBLuminanceSource source = new RGBLuminanceSource(width, height, pixels); BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(source)); try { rawResult = multiFormatReader.decodeWithState(binaryBitmap); } catch (ReaderException re) { // continue } finally { multiFormatReader.reset(); } return rawResult; }
Example 2
Source File: DecodeUtils.java From SimplifyReader with Apache License 2.0 | 6 votes |
public String decodeWithZxing(byte[] data, int width, int height, Rect crop) { MultiFormatReader multiFormatReader = new MultiFormatReader(); multiFormatReader.setHints(changeZXingDecodeDataMode()); Result rawResult = null; PlanarYUVLuminanceSource source = new PlanarYUVLuminanceSource(data, width, height, crop.left, crop.top, crop.width(), crop.height(), false); if (source != null) { BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); try { rawResult = multiFormatReader.decodeWithState(bitmap); } catch (ReaderException re) { // continue } finally { multiFormatReader.reset(); } } return rawResult != null ? rawResult.getText() : null; }
Example 3
Source File: DecodeUtils.java From SimplifyReader with Apache License 2.0 | 6 votes |
public String decodeWithZxing(Bitmap bitmap) { MultiFormatReader multiFormatReader = new MultiFormatReader(); multiFormatReader.setHints(changeZXingDecodeDataMode()); int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] pixels = new int[width * height]; bitmap.getPixels(pixels, 0, width, 0, 0, width, height); Result rawResult = null; RGBLuminanceSource source = new RGBLuminanceSource(width, height, pixels); if (source != null) { BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(source)); try { rawResult = multiFormatReader.decodeWithState(binaryBitmap); } catch (ReaderException re) { // continue } finally { multiFormatReader.reset(); } } return rawResult != null ? rawResult.getText() : null; }
Example 4
Source File: Utils.java From code-scanner with MIT License | 5 votes |
@Nullable public static Result decodeLuminanceSource(@NonNull final MultiFormatReader reader, @NonNull final LuminanceSource luminanceSource) throws ReaderException { try { return reader.decodeWithState(new BinaryBitmap(new HybridBinarizer(luminanceSource))); } catch (final NotFoundException e) { return reader.decodeWithState( new BinaryBitmap(new HybridBinarizer(luminanceSource.invert()))); } finally { reader.reset(); } }