This commit is contained in:
Sean Owen 2021-08-30 13:24:58 -05:00
parent 2b48aec2c4
commit b3941e251b

View file

@ -98,13 +98,13 @@ public final class MaxiCodeReader implements Reader {
// Now just read off the bits
BitMatrix bits = new BitMatrix(MATRIX_WIDTH, MATRIX_HEIGHT);
for (int y = 0; y < MATRIX_HEIGHT; y++) {
int iy = top + (y * height + height / 2) / MATRIX_HEIGHT;
int iy = Math.min(top + (y * height + height / 2) / MATRIX_HEIGHT, height - 1);
for (int x = 0; x < MATRIX_WIDTH; x++) {
// srowen: I don't quite understand why the formula below is necessary, but it
// can walk off the image if left + width = the right boundary. So cap it.
int ix = left + Math.min(
(x * width + width / 2 + (y & 0x01) * width / 2) / MATRIX_WIDTH,
width);
width - 1);
if (image.get(ix, iy)) {
bits.set(x, y);
}