Ejemplo n.º 1
0
        /// <summary>
        /// Decode the specified image, with the hints and optionally multiple barcodes.
        /// Based on Owen's Comments in <see cref="ZXing.ReaderException"/>, this method has been modified to continue silently
        /// if a barcode was not decoded where it was detected instead of throwing a new exception object.
        /// </summary>
        /// <param name="image">Image.</param>
        /// <param name="hints">Hints.</param>
        /// <param name="multiple">If set to <c>true</c> multiple.</param>
        private static Result[] decode(BinaryBitmap image, IDictionary <DecodeHintType, object> hints, bool multiple)
        {
            var results        = new List <Result>();
            var detectorResult = Detector.detect(image, hints, multiple);

            if (detectorResult != null)
            {
                foreach (var points in detectorResult.Points)
                {
                    var decoderResult = PDF417ScanningDecoder.decode(detectorResult.Bits, points[4], points[5],
                                                                     points[6], points[7], getMinCodewordWidth(points), getMaxCodewordWidth(points));
                    if (decoderResult == null)
                    {
                        continue;
                    }
                    var result = new Result(decoderResult.Text, decoderResult.RawBytes, points, BarcodeFormat.PDF_417);
                    result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult.ECLevel);
                    var pdf417ResultMetadata = (PDF417ResultMetadata)decoderResult.Other;
                    if (pdf417ResultMetadata != null)
                    {
                        result.putMetadata(ResultMetadataType.PDF417_EXTRA_METADATA, pdf417ResultMetadata);
                    }
                    results.Add(result);
                }
            }
            return(results.ToArray());
        }