Beispiel #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)
        {
            List <Result>        results        = new List <Result>();
            PDF417DetectorResult detectorResult = Detector.Detect(image, hints, multiple);

            foreach (ResultPoint[] points in detectorResult.Points)
            {
                DecoderResult decoderResult = PDF417ScanningDecoder.Decode(detectorResult.Bits, points[4], points[5],
                                                                           points[6], points[7], GetMinCodewordWidth(points), GetMaxCodewordWidth(points));
                if (decoderResult == null)
                {
                    // See comments re: Exceptions above
                    // continue;
                    throw ReaderException.Instance;
                }
                System.Diagnostics.Debug.WriteLine("Result " + points.ToString() + " > " + decoderResult.Text + " " + decoderResult.RawBytes);
                Result result = new Result(decoderResult.Text, decoderResult.RawBytes, points, BarcodeFormat.PDF_417);
                result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult.ECLevel);
                PDF417ResultMetadata pdf417ResultMetadata = (PDF417ResultMetadata)decoderResult.Other;
                if (pdf417ResultMetadata != null)
                {
                    result.putMetadata(ResultMetadataType.PDF417_EXTRA_METADATA, pdf417ResultMetadata);
                }
                results.Add(result);
            }
            return(results.ToArray());
        }
Beispiel #2
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)
        {
            List <Result>        results        = new List <Result>();
            PDF417DetectorResult detectorResult = Detector.detect(image, hints, multiple);

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