コード例 #1
0
        public Result decode(BinaryBitmap image, System.Collections.Hashtable hints)
        {
            DecoderResult decoderResult;

            ResultPoint[] points;
            if (hints != null && hints.ContainsKey(DecodeHintType.PURE_BARCODE))
            {
                BitMatrix bits = extractPureBits(image);
                if (bits.IsBlank())
                {
                    return(null);
                }

                decoderResult = decoder.decode(bits);
                points        = NO_POINTS;
            }
            else
            {
                DetectorResult detectorResult = new Detector(image).detect();
                if (detectorResult.IsBlank())
                {
                    return(null);
                }

                decoderResult = decoder.decode(detectorResult.Bits);
                if (decoderResult.IsBlank())
                {
                    return(null);
                }

                points = detectorResult.Points;
            }
            return(new Result(decoderResult.Text, decoderResult.RawBytes, points, BarcodeFormat.PDF417));
        }
コード例 #2
0
        public virtual Result decode(BinaryBitmap image, System.Collections.Hashtable hints)
        {
            DecoderResult decoderResult;

            ResultPoint[] points;
            if (hints != null && hints.ContainsKey(DecodeHintType.PURE_BARCODE))
            {
                BitMatrix bits = extractPureBits(image.BlackMatrix);
                if (bits.IsBlank())
                {
                    return(null);
                }

                decoderResult = decoder.decode(bits);
                points        = NO_POINTS;
            }
            else
            {
                var            detector       = new Detector(image.BlackMatrix);
                DetectorResult detectorResult = detector.detect(hints);
                if (detectorResult.IsBlank())
                {
                    return(null);
                }

                decoderResult = decoder.decode(detectorResult.Bits);
                if (decoderResult == null)
                {
                    return(null);
                }

                points = detectorResult.Points;
            }

            Result result = new Result(decoderResult.Text, decoderResult.RawBytes, points, BarcodeFormat.QR_CODE);

            if (decoderResult.ByteSegments != null)
            {
                result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, decoderResult.ByteSegments);
            }
            if (decoderResult.ECLevel != null)
            {
                result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult.ECLevel.ToString());
            }
            return(result);
        }