BitMatrix.java (zxing-zxing-3.4.0) | : | BitMatrix.java (zxing-zxing-3.4.1) | ||
---|---|---|---|---|
skipping to change at line 120 | skipping to change at line 120 | |||
if (bitsPos > rowStartPos) { | if (bitsPos > rowStartPos) { | |||
if (rowLength == -1) { | if (rowLength == -1) { | |||
rowLength = bitsPos - rowStartPos; | rowLength = bitsPos - rowStartPos; | |||
} else if (bitsPos - rowStartPos != rowLength) { | } else if (bitsPos - rowStartPos != rowLength) { | |||
throw new IllegalArgumentException("row lengths do not match"); | throw new IllegalArgumentException("row lengths do not match"); | |||
} | } | |||
rowStartPos = bitsPos; | rowStartPos = bitsPos; | |||
nRows++; | nRows++; | |||
} | } | |||
pos++; | pos++; | |||
} else if (stringRepresentation.substring(pos, pos + setString.length()). equals(setString)) { | } else if (stringRepresentation.startsWith(setString, pos)) { | |||
pos += setString.length(); | pos += setString.length(); | |||
bits[bitsPos] = true; | bits[bitsPos] = true; | |||
bitsPos++; | bitsPos++; | |||
} else if (stringRepresentation.substring(pos, pos + unsetString.length()) .equals(unsetString)) { | } else if (stringRepresentation.startsWith(unsetString, pos)) { | |||
pos += unsetString.length(); | pos += unsetString.length(); | |||
bits[bitsPos] = false; | bits[bitsPos] = false; | |||
bitsPos++; | bitsPos++; | |||
} else { | } else { | |||
throw new IllegalArgumentException( | throw new IllegalArgumentException( | |||
"illegal character encountered: " + stringRepresentation.substring(p os)); | "illegal character encountered: " + stringRepresentation.substring(p os)); | |||
} | } | |||
} | } | |||
// no EOL at end? | // no EOL at end? | |||
skipping to change at line 199 | skipping to change at line 199 | |||
bits[offset] ^= 1 << (x & 0x1f); | bits[offset] ^= 1 << (x & 0x1f); | |||
} | } | |||
/** | /** | |||
* Exclusive-or (XOR): Flip the bit in this {@code BitMatrix} if the correspon ding | * Exclusive-or (XOR): Flip the bit in this {@code BitMatrix} if the correspon ding | |||
* mask bit is set. | * mask bit is set. | |||
* | * | |||
* @param mask XOR mask | * @param mask XOR mask | |||
*/ | */ | |||
public void xor(BitMatrix mask) { | public void xor(BitMatrix mask) { | |||
if (width != mask.getWidth() || height != mask.getHeight() | if (width != mask.width || height != mask.height || rowSize != mask.rowSize) | |||
|| rowSize != mask.getRowSize()) { | { | |||
throw new IllegalArgumentException("input matrix dimensions do not match") ; | throw new IllegalArgumentException("input matrix dimensions do not match") ; | |||
} | } | |||
BitArray rowArray = new BitArray(width); | BitArray rowArray = new BitArray(width); | |||
for (int y = 0; y < height; y++) { | for (int y = 0; y < height; y++) { | |||
int offset = y * rowSize; | int offset = y * rowSize; | |||
int[] row = mask.getRow(y, rowArray).getBitArray(); | int[] row = mask.getRow(y, rowArray).getBitArray(); | |||
for (int x = 0; x < rowSize; x++) { | for (int x = 0; x < rowSize; x++) { | |||
bits[offset + x] ^= row[x]; | bits[offset + x] ^= row[x]; | |||
} | } | |||
} | } | |||
skipping to change at line 284 | skipping to change at line 283 | |||
* @param row {@link BitArray} to copy from | * @param row {@link BitArray} to copy from | |||
*/ | */ | |||
public void setRow(int y, BitArray row) { | public void setRow(int y, BitArray row) { | |||
System.arraycopy(row.getBitArray(), 0, bits, y * rowSize, rowSize); | System.arraycopy(row.getBitArray(), 0, bits, y * rowSize, rowSize); | |||
} | } | |||
/** | /** | |||
* Modifies this {@code BitMatrix} to represent the same but rotated 180 degre es | * Modifies this {@code BitMatrix} to represent the same but rotated 180 degre es | |||
*/ | */ | |||
public void rotate180() { | public void rotate180() { | |||
int width = getWidth(); | ||||
int height = getHeight(); | ||||
BitArray topRow = new BitArray(width); | BitArray topRow = new BitArray(width); | |||
BitArray bottomRow = new BitArray(width); | BitArray bottomRow = new BitArray(width); | |||
for (int i = 0; i < (height + 1) / 2; i++) { | int maxHeight = (height + 1) / 2; | |||
for (int i = 0; i < maxHeight; i++) { | ||||
topRow = getRow(i, topRow); | topRow = getRow(i, topRow); | |||
bottomRow = getRow(height - 1 - i, bottomRow); | int bottomRowIndex = height - 1 - i; | |||
bottomRow = getRow(bottomRowIndex, bottomRow); | ||||
topRow.reverse(); | topRow.reverse(); | |||
bottomRow.reverse(); | bottomRow.reverse(); | |||
setRow(i, bottomRow); | setRow(i, bottomRow); | |||
setRow(height - 1 - i, topRow); | setRow(bottomRowIndex, topRow); | |||
} | } | |||
} | } | |||
/** | /** | |||
* This is useful in detecting the enclosing rectangle of a 'pure' barcode. | * This is useful in detecting the enclosing rectangle of a 'pure' barcode. | |||
* | * | |||
* @return {@code left,top,width,height} enclosing rectangle of all 1 bits, or null if it is all white | * @return {@code left,top,width,height} enclosing rectangle of all 1 bits, or null if it is all white | |||
*/ | */ | |||
public int[] getEnclosingRectangle() { | public int[] getEnclosingRectangle() { | |||
int left = width; | int left = width; | |||
End of changes. 7 change blocks. | ||||
9 lines changed or deleted | 9 lines changed or added |