mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 03:55:28 -04:00
449# Missing test to verify that we ignore bogus 0 byte counts.
(cherry picked from commit 7985cdd4a7c459cace5ee247426a968c37c8964f)
This commit is contained in:
parent
bdd7f5b228
commit
22a842eb78
@ -566,6 +566,57 @@ public class TIFFImageReaderTest extends ImageReaderAbstractTest<TIFFImageReader
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadBogusByteCounts() throws IOException {
|
||||
ImageReader reader = createReader();
|
||||
|
||||
try (ImageInputStream stream = ImageIO.createImageInputStream(getClassLoaderResource("/tiff/CCITT-G4-300dpi-StripByteCounts0.tif"))) {
|
||||
reader.setInput(stream);
|
||||
|
||||
ImageReadParam param = reader.getDefaultReadParam();
|
||||
|
||||
BufferedImage image = null;
|
||||
try {
|
||||
// Get the crop mark on the page
|
||||
param.setSourceRegion(new Rectangle(95, 105, 100, 100));
|
||||
image = reader.read(0, param);
|
||||
}
|
||||
catch (IOException e) {
|
||||
failBecause("Image could not be read", e);
|
||||
}
|
||||
|
||||
assertNotNull(image);
|
||||
assertEquals(100, image.getWidth());
|
||||
assertEquals(100, image.getHeight());
|
||||
|
||||
// We have cropped a crop mark, should be black on white
|
||||
for (int y = 0; y < 26; y++) {
|
||||
for (int x = 0; x < 67; x++) {
|
||||
assertRGBEquals("Expected black " + x + "," + y, 0xff000000, image.getRGB(x, y), 0);
|
||||
}
|
||||
// Skip one column due to fuzzy edges
|
||||
for (int x = 68; x < 100; x++) {
|
||||
assertRGBEquals("Expected white " + x + "," + y, 0xffffffff, image.getRGB(x, y), 0);
|
||||
}
|
||||
}
|
||||
// Skip one row due to fuzzy edges
|
||||
for (int y = 27; y < 71; y++) {
|
||||
for (int x = 0; x < 23; x++) {
|
||||
assertRGBEquals("Expected black " + x + "," + y, 0xff000000, image.getRGB(x, y), 0);
|
||||
}
|
||||
// Skip one column due to fuzzy edges
|
||||
for (int x = 24; x < 100; x++) {
|
||||
assertRGBEquals("Expected white " + x + "," + y, 0xffffffff, image.getRGB(x, y), 0);
|
||||
}
|
||||
}
|
||||
for (int y = 71; y < 100; y++) {
|
||||
for (int x = 0; x < 100; x++) {
|
||||
assertRGBEquals("Expected white " + x + "," + y, 0xffffffff, image.getRGB(x, y), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadMultipleExtraSamples() throws IOException {
|
||||
ImageReader reader = createReader();
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user