2 * Copyright 2009 ZXing authors
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 using BarcodeFormat = com.google.zxing.BarcodeFormat;
\r
18 using BinaryBitmap = com.google.zxing.BinaryBitmap;
\r
19 using ReaderException = com.google.zxing.ReaderException;
\r
20 using Result = com.google.zxing.Result;
\r
21 using ResultMetadataType = com.google.zxing.ResultMetadataType;
\r
22 using ResultPoint = com.google.zxing.ResultPoint;
\r
23 using DecoderResult = com.google.zxing.common.DecoderResult;
\r
24 using DetectorResult = com.google.zxing.common.DetectorResult;
\r
25 using MultipleBarcodeReader = com.google.zxing.multi.MultipleBarcodeReader;
\r
26 using MultiDetector = com.google.zxing.multi.qrcode.detector.MultiDetector;
\r
27 using QRCodeReader = com.google.zxing.qrcode.QRCodeReader;
\r
28 namespace com.google.zxing.multi.qrcode
\r
31 /// <summary> This implementation can detect and decode multiple QR Codes in an image.
\r
34 /// <author> Sean Owen
\r
36 /// <author> Hannes Erven
\r
38 /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source
\r
41 public sealed class QRCodeMultiReader:QRCodeReader, MultipleBarcodeReader
\r
44 //UPGRADE_NOTE: Final was removed from the declaration of 'EMPTY_RESULT_ARRAY '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
45 private static readonly Result[] EMPTY_RESULT_ARRAY = new Result[0];
\r
47 public Result[] decodeMultiple(BinaryBitmap image)
\r
49 return decodeMultiple(image, null);
\r
52 public Result[] decodeMultiple(BinaryBitmap image, System.Collections.Hashtable hints)
\r
54 System.Collections.ArrayList results = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
\r
55 DetectorResult[] detectorResult = new MultiDetector(image.BlackMatrix).detectMulti(hints);
\r
56 for (int i = 0; i < detectorResult.Length; i++)
\r
60 DecoderResult decoderResult = Decoder.decode(detectorResult[i].Bits);
\r
61 ResultPoint[] points = detectorResult[i].Points;
\r
62 Result result = new Result(decoderResult.Text, decoderResult.RawBytes, points, BarcodeFormat.QR_CODE);
\r
63 if (decoderResult.ByteSegments != null)
\r
65 result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, decoderResult.ByteSegments);
\r
67 if (decoderResult.ECLevel != null)
\r
69 result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult.ECLevel.ToString());
\r
71 results.Add(result);
\r
73 catch (ReaderException re)
\r
75 // ignore and continue
\r
78 if ((results.Count == 0))
\r
80 return EMPTY_RESULT_ARRAY;
\r
84 Result[] resultArray = new Result[results.Count];
\r
85 for (int i = 0; i < results.Count; i++)
\r
87 resultArray[i] = (Result) results[i];
\r