mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2026-04-25 00:00:03 -04:00
#681: Fix for little-endian "packed" USHORT types + rewritten stream handling
This commit is contained in:
+31
-2
@@ -44,7 +44,7 @@ import javax.imageio.metadata.IIOMetadata;
|
||||
import javax.imageio.spi.ImageReaderSpi;
|
||||
import javax.imageio.stream.ImageInputStream;
|
||||
import java.awt.*;
|
||||
import java.awt.color.ColorSpace;
|
||||
import java.awt.color.*;
|
||||
import java.awt.image.*;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteOrder;
|
||||
@@ -56,7 +56,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.AdditionalMatchers.and;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@@ -892,6 +895,32 @@ public class TIFFImageReaderTest extends ImageReaderAbstractTest<TIFFImageReader
|
||||
assertSubsampledImageDataEquals("Subsampled image data does not match expected", image, subsampled, param);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadLittleEndian4444ARGB() throws IOException {
|
||||
ImageReader reader = createReader();
|
||||
|
||||
try (ImageInputStream stream = ImageIO.createImageInputStream(getClassLoaderResource("/tiff/little-endian-rgba-4444.tiff"))) {
|
||||
reader.setInput(stream);
|
||||
|
||||
BufferedImage image = null;
|
||||
try {
|
||||
image = reader.read(0);
|
||||
}
|
||||
catch (IOException e) {
|
||||
failBecause("Image could not be read", e);
|
||||
}
|
||||
|
||||
assertNotNull(image);
|
||||
assertEquals(589, image.getWidth());
|
||||
assertEquals(340, image.getHeight());
|
||||
|
||||
assertRGBEquals("Red", 0xffff1111, image.getRGB(124, 42), 4);
|
||||
assertRGBEquals("Green", 0xff66ee11, image.getRGB(476, 100), 4);
|
||||
assertRGBEquals("Yellow", 0xffffff00, image.getRGB(312, 186), 4);
|
||||
assertRGBEquals("Blue", 0xff1155dd, image.getRGB(366, 192), 4);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadUnsupported() throws IOException {
|
||||
ImageReader reader = createReader();
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user