decode method

  1. @override
Result decode(
  1. BinaryBitmap image, [
  2. DecodeHint? hints
])
override

Locates and decodes a barcode in some format within an image. This method also accepts hints, each possibly associated to some data, which may help the implementation decode.

@param image image of barcode to decode @param hints passed as a Map from DecodeHintType to arbitrary data. The meaning of the data depends upon the hint type. The implementation may or may not do anything with these hints. @return String which the barcode encodes @throws NotFoundException if no potential barcode is found @throws ChecksumException if a potential barcode is found but does not pass its checksum @throws FormatException if a potential barcode is found but format is invalid

Implementation

@override
Result decode(BinaryBitmap image, [DecodeHint? hints]) {
  // Note that MaxiCode reader effectively always assumes PURE_BARCODE mode
  // and can't detect it in an image
  final bits = _extractPureBits(image.blackMatrix);
  final decoderResult = _decoder.decode(bits, hints);
  final result = Result(
    decoderResult.text,
    decoderResult.rawBytes,
    _noPoints,
    BarcodeFormat.maxicode,
  );
  result.putMetadata(
    ResultMetadataType.errorsCorrected,
    decoderResult.errorsCorrected ?? 0,
  );

  final ecLevel = decoderResult.ecLevel;
  if (ecLevel != null) {
    result.putMetadata(ResultMetadataType.errorCorrectionLevel, ecLevel);
  }
  return result;
}