From 45b9c32fba5e55eda07b148b152e9b862d117511 Mon Sep 17 00:00:00 2001 From: srowen Date: Wed, 6 Jan 2010 14:02:16 +0000 Subject: [PATCH 1/1] Better version of revision 1166 and 1165 -- corrects behavior, by changing code such that points are always within image. Happens to make one test image fail at one rotation, but think that was a 'false gain' so accepted that tiny step backwards. git-svn-id: http://zxing.googlecode.com/svn/trunk@1178 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- .../zxing/datamatrix/detector/Detector.java | 4 ++-- .../google/zxing/qrcode/detector/Detector.java | 18 ++++++++---------- .../zxing/qrcode/QRCodeBlackBox3TestCase.java | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/core/src/com/google/zxing/datamatrix/detector/Detector.java b/core/src/com/google/zxing/datamatrix/detector/Detector.java index aa81d8cb..823c6242 100644 --- a/core/src/com/google/zxing/datamatrix/detector/Detector.java +++ b/core/src/com/google/zxing/datamatrix/detector/Detector.java @@ -235,11 +235,11 @@ public final class Detector { } error += dy; if (error > 0) { - y += ystep; - error -= dx; if (y == toY) { break; } + y += ystep; + error -= dx; } } return new ResultPointsAndTransitions(from, to, transitions); diff --git a/core/src/com/google/zxing/qrcode/detector/Detector.java b/core/src/com/google/zxing/qrcode/detector/Detector.java index 9807177f..6821dfcd 100644 --- a/core/src/com/google/zxing/qrcode/detector/Detector.java +++ b/core/src/com/google/zxing/qrcode/detector/Detector.java @@ -260,17 +260,15 @@ public class Detector { // Now count other way -- don't run off image though of course int otherToX = fromX - (toX - fromX); if (otherToX < 0) { - // "to" should the be the first value not included, so, the first value off - // the edge is -1 - otherToX = -1; - } else if (otherToX > image.getWidth()) { - otherToX = image.getWidth(); + otherToX = 0; + } else if (otherToX >= image.getWidth()) { + otherToX = image.getWidth() - 1; } int otherToY = fromY - (toY - fromY); if (otherToY < 0) { - otherToY = -1; - } else if (otherToY > image.getHeight()) { - otherToY = image.getHeight(); + otherToY = 0; + } else if (otherToY >= image.getHeight()) { + otherToY = image.getHeight() - 1; } result += sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY); return result - 1.0f; // -1 because we counted the middle pixel twice @@ -324,11 +322,11 @@ public class Detector { } error += dy; if (error > 0) { - y += ystep; - error -= dx; if (y == toY) { break; } + y += ystep; + error -= dx; } } int diffX = toX - fromX; diff --git a/core/test/src/com/google/zxing/qrcode/QRCodeBlackBox3TestCase.java b/core/test/src/com/google/zxing/qrcode/QRCodeBlackBox3TestCase.java index 8b152960..60805855 100644 --- a/core/test/src/com/google/zxing/qrcode/QRCodeBlackBox3TestCase.java +++ b/core/test/src/com/google/zxing/qrcode/QRCodeBlackBox3TestCase.java @@ -30,7 +30,7 @@ public final class QRCodeBlackBox3TestCase extends AbstractBlackBoxTestCase { addTest(36, 36, 0.0f); addTest(37, 37, 90.0f); addTest(35, 35, 180.0f); - addTest(37, 37, 270.0f); + addTest(36, 36, 270.0f); } } -- 2.20.1