pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1758663 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendComposite.java
Date Wed, 31 Aug 2016 18:45:57 GMT
Author: tilman
Date: Wed Aug 31 18:45:57 2016
New Revision: 1758663

URL: http://svn.apache.org/viewvc?rev=1758663&view=rev
Log:
PDFBOX-3477: always clip alpha to 0..1

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

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendComposite.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendComposite.java?rev=1758663&r1=1758662&r2=1758663&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendComposite.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendComposite.java
Wed Aug 31 18:45:57 2016
@@ -45,21 +45,22 @@ public final class BlendComposite implem
      * @param blendMode Desired blend mode
      * @param constantAlpha Constant alpha, must be in the inclusive range
      * [0.0...1.0] or it will be clipped.
+     * @return a blend composite.
      */
     public static Composite getInstance(BlendMode blendMode, float constantAlpha)
     {
+        if (constantAlpha < 0)
+        {
+            LOG.warn("using 0 instead of incorrect Alpha " + constantAlpha);
+            constantAlpha = 0;
+        }
+        else if (constantAlpha > 1)
+        {
+            LOG.warn("using 1 instead of incorrect Alpha " + constantAlpha);
+            constantAlpha = 1;
+        }
         if (blendMode == BlendMode.NORMAL)
         {
-            if (constantAlpha < 0)
-            {
-                LOG.warn("using 0 instead of incorrect Alpha " + constantAlpha);
-                constantAlpha = 0;
-            }
-            else if (constantAlpha > 1)
-            {
-                LOG.warn("using 1 instead of incorrect Alpha " + constantAlpha);
-                constantAlpha = 1;
-            }
             return AlphaComposite.getInstance(AlphaComposite.SRC_OVER, constantAlpha);
         }
         else



Mime
View raw message