]> granicus.if.org Git - imagemagick/commitdiff
...
authorCristy <urban-warrior@imagemagick.org>
Sun, 25 Feb 2018 14:41:51 +0000 (09:41 -0500)
committerCristy <urban-warrior@imagemagick.org>
Sun, 25 Feb 2018 14:48:29 +0000 (09:48 -0500)
MagickCore/draw.c

index 8842d1ce7a7ed38370b6b079220656e86bc13834..a1a9a0ec405b7618fa63c39a0bf5826676619a43 100644 (file)
@@ -2060,13 +2060,17 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
           }
         if (LocaleCompare("fill-opacity",keyword) == 0)
           {
+            double
+              opacity;
+
             GetNextToken(q,&q,extent,token);
             factor=strchr(token,'%') != (char *) NULL ? 0.01 : 1.0;
-            graphic_context[n]->fill_alpha=(MagickRealType) (QuantumRange-
-              ClampToQuantum((MagickRealType) QuantumRange*(1.0-factor*
-              StringToDouble(token,&next_token))));
+            opacity=MagickMin(MagickMax(factor*
+              StringToDouble(token,&next_token),0.0),1.0);
             if (token == next_token)
               ThrowPointExpectedException(token,exception);
+            graphic_context[n]->fill_alpha=(MagickRealType) (QuantumRange-
+              QuantumRange*(1.0-opacity));
             break;
           }
         if (LocaleCompare("fill-rule",keyword) == 0)
@@ -2750,13 +2754,17 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
           }
         if (LocaleCompare("stroke-opacity",keyword) == 0)
           {
+            double
+              opacity;
+
             GetNextToken(q,&q,extent,token);
             factor=strchr(token,'%') != (char *) NULL ? 0.01 : 1.0;
-            graphic_context[n]->stroke_alpha=(MagickRealType) (QuantumRange-
-              ClampToQuantum((MagickRealType) QuantumRange*(1.0-factor*
-              StringToDouble(token,&next_token))));
+            opacity=MagickMin(MagickMax(factor*
+              StringToDouble(token,&next_token),0.0),1.0);
             if (token == next_token)
               ThrowPointExpectedException(token,exception);
+            graphic_context[n]->stroke_alpha=(MagickRealType) (QuantumRange-
+              QuantumRange*(1.0-opacity));
             break;
           }
         if (LocaleCompare("stroke-width",keyword) == 0)