pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1611708 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDLab.java
Date Fri, 18 Jul 2014 16:44:38 GMT
Author: tilman
Date: Fri Jul 18 16:44:38 2014
New Revision: 1611708

URL: http://svn.apache.org/r1611708
Log:
PDFBOX-2221: set negative XYZ values to 0 in /Lab to RGB conversion

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDLab.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDLab.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDLab.java?rev=1611708&r1=1611707&r2=1611708&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDLab.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDLab.java
Fri Jul 18 16:44:38 2014
@@ -143,6 +143,22 @@ public final class PDLab extends PDCIEBa
         float x = wpX * inverse(lstar + value[1] * (1f / 500f));
         float y = wpY * inverse(lstar);
         float z = wpZ * inverse(lstar - value[2] * (1f / 200f));
+        
+        // toRGB() malfunctions with negative values
+        // XYZ must be non-negative anyway:
+        // http://ninedegreesbelow.com/photography/icc-profile-negative-tristimulus.html
+        if (x < 0)
+        {
+            x = 0;
+        }
+        if (y < 0)
+        {
+            y = 0;
+        }
+        if (z < 0)
+        {
+            z = 0;
+        }
 
         // XYZ to RGB
         return CIEXYZ.toRGB(new float[] { x, y, z });



Mime
View raw message