public Result[] decodeMultiple2(BinaryBitmap image, Dictionary<object, object> hints)
 {
     ArrayList results = new ArrayList();
     DetectorResult[] detectorResult = new MultiDetector(image.BlackMatrix).detectMulti(hints);
     for (int i = 0; i < detectorResult.Length; i++)
     {
         try
         {
             DecoderResult decoderResult = Decoder.decode2(detectorResult[i].Bits);
             ResultPoint[] points = detectorResult[i].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());
             }
             results.Add(result);
         }
         catch (Exception e)
         {
             if (e.Message.IndexOf("ReaderException") < 0)
                 throw e;
             // ignore and continue
         }
     }
     if ((results.Count == 0))
     {
         return EMPTY_RESULT_ARRAY;
     }
     else
     {
         Result[] resultArray = new Result[results.Count];
         for (int i = 0; i < results.Count; i++)
         {
             resultArray[i] = (Result) results[i];
         }
         return resultArray;
     }
 }
示例#2
0
        public Result[] decodeMultiple(BinaryBitmap image, Dictionary <object, object> hints)
        {
            List <object> results = new List <object>();

            DetectorResult[] detectorResult = new MultiDetector(image.BlackMatrix).detectMulti(hints);
            for (int i = 0; i < detectorResult.Length; i++)
            {
                try
                {
                    DecoderResult decoderResult = Decoder.decode(detectorResult[i].Bits);
                    ResultPoint[] points        = detectorResult[i].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());
                    }
                    results.Add(result);
                }
                catch (ReaderException)
                {
                    // ignore and continue
                }
            }
            if ((results.Count == 0))
            {
                return(EMPTY_RESULT_ARRAY);
            }
            else
            {
                Result[] resultArray = new Result[results.Count];
                for (int i = 0; i < results.Count; i++)
                {
                    resultArray[i] = (Result)results[i];
                }
                return(resultArray);
            }
        }
 // added by .net follower (http://dotnetfollower.com)
 // public Result[] decodeMultiple(BinaryBitmap image, System.Collections.Hashtable hints) // commented by .net follower (http://dotnetfollower.com)
 public Result[] decodeMultiple(BinaryBitmap image, System.Collections.Generic.Dictionary<Object, Object> hints)
 {
     // System.Collections.ArrayList results = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); // commented by .net follower (http://dotnetfollower.com)
     System.Collections.Generic.List<Object> results = new System.Collections.Generic.List<Object>(10); // added by .net follower (http://dotnetfollower.com)
     DetectorResult[] detectorResult = new MultiDetector(image.BlackMatrix).detectMulti(hints);
     for (int i = 0; i < detectorResult.Length; i++)
     {
         try
         {
             DecoderResult decoderResult = Decoder.decode(detectorResult[i].Bits);
             ResultPoint[] points = detectorResult[i].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());
             }
             results.Add(result);
         }
         catch (ReaderException re)
         {
             // ignore and continue
         }
     }
     if ((results.Count == 0))
     {
         return EMPTY_RESULT_ARRAY;
     }
     else
     {
         Result[] resultArray = new Result[results.Count];
         for (int i = 0; i < results.Count; i++)
         {
             resultArray[i] = (Result) results[i];
         }
         return resultArray;
     }
 }
 // public Result[] decodeMultiple(BinaryBitmap image, System.Collections.Hashtable hints) // commented by .net follower (http://dotnetfollower.com)
 public Result[] decodeMultiple(BinaryBitmap image, System.Collections.Generic.Dictionary <Object, Object> hints) // added by .net follower (http://dotnetfollower.com)
 {
     // System.Collections.ArrayList results = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); // commented by .net follower (http://dotnetfollower.com)
     System.Collections.Generic.List <Object> results = new System.Collections.Generic.List <Object>(10); // added by .net follower (http://dotnetfollower.com)
     DetectorResult[] detectorResult = new MultiDetector(image.BlackMatrix).detectMulti(hints);
     for (int i = 0; i < detectorResult.Length; i++)
     {
         try
         {
             DecoderResult decoderResult = Decoder.decode(detectorResult[i].Bits);
             ResultPoint[] points        = detectorResult[i].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());
             }
             results.Add(result);
         }
         catch (ReaderException re)
         {
             // ignore and continue
         }
     }
     if ((results.Count == 0))
     {
         return(EMPTY_RESULT_ARRAY);
     }
     else
     {
         Result[] resultArray = new Result[results.Count];
         for (int i = 0; i < results.Count; i++)
         {
             resultArray[i] = (Result)results[i];
         }
         return(resultArray);
     }
 }