Issue 524
authorsmparkes@smparkes.net <smparkes@smparkes.net@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 31 Aug 2010 03:18:56 +0000 (03:18 +0000)
committersmparkes@smparkes.net <smparkes@smparkes.net@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 31 Aug 2010 03:18:56 +0000 (03:18 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@1570 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/src/com/google/zxing/qrcode/detector/Detector.java
cpp/core/src/zxing/qrcode/detector/Detector.cpp

index c67b768..e6b860b 100644 (file)
@@ -374,6 +374,9 @@ public class Detector {
 
     int alignmentAreaTopY = Math.max(0, estAlignmentY - allowance);
     int alignmentAreaBottomY = Math.min(image.getHeight() - 1, estAlignmentY + allowance);
 
     int alignmentAreaTopY = Math.max(0, estAlignmentY - allowance);
     int alignmentAreaBottomY = Math.min(image.getHeight() - 1, estAlignmentY + allowance);
+    if (alignmentAreaBottomY - alignmentAreaTopY < overallEstModuleSize * 3) {
+      throw NotFoundException.getNotFoundInstance();
+    }
 
     AlignmentPatternFinder alignmentFinder =
         new AlignmentPatternFinder(
 
     AlignmentPatternFinder alignmentFinder =
         new AlignmentPatternFinder(
index 4e40b72..fdab429 100644 (file)
@@ -273,6 +273,9 @@ Ref<AlignmentPattern> Detector::findAlignmentInRegion(float overallEstModuleSize
   }\r
   int alignmentAreaTopY = max(0, estAlignmentY - allowance);\r
   int alignmentAreaBottomY = min((int)(image_->getHeight() - 1), estAlignmentY + allowance);\r
   }\r
   int alignmentAreaTopY = max(0, estAlignmentY - allowance);\r
   int alignmentAreaBottomY = min((int)(image_->getHeight() - 1), estAlignmentY + allowance);\r
+  if (alignmentAreaBottomY - alignmentAreaTopY < overallEstModuleSize * 3) {\r
+      throw zxing::ReaderException("region too small to hold alignment pattern");\r
+  }\r
 \r
   AlignmentPatternFinder alignmentFinder(image_, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX\r
                                          - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, callback_);\r
 \r
   AlignmentPatternFinder alignmentFinder(image_, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX\r
                                          - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, callback_);\r