2 * Licensed under the Apache License, Version 2.0 (the "License");
\r
3 * you may not use this file except in compliance with the License.
\r
4 * You may obtain a copy of the License at
\r
6 * http://www.apache.org/licenses/LICENSE-2.0
\r
8 * Unless required by applicable law or agreed to in writing, software
\r
9 * distributed under the License is distributed on an "AS IS" BASIS,
\r
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
11 * See the License for the specific language governing permissions and
\r
12 * limitations under the License.
\r
14 namespace com.google.zxing.oned
\r
18 using com.google.zxing.common;
\r
20 public sealed class EAN8Reader : AbstractUPCEANReader
\r
22 private int[] decodeMiddleCounters;
\r
23 public EAN8Reader() {
\r
24 decodeMiddleCounters = new int[4];
\r
27 protected override int decodeMiddle(BitArray row, int[] startRange, StringBuilder result) {
\r
28 int[] counters = decodeMiddleCounters;
\r
33 int end = row.getSize();
\r
34 int rowOffset = startRange[1];
\r
36 for (int x = 0; x < 4 && rowOffset < end; x++) {
\r
37 int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS);
\r
38 result.Append((char) ('0' + bestMatch));
\r
39 for (int i = 0; i < counters.Length; i++) {
\r
40 rowOffset += counters[i];
\r
44 int[] middleRange = findGuardPattern(row, rowOffset, true, MIDDLE_PATTERN);
\r
45 rowOffset = middleRange[1];
\r
47 for (int x = 0; x < 4 && rowOffset < end; x++) {
\r
48 int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS);
\r
49 result.Append((char) ('0' + bestMatch));
\r
50 for (int i = 0; i < counters.Length; i++) {
\r
51 rowOffset += counters[i];
\r
58 public override BarcodeFormat getBarcodeFormat() {
\r
59 return BarcodeFormat.EAN_8;
\r