From d02d45f95a1ac1216ef9108400b49df1d1862e41 Mon Sep 17 00:00:00 2001 From: Harald Kuhr Date: Tue, 9 Jan 2018 20:01:30 +0100 Subject: [PATCH] #400 Added test case for the V3 with no palette case. --- .../plugins/pcx/PCXImageReaderTest.java | 24 ++++++++++++++++++ .../resources/pcx/no-palette-monochrome.pcx | Bin 0 -> 2384 bytes 2 files changed, 24 insertions(+) create mode 100755 imageio/imageio-pcx/src/test/resources/pcx/no-palette-monochrome.pcx diff --git a/imageio/imageio-pcx/src/test/java/com/twelvemonkeys/imageio/plugins/pcx/PCXImageReaderTest.java b/imageio/imageio-pcx/src/test/java/com/twelvemonkeys/imageio/plugins/pcx/PCXImageReaderTest.java index dfc758c5..794027a7 100755 --- a/imageio/imageio-pcx/src/test/java/com/twelvemonkeys/imageio/plugins/pcx/PCXImageReaderTest.java +++ b/imageio/imageio-pcx/src/test/java/com/twelvemonkeys/imageio/plugins/pcx/PCXImageReaderTest.java @@ -68,6 +68,7 @@ public class PCXImageReaderTest extends ImageReaderAbstractTest new TestData(getClassLoaderResource("/pcx/lena9.pcx"), new Dimension(512, 512)), // RLE encoded, 2 color indexed (1 bps/1 channel) new TestData(getClassLoaderResource("/pcx/lena10.pcx"), new Dimension(512, 512)), // RLE encoded, 16 color indexed (4 bps/1 channel) (uses only 8 colors) new TestData(getClassLoaderResource("/pcx/DARKSTAR.PCX"), new Dimension(88, 52)), // RLE encoded monochrome (1 bps/1 channel) + new TestData(getClassLoaderResource("/pcx/no-palette-monochrome.pcx"), new Dimension(128, 152)), // RLE encoded monochrome (1 bps/1 channel) // See cga-pcx.txt, however, the text seems to be in error, the bits can not not as described new TestData(getClassLoaderResource("/pcx/CGA_BW.PCX"), new Dimension(640, 200)), // RLE encoded indexed (CGA mode) new TestData(getClassLoaderResource("/pcx/CGA_FSD.PCX"), new Dimension(320, 200)), // RLE encoded indexed (CGA mode) @@ -131,6 +132,29 @@ public class PCXImageReaderTest extends ImageReaderAbstractTest } } + @Test + public void testReadMonochromeNoPalette() throws IOException { + // Monochrome image V3 (no palette), palette is all 0's + try (ImageInputStream input = ImageIO.createImageInputStream(getClassLoaderResource("/pcx/no-palette-monochrome.pcx"))) { + PCXImageReader reader = createReader(); + reader.setInput(input); + + assertEquals(1, reader.getNumImages(true)); + assertEquals(128, reader.getWidth(0)); + assertEquals(152, reader.getHeight(0)); + + BufferedImage image = reader.read(0); + + assertNotNull(image); + assertEquals(BufferedImage.TYPE_BYTE_BINARY, image.getType()); + assertEquals(128, image.getWidth()); + assertEquals(152, image.getHeight()); + + assertRGBEquals("Should have white background", 0xffffffff, image.getRGB(0, 0), 0); + assertRGBEquals("Should have black skull", 0xff000000, image.getRGB(64, 10), 0); + } + } + @Test public void testReadWithSourceRegionParamEqualImage() throws IOException { TestData data = getTestData().get(1); diff --git a/imageio/imageio-pcx/src/test/resources/pcx/no-palette-monochrome.pcx b/imageio/imageio-pcx/src/test/resources/pcx/no-palette-monochrome.pcx new file mode 100755 index 0000000000000000000000000000000000000000..b7ee9dc2f9a5685d9b76f5fb7b82fd42e9cc9c6c GIT binary patch literal 2384 zcmbuAzi#735XP6FVFH0-rpy7pW0MC+sUpzofP;}DKwd$IGgPHe>B7j;Q2;doT&4+p zufkc%l2aJT0|W+jD$=gtB0PZL=9^hjvM+F9L;}hAelt6}oc+Vk;wV!18TBhap8t!! zcz&A)E&lYM{uiEV6)ioU&Z=|)BeyDE_-jvXM4lQYwu`M-=9+P#EgEHP=OvoAZSA^(#-vI;bVR#3qPHE?gHbYBA6ME)Rc@H z&7%)?ZD2PKZ7nfwiRKT?Oz4JbD(3pe?~LI5`^G1oi9xK*eb+uw)sT+&C(vh`E) zS_;Xaimb;1OG9M^$Z|9KQmS796$+?Uc8_vp0J6uxDVv75LnDr;RH6e|(Z(vxV9V|oj@_7bq2k<#u1~jmy9ArBI=`&Q=3px?g6y%ZR2*ar$=%09Vf{iI z(Hmak$E+N@8-90#o2Qk1jB72p5KPsXiX^(u80UukE32sJZEgI zX;3O+m8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