return decode(image, null);
}
+ // Note that we don't try rotation without the try harder flag, even if rotation was supported.
public final Result decode(BinaryBitmap image, Hashtable hints) throws ReaderException {
try {
return doDecode(image, hints);
row = image.getBlackRow(rowNumber, row);
} catch (ReaderException re) {
continue;
- }
+ }
// While we have the image data in a BitArray, it's fairly cheap to reverse it in place to
// handle decoding upside down barcodes.
for (int attempt = 0; attempt < 2; attempt++) {
if (attempt == 1) { // trying again?
row.reverse(); // reverse the row and continue
+ // This means we will only ever draw result points *once* in the life of this method
+ // since we want to avoid drawing the wrong points after flipping the row, and,
+ // don't want to clutter with noise from every single row scan -- just the scans
+ // that start on the center line.
+ if (hints != null && hints.containsKey(DecodeHintType.NEED_RESULT_POINT_CALLBACK)) {
+ hints = (Hashtable) hints.clone();
+ hints.remove(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
+ }
}
try {
// Look for a barcode
break;
} else {
counters[counterPosition] = 1;
- isWhite ^= true; // isWhite = !isWhite; Is this too clever? shorter byte code, no conditional
+ isWhite = !isWhite;
}
}
i++;
if (variance > maxIndividualVariance) {
return Integer.MAX_VALUE;
}
- totalVariance += variance;
+ totalVariance += variance;
}
return totalVariance / total;
}