Try both binarizers, use appspot stylesheet, update dependency libs
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Sun, 31 Jan 2010 14:43:44 +0000 (14:43 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Sun, 31 Jan 2010 14:43:44 +0000 (14:43 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@1192 59b500cc-1b3d-0410-9834-0bbf25fbcc57

15 files changed:
zxingorg/build.xml
zxingorg/src/com/google/zxing/web/DecodeServlet.java
zxingorg/web/WEB-INF/lib/commons-codec-1.3.jar [deleted file]
zxingorg/web/WEB-INF/lib/commons-codec-1.4.jar [new file with mode: 0644]
zxingorg/web/WEB-INF/lib/httpclient-4.0.1.jar [new file with mode: 0644]
zxingorg/web/WEB-INF/lib/httpclient-4.0.jar [deleted file]
zxingorg/web/WEB-INF/lib/httpmime-4.0.1.jar [new file with mode: 0644]
zxingorg/web/WEB-INF/lib/httpmime-4.0.jar [deleted file]
zxingorg/web/badimage.jspx
zxingorg/web/badurl.jspx
zxingorg/web/decode.jspx
zxingorg/web/decoderesult.jspx
zxingorg/web/index.jspx
zxingorg/web/notfound.jspx
zxingorg/web/style.css [new file with mode: 0644]

index 2303bcf..0c59a7e 100644 (file)
@@ -84,6 +84,7 @@
       <fileset dir="web">
         <include name="*.jspx"/>
         <include name="*.png"/>
+        <include name="*.css"/>        
         <include name="**/*.jad"/>
         <include name="**/*.jar"/>
       </fileset>
index 2f5e198..ea213d3 100644 (file)
@@ -63,6 +63,7 @@ import java.net.SocketException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.UnknownHostException;
+import java.util.Collection;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Vector;
@@ -93,7 +94,7 @@ public final class DecodeServlet extends HttpServlet {
   static {
     HINTS = new Hashtable<DecodeHintType, Object>(5);
     HINTS.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
-    Vector<BarcodeFormat> possibleFormats = new Vector<BarcodeFormat>();
+    Collection<BarcodeFormat> possibleFormats = new Vector<BarcodeFormat>();
     possibleFormats.add(BarcodeFormat.UPC_A);
     possibleFormats.add(BarcodeFormat.UPC_E);
     possibleFormats.add(BarcodeFormat.EAN_8);
@@ -253,9 +254,16 @@ public final class DecodeServlet extends HttpServlet {
       BinaryBitmap bitmap = new BinaryBitmap(new GlobalHistogramBinarizer(source));
       result = reader.decode(bitmap, HINTS);
     } catch (ReaderException re) {
-      log.info("DECODE FAILED: " + re.toString());
-      response.sendRedirect("notfound.jspx");
-      return;
+      try {
+        // Try again with other binarizer
+        LuminanceSource source = new BufferedImageLuminanceSource(image);
+        BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
+        result = reader.decode(bitmap, HINTS);
+      } catch (ReaderException re2) {
+        log.info("DECODE FAILED: " + re.toString());
+        response.sendRedirect("notfound.jspx");
+        return;
+      }
     }
 
     if (request.getParameter("full") == null) {
diff --git a/zxingorg/web/WEB-INF/lib/commons-codec-1.3.jar b/zxingorg/web/WEB-INF/lib/commons-codec-1.3.jar
deleted file mode 100644 (file)
index 957b675..0000000
Binary files a/zxingorg/web/WEB-INF/lib/commons-codec-1.3.jar and /dev/null differ
diff --git a/zxingorg/web/WEB-INF/lib/commons-codec-1.4.jar b/zxingorg/web/WEB-INF/lib/commons-codec-1.4.jar
new file mode 100644 (file)
index 0000000..458d432
Binary files /dev/null and b/zxingorg/web/WEB-INF/lib/commons-codec-1.4.jar differ
diff --git a/zxingorg/web/WEB-INF/lib/httpclient-4.0.1.jar b/zxingorg/web/WEB-INF/lib/httpclient-4.0.1.jar
new file mode 100644 (file)
index 0000000..e9c961f
Binary files /dev/null and b/zxingorg/web/WEB-INF/lib/httpclient-4.0.1.jar differ
diff --git a/zxingorg/web/WEB-INF/lib/httpclient-4.0.jar b/zxingorg/web/WEB-INF/lib/httpclient-4.0.jar
deleted file mode 100644 (file)
index a2fe7c1..0000000
Binary files a/zxingorg/web/WEB-INF/lib/httpclient-4.0.jar and /dev/null differ
diff --git a/zxingorg/web/WEB-INF/lib/httpmime-4.0.1.jar b/zxingorg/web/WEB-INF/lib/httpmime-4.0.1.jar
new file mode 100644 (file)
index 0000000..c27df78
Binary files /dev/null and b/zxingorg/web/WEB-INF/lib/httpmime-4.0.1.jar differ
diff --git a/zxingorg/web/WEB-INF/lib/httpmime-4.0.jar b/zxingorg/web/WEB-INF/lib/httpmime-4.0.jar
deleted file mode 100644 (file)
index 1658161..0000000
Binary files a/zxingorg/web/WEB-INF/lib/httpmime-4.0.jar and /dev/null differ
index 8256586..7743222 100644 (file)
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
   <head>
     <title>Bad Image</title>
+    <link rel="stylesheet" href="style.css" type="text/css"/>    
   </head>
   <body>
-    <h1><img src="zxing-icon.png" height="32" width="32" alt=""/> Bad Image</h1>
+    <div id="header"><h1><img src="zxing-icon.png" height="32" width="32" alt=""/> Bad Image</h1></div>
     <p>The image you uploaded could not be decoded, or was too large. Go "Back" in your browser and try another
       image.
     </p>
index d28e1d4..a73244e 100644 (file)
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
   <head>
     <title>Bad URL</title>
+    <link rel="stylesheet" href="style.css" type="text/css"/>    
   </head>
   <body>
-    <h1><img src="zxing-icon.png" height="32" width="32" alt=""/> Bad URL</h1>
+    <div id="header"><h1><img src="zxing-icon.png" height="32" width="32" alt=""/> Bad URL</h1></div>
     <p>You didn't specify a URL, or the URL was not valid, or did not return an image. Go "Back" in your browser and
       try again.
     </p>
index f3d08b6..8a51b9b 100644 (file)
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
   <head>
     <title>ZXing Decoder Online</title>
+    <link rel="stylesheet" href="style.css" type="text/css"/>
   </head>
   <body>
-    <h1><img src="zxing-icon.png" height="32" width="32" alt=""/> ZXing Decoder Online</h1>
+    <div id="header"><h1><img src="zxing-icon.png" height="32" width="32" alt=""/> ZXing Decoder Online</h1></div>
     <p>This is a simple page that will let you decode a 1D or 2D barcode found
       in an image online. Enter a URL below.
     </p>
@@ -45,7 +46,7 @@
       <a href="http://code.google.com/p/zxing">project page</a>
       for details.
     </p>
-    <p>Copyright 2008 and onwards ZXing authors</p>
+    <div id="footer"><p>Copyright 2008 and onwards ZXing authors</p></div>
     <jsp:include page="analytics.jspx"/>
   </body>
 </html>
index 265caad..40a0c48 100644 (file)
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
   <head>
     <title>Decode Succeeded</title>
+    <link rel="stylesheet" href="style.css" type="text/css"/>    
     <style type="text/css">
       td { vertical-align: top; padding: 0.1in; background-color: #EEEEEE; font-family: monospace; }
     </style>
   </head>
   <body>
-    <h1><img src="zxing-icon.png" height="32" width="32" alt=""/> Decode Succeeded</h1>
+    <div id="header"><h1><img src="zxing-icon.png" height="32" width="32" alt=""/> Decode Succeeded</h1></div>
     <table>
       <tr>
         <td>Raw text</td>
@@ -52,7 +53,7 @@
         <td><jsp:expression>request.getAttribute("displayResult")</jsp:expression></td>
       </tr>
     </table>
-    <p>Copyright 2008 and onwards ZXing authors</p>
+    <div id="footer"><p>Copyright 2008 and onwards ZXing authors</p></div>
     <jsp:include page="analytics.jspx"/>
   </body>
 </html>
index 6c928ec..809d681 100644 (file)
   <body>
     <h1><img src="zxing-icon.png" height="32" width="32" alt=""/> Download ZXing Reader</h1>
     <p>
-      <a href="BarcodeReader.jad">Download</a> the ZXing Barcode Reader for J2ME.
+      <a href="market://search?q=pname%3Acom.google.zxing.client.android">Download</a> the Android client.
     </p>
     <p>
-      (<a href="basic/BarcodeReader.jad">Download</a> the alternate "basic" version for J2ME.)
+      <a href="BarcodeReader.jad">Download</a> the Barcode Reader for J2ME.
     </p>
     <p>
-      <a href="market://search?q=pname%3Acom.google.zxing.client.android">Download</a> the Android client.
-    </p>
+      (<a href="basic/BarcodeReader.jad">Download</a> the alternate "basic" version for J2ME.)
+    </p> 
     <p>Copyright 2008 and onwards ZXing authors</p>
     <jsp:include page="analytics.jspx"/>
   </body>
index c5cb2dd..039391b 100644 (file)
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
   <head>
     <title>No Barcode Found</title>
+    <link rel="stylesheet" href="style.css" type="text/css"/>    
   </head>
   <body>
-    <h1><img src="zxing-icon.png" height="32" width="32" alt=""/> No Barcode Found</h1>
+    <div id="header"><h1><img src="zxing-icon.png" height="32" width="32" alt=""/> No Barcode Found</h1></div>
     <p>No barcode was found in this image. Either it did not contain a barcode, or did not contain one in a
       supported format, or the software was simply unable to find it. Go "Back" in your browser and try another image.
     </p>
diff --git a/zxingorg/web/style.css b/zxingorg/web/style.css
new file mode 100644 (file)
index 0000000..bdfde3c
--- /dev/null
@@ -0,0 +1,7 @@
+body{background-color:#e9eef3;font-family:Arial,sans-serif;font-size:12px}
+td{font-size:14px}
+#header{background-color:#dde3e9;border-bottom:1px solid #f2f7fc}
+#header h1{font-size:15px;font-weight:bold;padding:12px;border-bottom:1px solid #c8d0d9}
+#header span{font-weight:normal;color:#5e6b75}
+#footer{width:100%;text-align:center;padding-top:12px}
+#footer a{text-decoration:none;color:#5e6b75}