MCPcopy
hub / github.com/zxing-js/library / MultiFormatReader

Class MultiFormatReader

src/core/MultiFormatReader.ts:43–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected