public Result decode(BinaryBitmap image, Hashtable hints)
     throws NotFoundException, ChecksumException, FormatException {
   DecoderResult decoderResult;
   ResultPoint[] points;
   if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) {
     BitMatrix bits = extractPureBits(image.getBlackMatrix());
     decoderResult = decoder.decode(bits);
     points = NO_POINTS;
   } else {
     DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect();
     decoderResult = decoder.decode(detectorResult.getBits());
     points = detectorResult.getPoints();
   }
   Result result =
       new Result(
           decoderResult.getText(),
           decoderResult.getRawBytes(),
           points,
           BarcodeFormat.DATA_MATRIX);
   if (decoderResult.getByteSegments() != null) {
     result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, decoderResult.getByteSegments());
   }
   if (decoderResult.getECLevel() != null) {
     result.putMetadata(
         ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult.getECLevel().toString());
   }
   return result;
 }
Пример #2
0
 public final Result decode(BinaryBitmap binarybitmap, Map map)
     throws NotFoundException, ChecksumException, FormatException {
   java.util.List list;
   if (map != null && map.containsKey(DecodeHintType.PURE_BARCODE)) {
     binarybitmap = extractPureBits(binarybitmap.getBlackMatrix());
     binarybitmap = decoder.decode(binarybitmap);
     map = NO_POINTS;
   } else {
     map = (new Detector(binarybitmap.getBlackMatrix())).detect();
     binarybitmap = decoder.decode(map.getBits());
     map = map.getPoints();
   }
   map =
       new Result(
           binarybitmap.getText(), binarybitmap.getRawBytes(), map, BarcodeFormat.DATA_MATRIX);
   list = binarybitmap.getByteSegments();
   if (list != null) {
     map.putMetadata(ResultMetadataType.BYTE_SEGMENTS, list);
   }
   binarybitmap = binarybitmap.getECLevel();
   if (binarybitmap != null) {
     map.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, binarybitmap);
   }
   return map;
 }