MCPcopy
hub / github.com/zxing/zxing / MultiFormatReader

Class MultiFormatReader

core/src/main/java/com/google/zxing/MultiFormatReader.java:38–199  ·  view source on GitHub ↗

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. @author Sea

Source from the content-addressed store, hash-verified

36 * @author dswitkin@google.com (Daniel Switkin)
37 */
38public final class MultiFormatReader implements Reader {
39
40 private static final Reader[] EMPTY_READER_ARRAY = new Reader[0];
41
42 private Map<DecodeHintType,?> hints;
43 private Reader[] readers;
44
45 /**
46 * This version of decode honors the intent of Reader.decode(BinaryBitmap) in that it
47 * passes null as a hint to the decoders. However, that makes it inefficient to call repeatedly.
48 * Use setHints() followed by decodeWithState() for continuous scan applications.
49 *
50 * @param image The pixel data to decode
51 * @return The contents of the image
52 * @throws NotFoundException Any errors which occurred
53 */
54 @Override
55 public Result decode(BinaryBitmap image) throws NotFoundException {
56 setHints(null);
57 return decodeInternal(image);
58 }
59
60 /**
61 * Decode an image using the hints provided. Does not honor existing state.
62 *
63 * @param image The pixel data to decode
64 * @param hints The hints to use, clearing the previous state.
65 * @return The contents of the image
66 * @throws NotFoundException Any errors which occurred
67 */
68 @Override
69 public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException {
70 setHints(hints);
71 return decodeInternal(image);
72 }
73
74 /**
75 * Decode an image using the state set up by calling setHints() previously. Continuous scan
76 * clients will get a <b>large</b> speed increase by using this instead of decode().
77 *
78 * @param image The pixel data to decode
79 * @return The contents of the image
80 * @throws NotFoundException Any errors which occurred
81 */
82 public Result decodeWithState(BinaryBitmap image) throws NotFoundException {
83 // Make sure to set up the default state so we don't crash
84 if (readers == null) {
85 setHints(null);
86 }
87 return decodeInternal(image);
88 }
89
90 /**
91 * This method adds state to the MultiFormatReader. By setting the hints once, subsequent calls
92 * to decodeWithState(image) can reuse the same set of readers without reallocating memory. This
93 * is important for performance in continuous scan clients.
94 *
95 * @param hints The set of hints to use for subsequent calls to decode(image)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected