decodeMiddle method

  1. @override
int decodeMiddle(
  1. BitArray row,
  2. List<int> startRange,
  3. StringBuilder result
)
override

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, StringBuilder result) {
  final counters = _decodeMiddleCounters;
  counters[0] = 0;
  counters[1] = 0;
  counters[2] = 0;
  counters[3] = 0;
  final end = row.size;
  int rowOffset = startRange[1];

  int lgPatternFound = 0;

  for (int x = 0; x < 6 && rowOffset < end; x++) {
    final bestMatch = UPCEANReader.decodeDigit(
      row,
      counters,
      rowOffset,
      UPCEANReader.lAndGPatterns,
    );
    result.writeCharCode(48 /* 0 */ + bestMatch % 10);
    for (int counter in counters) {
      rowOffset += counter;
    }
    if (bestMatch >= 10) {
      lgPatternFound |= 1 << (5 - x);
    }
  }

  _determineNumSysAndCheckDigit(result, lgPatternFound);

  return rowOffset;
}