TMI-38: Fixed a bug in the getSourceCS method, that incorrectly identified non-subsampled JFIF files, as RGB instead of YCbCr.

This commit is contained in:
Harald Kuhr
2014-03-02 22:08:26 +01:00
parent 5c735674f0
commit 037a47ca2a
3 changed files with 33 additions and 7 deletions

View File

@@ -329,6 +329,32 @@ public class JPEGImageReaderTest extends ImageReaderAbstractTestCase<JPEGImageRe
verify(warningListener).warningOccurred(eq(reader), anyString());
}
@Test
public void testYCbCrNotSubsampledNonstandardChannelIndexes() throws IOException {
// Regression: Make sure 3 channel, non-subsampled JFIF, defaults to YCbCr, even if unstandard channel indexes
JPEGImageReader reader = createReader();
reader.setInput(ImageIO.createImageInputStream(getClassLoaderResource("/jpeg/jfif-ycbcr-no-subsampling-intel.jpg")));
assertEquals(600, reader.getWidth(0));
assertEquals(600, reader.getHeight(0));
ImageReadParam param = reader.getDefaultReadParam();
param.setSourceRegion(new Rectangle(8, 8));
BufferedImage image = reader.read(0, param);
assertNotNull(image);
assertEquals(8, image.getWidth());
assertEquals(8, image.getHeight());
// QnD test: Make sure all pixels are white (if treated as RGB, they will be pink-ish)
for (int y = 0; y < image.getHeight(); y++) {
for (int x = 0; x < image.getWidth(); x++) {
assertEquals(0xffffff, image.getRGB(x, y) & 0xffffff);
}
}
}
@Test
public void testCorbisRGB() throws IOException {
// Special case, throws exception below without special treatment

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB