pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1868833 - in /pdfbox/branches/2.0/pdfbox/src/test: java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactoryTest.java resources/org/apache/pdfbox/pdmodel/graphics/image/gif-1bit-transparent.gif
Date Thu, 24 Oct 2019 02:37:22 GMT
Author: tilman
Date: Thu Oct 24 02:37:22 2019
New Revision: 1868833

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

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

Modified: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactoryTest.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactoryTest.java?rev=1868833&r1=1868832&r2=1868833&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactoryTest.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactoryTest.java
Thu Oct 24 02:37:22 2019
@@ -264,6 +264,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/2.0/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/gif-1bit-transparent.gif
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/gif-1bit-transparent.gif?rev=1868833&view=auto
==============================================================================
Binary file - no diff available.

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



Mime
View raw message