mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Prevent MaxiCode sampler from sampling off the edge of the image.
This commit is contained in:
parent
fd364d9338
commit
6dd0776b96
|
@ -100,7 +100,11 @@ public final class MaxiCodeReader implements Reader {
|
||||||
for (int y = 0; y < MATRIX_HEIGHT; y++) {
|
for (int y = 0; y < MATRIX_HEIGHT; y++) {
|
||||||
int iy = top + (y * height + height / 2) / MATRIX_HEIGHT;
|
int iy = top + (y * height + height / 2) / MATRIX_HEIGHT;
|
||||||
for (int x = 0; x < MATRIX_WIDTH; x++) {
|
for (int x = 0; x < MATRIX_WIDTH; x++) {
|
||||||
int ix = left + (x * width + width / 2 + (y & 0x01) * width / 2) / MATRIX_WIDTH;
|
// 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);
|
||||||
if (image.get(ix, iy)) {
|
if (image.get(ix, iy)) {
|
||||||
bits.set(x, y);
|
bits.set(x, y);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue