From 8108ac42ebe300667c26836be5be05cc2201c040 Mon Sep 17 00:00:00 2001 From: srowen Date: Mon, 10 Mar 2008 16:26:57 +0000 Subject: [PATCH] Undo earlier change that rejects TYPE_CUSTOM -- too many images parse this way, and we can still decode them in some cases. Still can't rotate them. git-svn-id: https://zxing.googlecode.com/svn/trunk@258 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- .../client/j2se/BufferedImageMonochromeBitmapSource.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/javase/src/com/google/zxing/client/j2se/BufferedImageMonochromeBitmapSource.java b/javase/src/com/google/zxing/client/j2se/BufferedImageMonochromeBitmapSource.java index 01969395b..5030d7bf1 100644 --- a/javase/src/com/google/zxing/client/j2se/BufferedImageMonochromeBitmapSource.java +++ b/javase/src/com/google/zxing/client/j2se/BufferedImageMonochromeBitmapSource.java @@ -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; } /**