Package com.google.zxing
Class MultiFormatReader
- java.lang.Object
-
- com.google.zxing.MultiFormatReader
-
- All Implemented Interfaces:
Reader
public final class MultiFormatReader extends java.lang.Object implements Reader
MultiFormatReader is a convenience class and the main entry point into the library for most uses. By default it attempts to decode all barcode formats that the library supports. Optionally, you can provide a hints object to request different behavior, for example only decoding QR codes.
-
-
Field Summary
Fields Modifier and Type Field Description private static Reader[]
EMPTY_READER_ARRAY
private java.util.Map<DecodeHintType,?>
hints
private Reader[]
readers
-
Constructor Summary
Constructors Constructor Description MultiFormatReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Result
decode(BinaryBitmap image)
This version of decode honors the intent of Reader.decode(BinaryBitmap) in that it passes null as a hint to the decoders.Result
decode(BinaryBitmap image, java.util.Map<DecodeHintType,?> hints)
Decode an image using the hints provided.private Result
decodeInternal(BinaryBitmap image)
Result
decodeWithState(BinaryBitmap image)
Decode an image using the state set up by calling setHints() previously.void
reset()
Resets any internal state the implementation has after a decode, to prepare it for reuse.void
setHints(java.util.Map<DecodeHintType,?> hints)
This method adds state to the MultiFormatReader.
-
-
-
Field Detail
-
EMPTY_READER_ARRAY
private static final Reader[] EMPTY_READER_ARRAY
-
hints
private java.util.Map<DecodeHintType,?> hints
-
readers
private Reader[] readers
-
-
Method Detail
-
decode
public Result decode(BinaryBitmap image) throws NotFoundException
This version of decode honors the intent of Reader.decode(BinaryBitmap) in that it passes null as a hint to the decoders. However, that makes it inefficient to call repeatedly. Use setHints() followed by decodeWithState() for continuous scan applications.- Specified by:
decode
in interfaceReader
- Parameters:
image
- The pixel data to decode- Returns:
- The contents of the image
- Throws:
NotFoundException
- Any errors which occurred
-
decode
public Result decode(BinaryBitmap image, java.util.Map<DecodeHintType,?> hints) throws NotFoundException
Decode an image using the hints provided. Does not honor existing state.- Specified by:
decode
in interfaceReader
- Parameters:
image
- The pixel data to decodehints
- The hints to use, clearing the previous state.- Returns:
- The contents of the image
- Throws:
NotFoundException
- Any errors which occurred
-
decodeWithState
public Result decodeWithState(BinaryBitmap image) throws NotFoundException
Decode an image using the state set up by calling setHints() previously. Continuous scan clients will get a large speed increase by using this instead of decode().- Parameters:
image
- The pixel data to decode- Returns:
- The contents of the image
- Throws:
NotFoundException
- Any errors which occurred
-
setHints
public void setHints(java.util.Map<DecodeHintType,?> hints)
This method adds state to the MultiFormatReader. By setting the hints once, subsequent calls to decodeWithState(image) can reuse the same set of readers without reallocating memory. This is important for performance in continuous scan clients.- Parameters:
hints
- The set of hints to use for subsequent calls to decode(image)
-
reset
public void reset()
Description copied from interface:Reader
Resets any internal state the implementation has after a decode, to prepare it for reuse.
-
decodeInternal
private Result decodeInternal(BinaryBitmap image) throws NotFoundException
- Throws:
NotFoundException
-
-