mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Fixed decodeEnd() situation whereby row might not be re-reversed, and fixed an old NPE I caused
git-svn-id: https://zxing.googlecode.com/svn/trunk@878 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
8b339661d9
commit
e367d3ef96
|
@ -88,7 +88,11 @@ public final class ITFReader extends AbstractOneDReader {
|
|||
|
||||
String resultString = result.toString();
|
||||
|
||||
int[] allowedLengths = (int[]) hints.get(DecodeHintType.ALLOWED_LENGTHS);
|
||||
int[] allowedLengths = null;
|
||||
if (hints != null) {
|
||||
allowedLengths = (int[]) hints.get(DecodeHintType.ALLOWED_LENGTHS);
|
||||
|
||||
}
|
||||
if (allowedLengths == null) {
|
||||
allowedLengths = DEFAULT_ALLOWED_LENGTHS;
|
||||
}
|
||||
|
@ -245,32 +249,27 @@ public final class ITFReader extends AbstractOneDReader {
|
|||
// For convenience, reverse the row and then
|
||||
// search from 'the start' for the end block
|
||||
row.reverse();
|
||||
|
||||
int endStart = skipWhiteSpace(row);
|
||||
int[] endPattern;
|
||||
try {
|
||||
endPattern = findGuardPattern(row, endStart, END_PATTERN_REVERSED);
|
||||
} catch (ReaderException e) {
|
||||
// Put our row of data back the right way before throwing
|
||||
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 recalc the indicies of where the 'endblock' starts & stops to
|
||||
// accomodate
|
||||
// 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 righ way.
|
||||
row.reverse();
|
||||
throw e;
|
||||
}
|
||||
|
||||
// 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 recalc the indicies of where the 'endblock' starts & stops to
|
||||
// accomodate
|
||||
// the reversed nature of the search
|
||||
int temp = endPattern[0];
|
||||
endPattern[0] = row.getSize() - endPattern[1];
|
||||
endPattern[1] = row.getSize() - temp;
|
||||
|
||||
// Put the row back the righ way.
|
||||
row.reverse();
|
||||
return endPattern;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue