"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "core/src/main/java/com/google/zxing/common/BitSource.java" between
zxing-zxing-3.4.0.tar.gz and zxing-zxing-3.4.1.tar.gz

About: ZXing ("zebra crossing") is a multi-format 1D/2D barcode image processing library implemented in Java, with ports to other languages.

BitSource.java  (zxing-zxing-3.4.0):BitSource.java  (zxing-zxing-3.4.1)
skipping to change at line 72 skipping to change at line 72
public int readBits(int numBits) { public int readBits(int numBits) {
if (numBits < 1 || numBits > 32 || numBits > available()) { if (numBits < 1 || numBits > 32 || numBits > available()) {
throw new IllegalArgumentException(String.valueOf(numBits)); throw new IllegalArgumentException(String.valueOf(numBits));
} }
int result = 0; int result = 0;
// First, read remainder from current byte // First, read remainder from current byte
if (bitOffset > 0) { if (bitOffset > 0) {
int bitsLeft = 8 - bitOffset; int bitsLeft = 8 - bitOffset;
int toRead = numBits < bitsLeft ? numBits : bitsLeft; int toRead = Math.min(numBits, bitsLeft);
int bitsToNotRead = bitsLeft - toRead; int bitsToNotRead = bitsLeft - toRead;
int mask = (0xFF >> (8 - toRead)) << bitsToNotRead; int mask = (0xFF >> (8 - toRead)) << bitsToNotRead;
result = (bytes[byteOffset] & mask) >> bitsToNotRead; result = (bytes[byteOffset] & mask) >> bitsToNotRead;
numBits -= toRead; numBits -= toRead;
bitOffset += toRead; bitOffset += toRead;
if (bitOffset == 8) { if (bitOffset == 8) {
bitOffset = 0; bitOffset = 0;
byteOffset++; byteOffset++;
} }
} }
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)