pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1823593 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java
Date Thu, 08 Feb 2018 18:58:28 GMT
Author: tilman
Date: Thu Feb  8 18:58:28 2018
New Revision: 1823593

URL: http://svn.apache.org/viewvc?rev=1823593&view=rev
Log:
PDFBOX-3000: use the revised PDF 2.0 equations for the blend modes ColorDodge and ColorBurn
as suggested by Jani Pehkonen

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java?rev=1823593&r1=1823592&r2=1823593&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java
Thu Feb  8 18:58:28 2018
@@ -136,7 +136,16 @@ public abstract class BlendMode
         @Override
         public float blendChannel(float srcValue, float dstValue)
         {
-            return (srcValue < 1) ? Math.min(1, dstValue / (1 - srcValue)) : 1;
+            // See PDF 2.0 specification
+            if (dstValue == 0)
+            {
+                return 0;
+            }
+            if (dstValue >= 1 - srcValue)
+            {
+                return 1;
+            }
+            return dstValue / (1 - srcValue);
         }
     };
 
@@ -145,7 +154,16 @@ public abstract class BlendMode
         @Override
         public float blendChannel(float srcValue, float dstValue)
         {
-            return (srcValue > 0) ? 1 - Math.min(1, (1 - dstValue) / srcValue) : 0;
+            // See PDF 2.0 specification
+            if (dstValue == 1)
+            {
+                return 1;
+            }
+            if (1 - dstValue >= srcValue)
+            {
+                return 0;
+            }
+            return 1 - (1 - dstValue) / srcValue;
         }
     };
 



Mime
View raw message