Better version of revision 1166 and 1165 -- corrects behavior, by changing code such...
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Wed, 6 Jan 2010 14:02:16 +0000 (14:02 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Wed, 6 Jan 2010 14:02:16 +0000 (14:02 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@1178 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/src/com/google/zxing/datamatrix/detector/Detector.java
core/src/com/google/zxing/qrcode/detector/Detector.java
core/test/src/com/google/zxing/qrcode/QRCodeBlackBox3TestCase.java

index aa81d8c..823c624 100644 (file)
@@ -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);
index 9807177..6821dfc 100644 (file)
@@ -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;
index 8b15296..6080585 100644 (file)
@@ -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);
   }
 
 }