decodeMiddle method
Subclasses override this to decode the portion of a barcode between the start and end guard patterns.
@param row row of black/white values to search @param startRange start/end offset of start guard pattern @param resultString StringBuffer to append decoded chars to @return horizontal offset of first pixel after the "middle" that was decoded @throws NotFoundException if decoding could not complete successfully
Implementation
@override
int decodeMiddle(BitArray row, List<int> startRange, StringBuffer result) {
final counters = _decodeMiddleCounters;
counters.fillRange(0, counters.length, 0);
final end = row.size;
int rowOffset = startRange[1];
for (int x = 0; x < 4 && rowOffset < end; x++) {
final bestMatch = UPCEANReader.decodeDigit(
row,
counters,
rowOffset,
UPCEANReader.lPatterns,
);
result.writeCharCode(48 /* 0 */ + bestMatch);
for (int counter in counters) {
rowOffset += counter;
}
}
final middleRange = UPCEANReader.findGuardPattern(
row,
rowOffset,
true,
UPCEANReader.middlePattern,
);
rowOffset = middleRange[1];
for (int x = 0; x < 4 && rowOffset < end; x++) {
final bestMatch = UPCEANReader.decodeDigit(
row,
counters,
rowOffset,
UPCEANReader.lPatterns,
);
result.writeCharCode(48 /* 0 */ + bestMatch);
for (int counter in counters) {
rowOffset += counter;
}
}
return rowOffset;
}