2 * Copyright 2008 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 ReaderException = com.google.zxing.ReaderException;
\r
19 using BitArray = com.google.zxing.common.BitArray;
\r
20 namespace com.google.zxing.oned
\r
23 /// <summary> <p>Implements decoding of the EAN-8 format.</p>
\r
26 /// <author> Sean Owen
\r
28 /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source
\r
30 public sealed class EAN8Reader:UPCEANReader
\r
32 override internal BarcodeFormat BarcodeFormat
\r
36 return BarcodeFormat.EAN_8;
\r
41 //UPGRADE_NOTE: Final was removed from the declaration of 'decodeMiddleCounters '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
42 private int[] decodeMiddleCounters;
\r
46 decodeMiddleCounters = new int[4];
\r
49 protected internal override int decodeMiddle(BitArray row, int[] startRange, System.Text.StringBuilder result)
\r
51 int[] counters = decodeMiddleCounters;
\r
57 int rowOffset = startRange[1];
\r
59 for (int x = 0; x < 4 && rowOffset < end; x++)
\r
61 int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS);
\r
62 result.Append((char) ('0' + bestMatch));
\r
63 for (int i = 0; i < counters.Length; i++)
\r
65 rowOffset += counters[i];
\r
69 int[] middleRange = findGuardPattern(row, rowOffset, true, MIDDLE_PATTERN);
\r
70 rowOffset = middleRange[1];
\r
72 for (int x = 0; x < 4 && rowOffset < end; x++)
\r
74 int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS);
\r
75 result.Append((char) ('0' + bestMatch));
\r
76 for (int i = 0; i < counters.Length; i++)
\r
78 rowOffset += counters[i];
\r