X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=core%2Fsrc%2Fcom%2Fgoogle%2Fzxing%2Fqrcode%2FQRCodeReader.java;h=2a12c6dd3e14c61f1dc6ca94476e173b3292a209;hb=d0920ceb07da310eb8e10f6a11d5590bcb3184ea;hp=575af1f4018f4d4883ec83be1f4c8b94c0c0de6d;hpb=48a784144880eab9f726f030bdce41cca1ff8870;p=zxing.git diff --git a/core/src/com/google/zxing/qrcode/QRCodeReader.java b/core/src/com/google/zxing/qrcode/QRCodeReader.java index 575af1f4..2a12c6dd 100644 --- a/core/src/com/google/zxing/qrcode/QRCodeReader.java +++ b/core/src/com/google/zxing/qrcode/QRCodeReader.java @@ -118,6 +118,9 @@ public class QRCodeReader implements Reader { } int moduleSize = x - leftTopBlack[0]; + if (moduleSize == 0) { + throw NotFoundException.getNotFoundInstance(); + } // And now find where the rightmost black module on the first row ends int rowEndOfSymbol = width - 1; @@ -137,9 +140,10 @@ public class QRCodeReader implements Reader { // Push in the "border" by half the module width so that we start // sampling in the middle of the module. Just in case the image is a - // little off, this will help recover. - x -= moduleSize >> 1; - y -= moduleSize >> 1; + // little off, this will help recover. Need to back up at least 1. + int backOffAmount = moduleSize == 1 ? 1 : moduleSize >> 1; + x -= backOffAmount; + y -= backOffAmount; if ((x + (dimension - 1) * moduleSize) >= width || (y + (dimension - 1) * moduleSize) >= height) { @@ -159,4 +163,4 @@ public class QRCodeReader implements Reader { return bits; } -} \ No newline at end of file +}