You can now dump the black point for URLs to the pwd.
authordswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 26 May 2009 18:12:22 +0000 (18:12 +0000)
committerdswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 26 May 2009 18:12:22 +0000 (18:12 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@954 59b500cc-1b3d-0410-9834-0bbf25fbcc57

javase/src/com/google/zxing/client/j2se/CommandLineRunner.java

index 48913cf..a09bdf6 100644 (file)
@@ -170,7 +170,6 @@ public final class CommandLineRunner {
   // Writes out a single PNG which is three times the width of the input image, containing from left
   // to right: the original image, the row sampling monochrome version, and the 2D sampling
   // monochrome version.
-  // TODO: Currently fails on URLs. Would be nice to handle gracefully and write the output to pwd.
   private static void dumpBlackPoint(URI uri, BufferedImage image, MonochromeBitmapSource source) {
     String inputName = uri.getPath();
     if (inputName.contains(".mono.png")) {
@@ -235,7 +234,14 @@ public final class CommandLineRunner {
     BufferedImage result = new BufferedImage(stride, height, BufferedImage.TYPE_INT_ARGB);
     result.setRGB(0, 0, stride, height, pixels, 0, stride);
 
+    // Use the current working directory for URLs
     String resultName = inputName;
+    if (uri.getScheme().equals("http")) {
+      int pos = resultName.lastIndexOf('/');
+      if (pos > 0) {
+        resultName = "." + resultName.substring(pos);
+      }
+    }
     int pos = resultName.lastIndexOf('.');
     if (pos > 0) {
       resultName = resultName.substring(0, pos);