You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2019/10/24 02:37:11 UTC

svn commit: r1868831 - in /pdfbox/branches/issue4569/pdfbox/src/test: java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactoryTest.java resources/org/apache/pdfbox/pdmodel/graphics/image/gif-1bit-transparent.gif

Author: tilman
Date: Thu Oct 24 02:37:11 2019
New Revision: 1868831

URL: http://svn.apache.org/viewvc?rev=1868831&view=rev
Log:
PDFBOX-4672: add "previously failing" test of 1-bit bw gif

Added:
    pdfbox/branches/issue4569/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/gif-1bit-transparent.gif   (with props)
Modified:
    pdfbox/branches/issue4569/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactoryTest.java

Modified: pdfbox/branches/issue4569/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactoryTest.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue4569/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactoryTest.java?rev=1868831&r1=1868830&r2=1868831&view=diff
==============================================================================
--- pdfbox/branches/issue4569/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactoryTest.java (original)
+++ pdfbox/branches/issue4569/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactoryTest.java Thu Oct 24 02:37:11 2019
@@ -263,6 +263,36 @@ public class LosslessFactoryTest extends
     }
 
     /**
+     * Tests LosslessFactoryTest#createFromImage(PDDocument document,
+     * BufferedImage image) with a transparent 1 bit GIF. (PDFBOX-4672)
+     * This ends up as RGB because the 1 bit fast path doesn't support transparency.
+     *
+     * @throws java.io.IOException
+     */
+    public void testCreateLosslessFromTransparent1BitGIF() throws IOException
+    {
+        PDDocument document = new PDDocument();
+        BufferedImage image = ImageIO.read(this.getClass().getResourceAsStream("gif-1bit-transparent.gif"));
+
+        assertEquals(Transparency.BITMASK, image.getColorModel().getTransparency());
+        assertEquals(BufferedImage.TYPE_BYTE_BINARY, image.getType());
+
+        PDImageXObject ximage = LosslessFactory.createFromImage(document, image);
+
+        int w = image.getWidth();
+        int h = image.getHeight();
+        validate(ximage, 8, w, h, "png", PDDeviceRGB.INSTANCE.getName());
+        checkIdent(image, ximage.getImage());
+        checkIdentRGB(image, ximage.getOpaqueImage());
+
+        assertNotNull(ximage.getSoftMask());
+        validate(ximage.getSoftMask(), 1, w, h, "png", PDDeviceGray.INSTANCE.getName());
+        assertEquals(2, colorCount(ximage.getSoftMask().getImage()));
+
+        doWritePDF(document, ximage, testResultsDir, "gif-1bit-transparent.pdf");
+    }
+
+    /**
      * Test file that had a predictor encoding bug in PDFBOX-4184.
      *
      * @throws java.io.IOException

Added: pdfbox/branches/issue4569/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/gif-1bit-transparent.gif
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue4569/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/gif-1bit-transparent.gif?rev=1868831&view=auto
==============================================================================
Binary file - no diff available.

Propchange: pdfbox/branches/issue4569/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/gif-1bit-transparent.gif
------------------------------------------------------------------------------
    svn:mime-type = image/gif