- public Result decode(MonochromeBitmapSource image, Hashtable hints)
- throws ReaderException {
- Hashtable possibleFormats =
- hints == null ? null : (Hashtable) hints.get(DecodeHintType.POSSIBLE_FORMATS);
- if (possibleFormats == null || possibleFormats.contains(BarcodeFormat.QR_CODE)) {
- return new QRCodeReader().decode(image, hints);
- } else {
- throw new ReaderException();
+ public Result decode(MonochromeBitmapSource image, Hashtable hints) throws ReaderException {
+
+ Vector possibleFormats = hints == null ? null : (Vector) hints.get(DecodeHintType.POSSIBLE_FORMATS);
+ Vector readers = new Vector();
+ if (possibleFormats != null) {
+ if (possibleFormats.contains(BarcodeFormat.UPC_A) ||
+ possibleFormats.contains(BarcodeFormat.UPC_E) ||
+ possibleFormats.contains(BarcodeFormat.EAN_13) ||
+ possibleFormats.contains(BarcodeFormat.EAN_8) ||
+ possibleFormats.contains(BarcodeFormat.CODE_39) ||
+ possibleFormats.contains(BarcodeFormat.CODE_128)) {
+ readers.addElement(new MultiFormatOneDReader());
+ }
+ if (possibleFormats.contains(BarcodeFormat.QR_CODE)) {
+ readers.addElement(new QRCodeReader());
+ }
+ if (possibleFormats.contains(BarcodeFormat.DATAMATRIX)) {
+ readers.addElement(new DataMatrixReader());
+ }
+ }
+ if (readers.isEmpty()) {
+ readers.addElement(new MultiFormatOneDReader());
+ readers.addElement(new QRCodeReader());
+ readers.addElement(new DataMatrixReader());