Enable DataMatrix in the web app / other small tweaks
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Fri, 10 Apr 2009 13:46:11 +0000 (13:46 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Fri, 10 Apr 2009 13:46:11 +0000 (13:46 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@903 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/src/com/google/zxing/common/BaseMonochromeBitmapSource.java
core/src/com/google/zxing/qrcode/decoder/FormatInformation.java
core/src/com/google/zxing/qrcode/detector/AlignmentPattern.java
core/src/com/google/zxing/qrcode/detector/FinderPattern.java
zxingorg/src/com/google/zxing/web/DecodeServlet.java

index 0e6699e..0a99cda 100644 (file)
@@ -45,8 +45,6 @@ public abstract class BaseMonochromeBitmapSource implements MonochromeBitmapSour
 
   private void initLuminances() {
     if (luminances == null) {
-      int width = getWidth();
-      int height = getHeight();
       int max = width > height ? width : height;
       luminances = new int[max];
     }
@@ -135,7 +133,7 @@ public abstract class BaseMonochromeBitmapSource implements MonochromeBitmapSour
           histogram[luminances[x] >> LUMINANCE_SHIFT]++;
         }
       } else {
-        throw new IllegalArgumentException("Unknown method: " + method);
+        throw new IllegalArgumentException("Unknown method");
       }
       blackPoint = BlackPointEstimator.estimate(histogram) << LUMINANCE_SHIFT;
       lastMethod = method;
index 2568d77..299768c 100644 (file)
@@ -16,8 +16,6 @@
 
 package com.google.zxing.qrcode.decoder;
 
-import com.google.zxing.ReaderException;
-
 /**
  * <p>Encapsulates a QR Code's format information, including the data mask used and
  * error correction level.</p>
index e99aca8..a2c1d96 100644 (file)
@@ -49,11 +49,11 @@ public final class AlignmentPattern implements ResultPoint {
    * position and size -- meaning, it is at nearly the same center with nearly the same size.</p>
    */
   boolean aboutEquals(float moduleSize, float i, float j) {
-    return
-        Math.abs(i - posY) <= moduleSize &&
-            Math.abs(j - posX) <= moduleSize &&
-            (Math.abs(moduleSize - estimatedModuleSize) <= 1.0f ||
-                Math.abs(moduleSize - estimatedModuleSize) / estimatedModuleSize <= 0.1f);
+    if (Math.abs(i - posY) <= moduleSize && Math.abs(j - posX) <= moduleSize) {
+      float moduleSizeDiff = Math.abs(moduleSize - estimatedModuleSize);
+      return moduleSizeDiff <= 1.0f || moduleSizeDiff / estimatedModuleSize <= 1.0f;
+    }
+    return false;
   }
 
 }
\ No newline at end of file
index 3df26cf..a339cae 100644 (file)
@@ -64,10 +64,11 @@ public final class FinderPattern implements ResultPoint {
    * position and size -- meaning, it is at nearly the same center with nearly the same size.</p>
    */
   boolean aboutEquals(float moduleSize, float i, float j) {
-    return Math.abs(i - posY) <= moduleSize &&
-        Math.abs(j - posX) <= moduleSize &&
-        (Math.abs(moduleSize - estimatedModuleSize) <= 1.0f ||
-            Math.abs(moduleSize - estimatedModuleSize) / estimatedModuleSize <= 0.1f);
+    if (Math.abs(i - posY) <= moduleSize && Math.abs(j - posX) <= moduleSize) {
+      float moduleSizeDiff = Math.abs(moduleSize - estimatedModuleSize);
+      return moduleSizeDiff <= 1.0f || moduleSizeDiff / estimatedModuleSize <= 1.0f;
+    }
+    return false;
   }
 
 }
index 8831f36..4fc7b6b 100644 (file)
@@ -21,6 +21,7 @@ import com.google.zxing.MultiFormatReader;
 import com.google.zxing.Reader;
 import com.google.zxing.ReaderException;
 import com.google.zxing.Result;
+import com.google.zxing.BarcodeFormat;
 import com.google.zxing.client.j2se.BufferedImageMonochromeBitmapSource;
 import com.google.zxing.client.result.ParsedResult;
 import com.google.zxing.client.result.ResultParser;
@@ -63,6 +64,7 @@ import java.net.URISyntaxException;
 import java.net.UnknownHostException;
 import java.util.Hashtable;
 import java.util.List;
+import java.util.Vector;
 import java.util.logging.Logger;
 
 /**
@@ -80,8 +82,19 @@ public final class DecodeServlet extends HttpServlet {
   static final Hashtable<DecodeHintType, Object> HINTS;
 
   static {
-    HINTS = new Hashtable<DecodeHintType, Object>(3);
+    HINTS = new Hashtable<DecodeHintType, Object>(5);
     HINTS.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
+    Vector possibleFormats = new Vector();
+    possibleFormats.add(BarcodeFormat.UPC_A);
+    possibleFormats.add(BarcodeFormat.UPC_E);
+    possibleFormats.add(BarcodeFormat.EAN_8);
+    possibleFormats.add(BarcodeFormat.EAN_13);
+    possibleFormats.add(BarcodeFormat.CODE_39);
+    possibleFormats.add(BarcodeFormat.CODE_128);
+    possibleFormats.add(BarcodeFormat.ITF);
+    possibleFormats.add(BarcodeFormat.QR_CODE);
+    possibleFormats.add(BarcodeFormat.DATAMATRIX);
+    HINTS.put(DecodeHintType.POSSIBLE_FORMATS, possibleFormats);
   }
 
   private HttpClient client;