Should fix problems decoding tiny QR codes without any alignment pattern
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 20 Nov 2007 18:51:40 +0000 (18:51 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 20 Nov 2007 18:51:40 +0000 (18:51 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@63 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/src/com/google/zxing/qrcode/detector/DefaultGridSampler.java

index 501cb60..89ddbc6 100644 (file)
@@ -31,25 +31,27 @@ public final class DefaultGridSampler extends GridSampler {
                                  FinderPattern bottomLeft,
                                  AlignmentPattern alignmentPattern,
                                  int dimension) throws ReaderException {
-    float bottomRightX;
-    float bottomRightY;
+    float dimMinusThree = (float) dimension - 3.5f;
+    float bottomRightX, bottomRightY;
+    float sourceBottomRightX, sourceBottomRightY;
     if (alignmentPattern != null) {
       bottomRightX = alignmentPattern.getX();
       bottomRightY = alignmentPattern.getY();
+      sourceBottomRightX = sourceBottomRightY = dimMinusThree - 3.0f;
     } else {
       // Don't have an alignment pattern, just make up the bottom-right point
       bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX();
       bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY();
+      sourceBottomRightX = sourceBottomRightY = dimMinusThree;
     }
 
-    float dimMinusThree = (float) dimension - 3.5f;
     PerspectiveTransform transform = PerspectiveTransform.quadrilateralToQuadrilateral(
         3.5f,
         3.5f,
         dimMinusThree,
         3.5f,
-        dimMinusThree - 3.0f,
-        dimMinusThree - 3.0f,
+        sourceBottomRightX,
+        sourceBottomRightY,
         3.5f,
         dimMinusThree,
         topLeft.getX(),