Exemplo n.º 1
0
  Result decodeRow(int rowNumber, BitArray row, int rowOffset) throws NotFoundException {

    int[] extensionStartRange =
        UPCEANReader.findGuardPattern(row, rowOffset, false, EXTENSION_START_PATTERN);

    StringBuilder result = decodeRowStringBuffer;
    result.setLength(0);
    int end = decodeMiddle(row, extensionStartRange, result);

    String resultString = result.toString();
    Map<ResultMetadataType, Object> extensionData = parseExtensionString(resultString);

    Result extensionResult =
        new Result(
            resultString,
            null,
            new ResultPoint[] {
              new ResultPoint(
                  (extensionStartRange[0] + extensionStartRange[1]) / 2.0f, (float) rowNumber),
              new ResultPoint((float) end, (float) rowNumber),
            },
            BarcodeFormat.UPC_EAN_EXTENSION);
    if (extensionData != null) {
      extensionResult.putAllMetadata(extensionData);
    }
    return extensionResult;
  }
 Result decodeRow(int rowNumber, BitArray row, int rowOffset) throws NotFoundException {
   int[] extensionStartRange =
       UPCEANReader.findGuardPattern(row, rowOffset, false, EXTENSION_START_PATTERN);
   try {
     return fiveSupport.decodeRow(rowNumber, row, extensionStartRange);
   } catch (ReaderException re) {
     return twoSupport.decodeRow(rowNumber, row, extensionStartRange);
   }
 }
Exemplo n.º 3
0
  int decodeMiddle(BitArray row, int[] startRange, StringBuilder resultString)
      throws NotFoundException {
    int[] counters = decodeMiddleCounters;
    counters[0] = 0;
    counters[1] = 0;
    counters[2] = 0;
    counters[3] = 0;
    int end = row.getSize();
    int rowOffset = startRange[1];

    int lgPatternFound = 0;

    for (int x = 0; x < 5 && rowOffset < end; x++) {
      int bestMatch =
          UPCEANReader.decodeDigit(row, counters, rowOffset, UPCEANReader.L_AND_G_PATTERNS);
      resultString.append((char) ('0' + bestMatch % 10));
      for (int counter : counters) {
        rowOffset += counter;
      }
      if (bestMatch >= 10) {
        lgPatternFound |= 1 << (4 - x);
      }
      if (x != 4) {
        // Read off separator if not last
        while (rowOffset < end && !row.get(rowOffset)) {
          rowOffset++;
        }
        while (rowOffset < end && row.get(rowOffset)) {
          rowOffset++;
        }
      }
    }

    if (resultString.length() != 5) {
      throw NotFoundException.getNotFoundInstance();
    }

    int checkDigit = determineCheckDigit(lgPatternFound);
    if (extensionChecksum(resultString.toString()) != checkDigit) {
      throw NotFoundException.getNotFoundInstance();
    }

    return rowOffset;
  }
Exemplo n.º 4
0
 protected int decodeMiddle(BitArray row, int[] startRange, StringBuffer resultString)
     throws NotFoundException {
   return ean13Reader.decodeMiddle(row, startRange, resultString);
 }
Exemplo n.º 5
0
 public Result decode(BinaryBitmap image, Hashtable hints)
     throws NotFoundException, FormatException {
   return maybeReturnResult(ean13Reader.decode(image, hints));
 }
Exemplo n.º 6
0
 public Result decodeRow(int rowNumber, BitArray row, Hashtable hints)
     throws NotFoundException, FormatException, ChecksumException {
   return maybeReturnResult(ean13Reader.decodeRow(rowNumber, row, hints));
 }