poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1695183 - /poi/trunk/src/java/org/apache/poi/sl/draw/DrawPaint.java
Date Tue, 11 Aug 2015 00:07:16 GMT
Author: kiwiwings
Date: Tue Aug 11 00:07:15 2015
New Revision: 1695183

URL: http://svn.apache.org/r1695183
Log:
clamp (h)sl values

Modified:
    poi/trunk/src/java/org/apache/poi/sl/draw/DrawPaint.java

Modified: poi/trunk/src/java/org/apache/poi/sl/draw/DrawPaint.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/DrawPaint.java?rev=1695183&r1=1695182&r2=1695183&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/DrawPaint.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/DrawPaint.java Tue Aug 11 00:07:15 2015
@@ -356,15 +356,10 @@ public class DrawPaint {
      *  @returns the RGB Color object
      */
     private static Color HSL2RGB(double h, double s, double l, double alpha) {
-        if (s <0.0f || s > 100.0f) {
-            String message = "Color parameter outside of expected range - Saturation: " +
s;
-            throw new IllegalArgumentException( message );
-        }
-
-        if (l <0.0f || l > 100.0f) {
-            String message = "Color parameter outside of expected range - Luminance: " +
l;
-            throw new IllegalArgumentException( message );
-        }
+        // we clamp the values, as it possible to come up with more than 100% sat/lum
+        // (see links in applyColorTransform() for more info)
+        s = Math.max(0, Math.min(100, s));
+        l = Math.max(0, Math.min(100, l));
 
         if (alpha <0.0f || alpha > 1.0f) {
             String message = "Color parameter outside of expected range - Alpha: " + alpha;



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message