Closes issue #162 : PURE_BARCODE fails on certain dense QR codes

This commit is contained in:
Sean Owen 2014-05-31 21:04:54 +01:00
parent 1fa62635de
commit 84643199a9

View file

@ -159,7 +159,9 @@ public class QRCodeReader implements Reader {
left += nudge;
// But careful that this does not sample off the edge
int nudgedTooFarRight = left + (int) ((matrixWidth - 1) * moduleSize) - (right - 1);
// "right" is the farthest-right valid pixel location -- right+1 is not necessarily
// This is positive by how much the inner x loop below would be too large
int nudgedTooFarRight = left + (int) ((matrixWidth - 1) * moduleSize) - right;
if (nudgedTooFarRight > 0) {
if (nudgedTooFarRight > nudge) {
// Neither way fits; abort
@ -167,7 +169,8 @@ public class QRCodeReader implements Reader {
}
left -= nudgedTooFarRight;
}
int nudgedTooFarDown = top + (int) ((matrixHeight - 1) * moduleSize) - (bottom - 1);
// See logic above
int nudgedTooFarDown = top + (int) ((matrixHeight - 1) * moduleSize) - bottom;
if (nudgedTooFarDown > 0) {
if (nudgedTooFarDown > nudge) {
// Neither way fits; abort