Fix getAlphaRaster for ExtraSamplesColorModel

This commit is contained in:
Ivan Khaldeev
2018-06-29 10:02:05 +04:00
parent 44530d4717
commit c83171cdbf
3 changed files with 36 additions and 0 deletions
@@ -40,6 +40,7 @@ import javax.imageio.stream.ImageInputStream;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
import java.io.IOException;
import java.nio.ByteOrder;
import java.util.Arrays;
@@ -586,6 +587,25 @@ public class TIFFImageReaderTest extends ImageReaderAbstractTest<TIFFImageReader
}
}
@Test
public void testAlphaRasterForMultipleExtraSamples() throws IOException {
ImageReader reader = createReader();
try (ImageInputStream stream = ImageIO.createImageInputStream(getClassLoaderResource("/tiff/extra-channels.tif"))) {
reader.setInput(stream);
BufferedImage image = reader.read(0);
assertNotNull(image);
assertEquals(0x00, image.getRGB(0, 0));
assertEquals(0xf5, (image.getRGB(50, 50) & 0xff000000) >>> 24);
int[] alpha = new int[1];
WritableRaster alphaRaster = image.getAlphaRaster();
assertEquals(0x00, alphaRaster.getPixel(0, 0, alpha)[0]);
assertEquals(0xf5, alphaRaster.getPixel(50, 50, alpha)[0]);
}
}
@Test
public void testReadWithSubsampleParamPixelsJPEG() throws IOException {
// Tiled "new style" JPEG
Binary file not shown.