pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1863746 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
Date Thu, 25 Jul 2019 16:37:20 GMT
Author: tilman
Date: Thu Jul 25 16:37:20 2019
New Revision: 1863746

URL: http://svn.apache.org/viewvc?rev=1863746&view=rev
Log:
PDFBOX-4607: set correct /Alternate colorspace for images with gray colorspace, by Emmeran
Seehuber

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java?rev=1863746&r1=1863745&r2=1863746&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
Thu Jul 25 16:37:20 2019
@@ -561,7 +561,8 @@ public final class LosslessFactory
             int w = image.getWidth();
 
             ColorSpace srcCspace = image.getColorModel().getColorSpace();
-            PDColorSpace pdColorSpace = srcCspace.getType() != ColorSpace.TYPE_CMYK
+            int srcCspaceType = srcCspace.getType();
+			PDColorSpace pdColorSpace = srcCspaceType != ColorSpace.TYPE_CMYK
                                         ? PDDeviceRGB.INSTANCE : PDDeviceCMYK.INSTANCE;
 
             // Encode the image profile if the image has one
@@ -579,9 +580,9 @@ public final class LosslessFactory
                     pdProfile.getPDStream().getCOSObject().setInt(COSName.N,
                             srcCspace.getNumComponents());
                     pdProfile.getPDStream().getCOSObject().setItem(COSName.ALTERNATE,
-                            srcCspace.getType() == ColorSpace.TYPE_CMYK ?
-                                    COSName.DEVICECMYK :
-                                    COSName.DEVICERGB);
+                            srcCspaceType == ColorSpace.TYPE_GRAY ? COSName.DEVICEGRAY
+                                    : (srcCspaceType == ColorSpace.TYPE_CMYK ? COSName.DEVICECMYK
+                                            : COSName.DEVICERGB));
                     pdColorSpace = pdProfile;
                 }
             }



Mime
View raw message