Undo earlier change that rejects TYPE_CUSTOM -- too many images parse this way, and...
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Mon, 10 Mar 2008 16:26:57 +0000 (16:26 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Mon, 10 Mar 2008 16:26:57 +0000 (16:26 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@258 59b500cc-1b3d-0410-9834-0bbf25fbcc57

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

index 0196939..5030d7b 100644 (file)
@@ -45,9 +45,6 @@ public final class BufferedImageMonochromeBitmapSource implements MonochromeBitm
   private static final int LUMINANCE_BUCKETS = 1 << LUMINANCE_BITS;
 
   public BufferedImageMonochromeBitmapSource(BufferedImage image) {
-    if (image.getType() == BufferedImage.TYPE_CUSTOM) {
-      throw new IllegalArgumentException("Can't handle BufferedImage of type TYPE_CUSTOM");
-    }
     this.image = image;
     blackPoint = 0x7F;
     lastMethod = null;
@@ -119,6 +116,9 @@ public final class BufferedImageMonochromeBitmapSource implements MonochromeBitm
   }
 
   public MonochromeBitmapSource rotateCounterClockwise() {
+    if (!isRotateSupported()) {
+      throw new IllegalStateException("Rotate not supported");
+    }
     // 90 degrees counterclockwise:
     AffineTransform transform = new AffineTransform(0.0, -1.0, 1.0, 0.0, 0.0, image.getHeight());
     BufferedImageOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
@@ -128,7 +128,8 @@ public final class BufferedImageMonochromeBitmapSource implements MonochromeBitm
   }
 
   public boolean isRotateSupported() {
-    return true;
+    // Can't run AffineTransforms on images of unknown format
+    return image.getType() != BufferedImage.TYPE_CUSTOM;
   }
 
   /**