Set 'frame' to correct image bounds (#1130)

Ensure the x,y offset for extended v2 pictures is respected by updating 'frame' to the correct bounding rectangle. As a result we
need to base output image directly on frame size rather than applying screen image ratio. See cow.pict.

Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com>
This commit is contained in:
Rolf Howarth
2025-05-30 15:07:16 +01:00
committed by GitHub
parent 66363f8d09
commit defadbbbcd
3 changed files with 26 additions and 1 deletions
@@ -84,6 +84,7 @@ 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/cow.pict"), new Dimension(787, 548)),
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)),
@@ -251,6 +252,22 @@ public class PICTImageReaderTest extends ImageReaderAbstractTest<PICTImageReader
reader.read(0);
}
@Test
public void testFrameBoundsIssue() throws IOException {
PICTImageReader reader = createReader();
try (ImageInputStream stream = ImageIO.createImageInputStream(getClassLoaderResource("/pict/cow.pict"))) {
reader.setInput(stream);
// This file is from Apache POI test data. It should render as a black silhouette of a cow on a transparent
// background. Without the fix the image is completely transparent.
BufferedImage image = reader.read(0, null);
assertRGBEquals("RGB values differ", 0xff000000, image.getRGB(100, 100), 1); // was transparent 00ffffff
}
finally {
reader.dispose();
}
}
@Test
public void testBoundsIssue() throws IOException {
PICTImageReader reader = createReader();