mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Don't calculate 1st digit unless checkBothParities is true
git-svn-id: https://zxing.googlecode.com/svn/trunk@102 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
776c3db869
commit
852669ced6
|
@ -251,18 +251,24 @@ final class UPCDecoder {
|
|||
}
|
||||
result.append(foundChar.character);
|
||||
}
|
||||
char firstDigit = '-';
|
||||
for (int i = 0; i < FIRST_DIGIT_ENCODINGS.length; i++) {
|
||||
if (firstDigitPattern == FIRST_DIGIT_ENCODINGS[i]) {
|
||||
firstDigit = (char)((int)'0' + i);
|
||||
break;
|
||||
// If checkBothParities is true then we're potentially looking at the left
|
||||
// hand side of an EAN-13 barcode, where the first digit is encoded by the
|
||||
// parity pattern. In that case, calculate the first digit by checking
|
||||
// the parity patterns.
|
||||
if (checkBothParities) {
|
||||
char firstDigit = '-';
|
||||
for (int i = 0; i < FIRST_DIGIT_ENCODINGS.length; i++) {
|
||||
if (firstDigitPattern == FIRST_DIGIT_ENCODINGS[i]) {
|
||||
firstDigit = (char)((int)'0' + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (firstDigit == '-') {
|
||||
return -1;
|
||||
}
|
||||
if (firstDigit != '0') {
|
||||
result.insert(0, firstDigit);
|
||||
}
|
||||
}
|
||||
if (firstDigit == '-') {
|
||||
return -1;
|
||||
}
|
||||
if (firstDigit != '0') {
|
||||
result.insert(0, firstDigit);
|
||||
}
|
||||
return rowOffset;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue