/** * Identify where the end of the middle / payload section ends. * * @param row row of black/white values to search * @return Array, containing index of start of 'end block' and end of 'end * block' */ private int[] decodeEnd(BitArray row) throws NotFoundException { // For convenience, reverse the row and then // search from 'the start' for the end block row.reverse(); try { int endStart = skipWhiteSpace(row); int[] endPattern = findGuardPattern(row, endStart, END_PATTERN_REVERSED); // The start & end patterns must be pre/post fixed by a quiet zone. This // zone must be at least 10 times the width of a narrow line. // ref: http://www.barcode-1.net/i25code.html validateQuietZone(row, endPattern[0]); // Now recalculate the indices of where the 'endblock' starts & stops to // accommodate // the reversed nature of the search int temp = endPattern[0]; endPattern[0] = row.getSize() - endPattern[1]; endPattern[1] = row.getSize() - temp; return endPattern; } finally { // Put the row back the right way. row.reverse(); } }
/** * Identify where the end of the middle / payload section ends. * * @param row row of black/white values to search * @return Array, containing index of start of 'end block' and end of 'end * block' */ private int[] decodeEnd(BitArray row) throws NotFoundException { // For convenience, reverse the row and then // search from 'the start' for the end block row.reverse(); try { int endStart = skipWhiteSpace(row); int[] endPattern = findGuardPattern(row, endStart, END_PATTERN_REVERSED); // The start & end patterns must be pre/post fixed by a quiet zone. This // zone must be at least 10 times the width of a narrow line. // ref: http://www.barcode-1.net/i25code.html validateQuietZone(row, endPattern[0]); // Now recalculate the indices of where the 'endblock' starts & stops to // accommodate // the reversed nature of the search int temp = endPattern[0]; endPattern[0] = row.getSize() - endPattern[1]; endPattern[1] = row.getSize() - temp; return endPattern; } finally { // Put the row back the right way. row.reverse(); } }
public Result decodeRow(int rowNumber, BitArray row, Hashtable hints) throws NotFoundException { Pair leftPair = decodePair(row, false, rowNumber, hints); addOrTally(possibleLeftPairs, leftPair); row.reverse(); Pair rightPair = decodePair(row, true, rowNumber, hints); addOrTally(possibleRightPairs, rightPair); row.reverse(); int numLeftPairs = possibleLeftPairs.size(); int numRightPairs = possibleRightPairs.size(); for (int l = 0; l < numLeftPairs; l++) { Pair left = (Pair) possibleLeftPairs.elementAt(l); if (left.getCount() > 1) { for (int r = 0; r < numRightPairs; r++) { Pair right = (Pair) possibleRightPairs.elementAt(r); if (right.getCount() > 1) { if (checkChecksum(left, right)) { return constructResult(left, right); } } } } } throw NotFoundException.getNotFoundInstance(); }
/** * Modifies this {@code BitMatrix} to represent the same but rotated 180 degrees */ public void rotate180() { int width = getWidth(); int height = getHeight(); BitArray topRow = new BitArray(width); BitArray bottomRow = new BitArray(width); for (int i = 0; i < (height + 1) / 2; i++) { topRow = getRow(i, topRow); bottomRow = getRow(height - 1 - i, bottomRow); topRow.reverse(); bottomRow.reverse(); setRow(i, bottomRow); setRow(height - 1 - i, topRow); } }
/** * Modifies this {@code BitMatrix} to represent the same but rotated 180 degrees */ public void rotate180() { int width = getWidth(); int height = getHeight(); BitArray topRow = new BitArray(width); BitArray bottomRow = new BitArray(width); for (int i = 0; i < (height + 1) / 2; i++) { topRow = getRow(i, topRow); bottomRow = getRow(height - 1 - i, bottomRow); topRow.reverse(); bottomRow.reverse(); setRow(i, bottomRow); setRow(height - 1 - i, topRow); } }
@Override public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints) throws NotFoundException { Pair leftPair = decodePair(row, false, rowNumber, hints); addOrTally(possibleLeftPairs, leftPair); row.reverse(); Pair rightPair = decodePair(row, true, rowNumber, hints); addOrTally(possibleRightPairs, rightPair); row.reverse(); for (Pair left : possibleLeftPairs) { if (left.getCount() > 1) { for (Pair right : possibleRightPairs) { if (right.getCount() > 1 && checkChecksum(left, right)) { return constructResult(left, right); } } } } throw NotFoundException.getNotFoundInstance(); }
@Override public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints) throws NotFoundException { Pair leftPair = decodePair(row, false, rowNumber, hints); addOrTally(possibleLeftPairs, leftPair); row.reverse(); Pair rightPair = decodePair(row, true, rowNumber, hints); addOrTally(possibleRightPairs, rightPair); row.reverse(); for (Pair left : possibleLeftPairs) { if (left.getCount() > 1) { for (Pair right : possibleRightPairs) { if (right.getCount() > 1 && checkChecksum(left, right)) { return constructResult(left, right); } } } } throw NotFoundException.getNotFoundInstance(); }
row.reverse(); // reverse the row and continue
row.reverse(); // reverse the row and continue
row.reverse(); // reverse the row and continue