]> source.dussan.org Git - poi.git/commitdiff
clamp (h)sl values
authorAndreas Beeker <kiwiwings@apache.org>
Tue, 11 Aug 2015 00:07:15 +0000 (00:07 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Tue, 11 Aug 2015 00:07:15 +0000 (00:07 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1695183 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/sl/draw/DrawPaint.java

index c291717431b25edd07aea389e5dac58d0721b346..4309d4ec5dbdb2ca4713031bfbad2d31a6b59005 100644 (file)
@@ -356,15 +356,10 @@ public class DrawPaint {
      *  @returns the RGB Color object\r
      */\r
     private static Color HSL2RGB(double h, double s, double l, double alpha) {\r
-        if (s <0.0f || s > 100.0f) {\r
-            String message = "Color parameter outside of expected range - Saturation: " + s;\r
-            throw new IllegalArgumentException( message );\r
-        }\r
-\r
-        if (l <0.0f || l > 100.0f) {\r
-            String message = "Color parameter outside of expected range - Luminance: " + l;\r
-            throw new IllegalArgumentException( message );\r
-        }\r
+        // we clamp the values, as it possible to come up with more than 100% sat/lum\r
+        // (see links in applyColorTransform() for more info)\r
+        s = Math.max(0, Math.min(100, s));\r
+        l = Math.max(0, Math.min(100, l));\r
 \r
         if (alpha <0.0f || alpha > 1.0f) {\r
             String message = "Color parameter outside of expected range - Alpha: " + alpha;\r