You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2018/02/08 18:58:33 UTC
svn commit: r1823594 -
/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java
Author: tilman
Date: Thu Feb 8 18:58:33 2018
New Revision: 1823594
URL: http://svn.apache.org/viewvc?rev=1823594&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/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java?rev=1823594&r1=1823593&r2=1823594&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java Thu Feb 8 18:58:33 2018
@@ -125,7 +125,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);
}
};
@@ -134,7 +143,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;
}
};