protected int decodeMiddle(BitArray row, int[] startRange, StringBuffer result) throws NotFoundException { int[] counters = decodeMiddleCounters; counters[0] = 0; counters[1] = 0; counters[2] = 0; counters[3] = 0; int end = row.getSize(); int rowOffset = startRange[1]; for (int x = 0; x < 4 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); result.append((char) ('0' + bestMatch)); for (int i = 0; i < counters.length; i++) { rowOffset += counters[i]; } } int[] middleRange = findGuardPattern(row, rowOffset, true, MIDDLE_PATTERN); rowOffset = middleRange[1]; for (int x = 0; x < 4 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); result.append((char) ('0' + bestMatch)); for (int i = 0; i < counters.length; i++) { rowOffset += counters[i]; } } return rowOffset; }
public MultiFormatUPCEANReader(Map<DecodeHintType,?> hints) { @SuppressWarnings("unchecked") Collection<BarcodeFormat> possibleFormats = hints == null ? null : (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS); Collection<UPCEANReader> readers = new ArrayList<>(); if (possibleFormats != null) { if (possibleFormats.contains(BarcodeFormat.EAN_13)) { readers.add(new EAN13Reader()); } else if (possibleFormats.contains(BarcodeFormat.UPC_A)) { readers.add(new UPCAReader()); } if (possibleFormats.contains(BarcodeFormat.EAN_8)) { readers.add(new EAN8Reader()); } if (possibleFormats.contains(BarcodeFormat.UPC_E)) { readers.add(new UPCEReader()); } } if (readers.isEmpty()) { readers.add(new EAN13Reader()); // UPC-A is covered by EAN-13 readers.add(new EAN8Reader()); readers.add(new UPCEReader()); } this.readers = readers.toArray(new UPCEANReader[readers.size()]); }
public MultiFormatUPCEANReader(Map<DecodeHintType,?> hints) { @SuppressWarnings("unchecked") Collection<BarcodeFormat> possibleFormats = hints == null ? null : (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS); Collection<UPCEANReader> readers = new ArrayList<>(); if (possibleFormats != null) { if (possibleFormats.contains(BarcodeFormat.EAN_13)) { readers.add(new EAN13Reader()); } else if (possibleFormats.contains(BarcodeFormat.UPC_A)) { readers.add(new UPCAReader()); } if (possibleFormats.contains(BarcodeFormat.EAN_8)) { readers.add(new EAN8Reader()); } if (possibleFormats.contains(BarcodeFormat.UPC_E)) { readers.add(new UPCEReader()); } } if (readers.isEmpty()) { readers.add(new EAN13Reader()); // UPC-A is covered by EAN-13 readers.add(new EAN8Reader()); readers.add(new UPCEReader()); } this.readers = readers.toArray(new UPCEANReader[readers.size()]); }
@Override protected int decodeMiddle(BitArray row, int[] startRange, StringBuilder result) throws NotFoundException { int[] counters = decodeMiddleCounters; counters[0] = 0; counters[1] = 0; counters[2] = 0; counters[3] = 0; int end = row.getSize(); int rowOffset = startRange[1]; for (int x = 0; x < 4 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); result.append((char) ('0' + bestMatch)); for (int counter : counters) { rowOffset += counter; } } int[] middleRange = findGuardPattern(row, rowOffset, true, MIDDLE_PATTERN); rowOffset = middleRange[1]; for (int x = 0; x < 4 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); result.append((char) ('0' + bestMatch)); for (int counter : counters) { rowOffset += counter; } } return rowOffset; }
public MultiFormatUPCEANReader(Hashtable hints) { Vector possibleFormats = hints == null ? null : (Vector) hints.get(DecodeHintType.POSSIBLE_FORMATS); readers = new Vector(); if (possibleFormats != null) { if (possibleFormats.contains(BarcodeFormat.EAN_13)) { readers.addElement(new EAN13Reader()); } else if (possibleFormats.contains(BarcodeFormat.UPC_A)) { readers.addElement(new UPCAReader()); } if (possibleFormats.contains(BarcodeFormat.EAN_8)) { readers.addElement(new EAN8Reader()); } if (possibleFormats.contains(BarcodeFormat.UPC_E)) { readers.addElement(new UPCEReader()); } } if (readers.isEmpty()) { readers.addElement(new EAN13Reader()); // UPC-A is covered by EAN-13 readers.addElement(new EAN8Reader()); readers.addElement(new UPCEReader()); } }
@Override protected int decodeMiddle(BitArray row, int[] startRange, StringBuilder result) throws NotFoundException { int[] counters = decodeMiddleCounters; counters[0] = 0; counters[1] = 0; counters[2] = 0; counters[3] = 0; int end = row.getSize(); int rowOffset = startRange[1]; for (int x = 0; x < 4 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); result.append((char) ('0' + bestMatch)); for (int counter : counters) { rowOffset += counter; } } int[] middleRange = findGuardPattern(row, rowOffset, true, MIDDLE_PATTERN); rowOffset = middleRange[1]; for (int x = 0; x < 4 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); result.append((char) ('0' + bestMatch)); for (int counter : counters) { rowOffset += counter; } } return rowOffset; }