diff --git a/twelvemonkeys-imageio/core/src/test/java/com/twelvemonkeys/imageio/util/ImageReaderAbstractTestCase.java b/twelvemonkeys-imageio/core/src/test/java/com/twelvemonkeys/imageio/util/ImageReaderAbstractTestCase.java old mode 100755 new mode 100644 index 7a446284..84909fe7 --- a/twelvemonkeys-imageio/core/src/test/java/com/twelvemonkeys/imageio/util/ImageReaderAbstractTestCase.java +++ b/twelvemonkeys-imageio/core/src/test/java/com/twelvemonkeys/imageio/util/ImageReaderAbstractTestCase.java @@ -204,7 +204,7 @@ public abstract class ImageReaderAbstractTestCase extends reader.setInput(null); } - public void testRead() throws IOException { + public void testRead() { ImageReader reader = createReader(); for (TestData data : getTestData()) { // TODO: Is it required to call reset before setInput? @@ -1283,7 +1283,7 @@ public abstract class ImageReaderAbstractTestCase extends return getClass().getResource(pName); } - static final protected class TestData { + static final protected class TestData { private final Object mInput; private final List mSizes; private final List mImages; diff --git a/twelvemonkeys-imageio/pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java b/twelvemonkeys-imageio/pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java old mode 100755 new mode 100644 index a05c775d..b146d450 --- a/twelvemonkeys-imageio/pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java +++ b/twelvemonkeys-imageio/pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java @@ -191,7 +191,7 @@ public class PICTImageReader extends ImageReaderBase { // Get frame at 72 dpi // NOTE: These are not pixel sizes! - // Need sto be multiplied with hRes/screenResolution and vRes/screenResolution + // Need to be multiplied with hRes/screenResolution and vRes/screenResolution int y = pStream.readUnsignedShort(); int x = pStream.readUnsignedShort(); int h = pStream.readUnsignedShort(); @@ -1664,10 +1664,18 @@ public class PICTImageReader extends ImageReaderBase { throw e; } catch (EOFException e) { - throw new IIOException("Error in PICT format: Unexpected end of File", e); + String pos; + try { + pos = String.format("position %d", mImageInput.getStreamPosition()); + } + catch (IOException ignore) { + pos = "unknown position"; + } + + throw new IIOException(String.format("Error in PICT format: Unexpected end of File at %s", pos), e); } catch (IOException e) { - throw new IIOException("Error in PICT format: " + e.getMessage(), e); + throw new IIOException(String.format("Error in PICT format: %s", e.getMessage()), e); } } @@ -2528,7 +2536,7 @@ public class PICTImageReader extends ImageReaderBase { /* * Read a long comment from the stream. */ - private void readLongComment(DataInput pStream) throws IOException { + private void readLongComment(final DataInput pStream) throws IOException { // Comment kind and data byte count pStream.readShort(); @@ -2604,12 +2612,12 @@ public class PICTImageReader extends ImageReaderBase { // TODO: Might need to clear background g.setTransform(AffineTransform.getScaleInstance(mScreenImageXRatio, mScreenImageYRatio)); - try { +// try { drawOnto(g); - } - catch (IOException e) { - e.printStackTrace(); - } +// } +// catch (IOException e) { +// e.printStackTrace(); +// } } finally { g.dispose(); diff --git a/twelvemonkeys-imageio/pict/src/test/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReaderTestCase.java b/twelvemonkeys-imageio/pict/src/test/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReaderTestCase.java old mode 100755 new mode 100644 index ec2ad5f7..8a02dea1 --- a/twelvemonkeys-imageio/pict/src/test/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReaderTestCase.java +++ b/twelvemonkeys-imageio/pict/src/test/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReaderTestCase.java @@ -4,6 +4,7 @@ import com.twelvemonkeys.imageio.util.ImageReaderAbstractTestCase; import javax.imageio.spi.ImageReaderSpi; import java.awt.*; +import java.io.IOException; import java.util.Arrays; import java.util.List; @@ -18,7 +19,7 @@ public class PICTImageReaderTestCase extends ImageReaderAbstractTestCase getTestData() { return Arrays.asList( new TestData(getClassLoaderResource("/pict/test.pct"), new Dimension(300, 200)), @@ -57,4 +58,13 @@ public class PICTImageReaderTestCase extends ImageReaderAbstractTestCase getMIMETypes() { return Arrays.asList("image/pict", "image/x-pict"); } + + public void testProviderNotMatchJPEG() throws IOException { + // This JPEG contains PICT magic bytes at locations a PICT would normally have them. + // We should not claim to be able read it. + assertFalse(sProvider.canDecodeInput(new TestData( + getClassLoaderResource("/jpeg/R-7439-1151526181.jpeg"), + new Dimension(386, 396) + ))); + } } \ No newline at end of file diff --git a/twelvemonkeys-imageio/pict/src/test/resources/jpeg/R-7439-1151526181.jpeg b/twelvemonkeys-imageio/pict/src/test/resources/jpeg/R-7439-1151526181.jpeg new file mode 100644 index 00000000..a20a5899 Binary files /dev/null and b/twelvemonkeys-imageio/pict/src/test/resources/jpeg/R-7439-1151526181.jpeg differ