Merge pull request #458 from Schmidor/455

Fix for #455: Ignore profiles PhotometricInterpretation MinIsWhite wi…
This commit is contained in:
Harald Kuhr 2019-02-12 20:29:31 +01:00 committed by GitHub
commit 5ade293445
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View File

@ -468,7 +468,7 @@ public final class TIFFImageReader extends ImageReaderBase {
// We need special case to preserve WhiteIsZero for CCITT 1 bit encodings
// as some software will treat black/white runs as-is, regardless of photometric.
// Special handling is also in the normalizeColor method
if (profile == null && significantSamples == 1 && bitsPerSample == 1) {
if (significantSamples == 1 && bitsPerSample == 1) {
byte[] lut = new byte[] {-1, 0};
return ImageTypeSpecifier.createIndexed(lut, lut, lut, null, bitsPerSample, dataType);
}

View File

@ -611,6 +611,20 @@ public class TIFFImageReaderTest extends ImageReaderAbstractTest<TIFFImageReader
assertEquals(0xf5, alphaRaster.getPixel(50, 50, alpha)[0]);
}
}
@Test
public void testMinIsWhiteWithProfile() throws IOException {
ImageReader reader = createReader();
try (ImageInputStream stream = ImageIO.createImageInputStream(getClassLoaderResource("/tiff/ccitt/min-is-white-with-profile.tif"))) {
reader.setInput(stream);
BufferedImage image = reader.read(0);
assertNotNull(image);
assertEquals(0xFFFFFFFF, image.getRGB(0, 0));
assertEquals(0xFFFFFFFF, image.getRGB(50, 50));
}
}
@Test
public void testReadCMYKExtraSamples() throws IOException {