mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-02 19:15:29 -04:00
Fix bounds issue in some v2 PICT files (#1129)
x2 and y2 were swapped over, resulting in an "invalid bounds" exception with -ve height on some nonV2Ext images, see for example CatDV==2.0=1=.pict or Picture14.pict Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com>
This commit is contained in:
parent
1bef35daba
commit
66363f8d09
@ -254,8 +254,8 @@ public final class PICTImageReader extends ImageReaderBase {
|
||||
// the default Mac screen resolution and the image resolution
|
||||
|
||||
// int y, x, w(?), h (fixed point)
|
||||
double y2 = PICTUtil.readFixedPoint(pStream);
|
||||
double x2 = PICTUtil.readFixedPoint(pStream);
|
||||
double y2 = PICTUtil.readFixedPoint(pStream);
|
||||
double w2 = PICTUtil.readFixedPoint(pStream); // ?!
|
||||
double h2 = PICTUtil.readFixedPoint(pStream);
|
||||
|
||||
|
@ -84,6 +84,8 @@ public class PICTImageReaderTest extends ImageReaderAbstractTest<PICTImageReader
|
||||
new TestData(getClassLoaderResource("/pict/FC10.PCT"), new Dimension(2265, 2593)),
|
||||
// 1000 DPI with bounding box not matching DPI
|
||||
new TestData(getClassLoaderResource("/pict/oom.pict"), new Dimension(1713, 1263)),
|
||||
new TestData(getClassLoaderResource("/pict/CatDV==2.0=1=.pict"), new Dimension(375, 165)),
|
||||
new TestData(getClassLoaderResource("/pict/Picture14.pict"), new Dimension(404, 136)),
|
||||
new TestData(getClassLoaderResource("/pict/J19.pict"), new Dimension(640, 480)),
|
||||
|
||||
// Sample data from http://developer.apple.com/documentation/mac/QuickDraw/QuickDraw-458.html
|
||||
@ -249,6 +251,23 @@ public class PICTImageReaderTest extends ImageReaderAbstractTest<PICTImageReader
|
||||
reader.read(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoundsIssue() throws IOException {
|
||||
PICTImageReader reader = createReader();
|
||||
|
||||
try (ImageInputStream stream = ImageIO.createImageInputStream(getClassLoaderResource("/pict/Picture14.pict"))) {
|
||||
reader.setInput(stream);
|
||||
|
||||
BufferedImage image = reader.read(0, null);
|
||||
assertRGBEquals("RGB values differ", 0xffcccccc, image.getRGB(4, 4), 1); // was transparent 00ffffff
|
||||
assertRGBEquals("RGB values differ", 0xffcccccc, image.getRGB(5, 118), 1); // was red ffcc6666
|
||||
assertRGBEquals("RGB values differ", 0xffcc6666, image.getRGB(28, 60), 1); // was grey ffcccccc
|
||||
}
|
||||
finally {
|
||||
reader.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQTMaskBytesSkipped() throws IOException {
|
||||
assumeTrue(ImageIO.getImageReadersByFormatName("TIFF").hasNext(), "No TIFF plugin available, skipping test");
|
||||
|
BIN
imageio/imageio-pict/src/test/resources/pict/CatDV==2.0=1=.pict
Executable file
BIN
imageio/imageio-pict/src/test/resources/pict/CatDV==2.0=1=.pict
Executable file
Binary file not shown.
BIN
imageio/imageio-pict/src/test/resources/pict/Picture14.pict
Executable file
BIN
imageio/imageio-pict/src/test/resources/pict/Picture14.pict
Executable file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user