pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1601862 - /pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDJpeg.java
Date Wed, 11 Jun 2014 11:40:10 GMT
Author: tilman
Date: Wed Jun 11 11:40:09 2014
New Revision: 1601862

URL: http://svn.apache.org/r1601862
Log:
PDFBOX-2101: save RGB and Gray JPEG images directly, as suggested by Jeremias Maerki

Modified:
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDJpeg.java

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDJpeg.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDJpeg.java?rev=1601862&r1=1601861&r2=1601862&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDJpeg.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDJpeg.java
Wed Jun 11 11:40:09 2014
@@ -292,6 +292,18 @@ public class PDJpeg extends PDXObjectIma
      */
     public void write2OutputStream(OutputStream out) throws IOException
     {
+        String colorSpaceName = getColorSpace().getName();
+        if (PDDeviceGray.NAME.equals(colorSpaceName)
+                || PDDeviceRGB.NAME.equals(colorSpaceName))
+        {
+            // RGB and Gray colorspace:
+            // get and write the unmodified JPEG stream
+            removeAllFiltersButDCT(out);
+            return;
+        }
+        // CMYK and other "unusual" colorspaces
+        // create BufferedImage with correct colors and then save into a 
+        // JPEG (some quality loss)
         getRGBImage();
         if (image != null) 
         {



Mime
View raw message