Skip to content

Commit

Permalink
fix #400
Browse files Browse the repository at this point in the history
  • Loading branch information
syonip authored and micjahn committed Feb 2, 2022
1 parent d6ce50c commit 6db791d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/lib/maxicode/MaxiCodeReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ private static BitMatrix extractPureBits(BitMatrix image)
BitMatrix bits = new BitMatrix(MATRIX_WIDTH, MATRIX_HEIGHT);
for (int y = 0; y < MATRIX_HEIGHT; y++)
{
int iy = System.Math.Min(top + (y * height + height / 2) / MATRIX_HEIGHT, height - 1);
int iy = System.Math.Min(top + (y * height + height / 2) / MATRIX_HEIGHT, height);
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 + System.Math.Min((x * width + width / 2 + (y & 0x01) * width / 2) / MATRIX_WIDTH, width - 1);
int ix = left + System.Math.Min((x * width + width / 2 + (y & 0x01) * width / 2) / MATRIX_WIDTH, width);
if (image[ix, iy])
{
bits[x, y] = true;
Expand Down

0 comments on commit 6db791d

Please sign in to comment.