Issue 894 fix unsigned byte issue in unrandomize 255 state that prevented some codes from working in base 256 mode

git-svn-id: https://zxing.googlecode.com/svn/trunk@2016 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2011-11-04 17:16:25 +00:00
parent 957e179e63
commit 52befe2c8f

View file

@ -473,7 +473,7 @@ final class DecodedBitStreamParser {
if (bits.available() < 8) { if (bits.available() < 8) {
throw FormatException.getFormatInstance(); throw FormatException.getFormatInstance();
} }
bytes[i] = unrandomize255State(bits.readBits(8), codewordPosition++); bytes[i] = (byte) unrandomize255State(bits.readBits(8), codewordPosition++);
} }
byteSegments.add(bytes); byteSegments.add(bytes);
try { try {
@ -486,11 +486,11 @@ final class DecodedBitStreamParser {
/** /**
* See ISO 16022:2006, Annex B, B.2 * See ISO 16022:2006, Annex B, B.2
*/ */
private static byte unrandomize255State(int randomizedBase256Codeword, private static int unrandomize255State(int randomizedBase256Codeword,
int base256CodewordPosition) { int base256CodewordPosition) {
int pseudoRandomNumber = ((149 * base256CodewordPosition) % 255) + 1; int pseudoRandomNumber = ((149 * base256CodewordPosition) % 255) + 1;
int tempVariable = randomizedBase256Codeword - pseudoRandomNumber; int tempVariable = randomizedBase256Codeword - pseudoRandomNumber;
return (byte) (tempVariable >= 0 ? tempVariable : tempVariable + 256); return tempVariable >= 0 ? tempVariable : tempVariable + 256;
} }
} }