]> granicus.if.org Git - imagemagick/commitdiff
Support anti-aliased clipping when drawing
authorCristy <urban-warrior@imagemagick.org>
Sat, 5 May 2018 22:43:03 +0000 (18:43 -0400)
committerCristy <urban-warrior@imagemagick.org>
Sat, 5 May 2018 22:43:03 +0000 (18:43 -0400)
MagickCore/channel.c
MagickCore/draw.c

index 976d6b96b7228d7d846c515045b834ebcef1670d..4a000991509102b3e3d82f9c218cd8afe78a0e62 100644 (file)
@@ -1244,8 +1244,7 @@ MagickExport MagickBooleanType SetImageAlphaChannel(Image *image,
         for (x=0; x < (ssize_t) image->columns; x++)
         {
           FlattenPixelInfo(image,&image->background_color,
-            image->background_color.alpha,q,(double)
-            GetPixelAlpha(image,q),q);
+            image->background_color.alpha,q,(double) GetPixelAlpha(image,q),q);
           q+=GetPixelChannels(image);
         }
         if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
index 0b9f519f1f1e89ea33e138a9d3da3832b0c0de8b..e9ec1ca4af627a4a3a2c522cffcda6c07da686ab 100644 (file)
@@ -1513,6 +1513,8 @@ static Image *DrawClippingMask(Image *image,const DrawInfo *draw_info,
   clone_info->alpha=OpaqueAlpha;
   clone_info->clip_path=MagickTrue;
   status=DrawImage(clip_mask,clone_info,exception);
+  (void) CompositeImage(clip_mask,clip_mask,AlphaCompositeOp,MagickTrue,0,0,
+    exception);
   clone_info=DestroyDrawInfo(clone_info);
   if (status == MagickFalse)
     clip_mask=DestroyImage(clip_mask);
@@ -4525,14 +4527,6 @@ RestoreMSCWarning
     const int
       id = GetOpenMPThreadId();
 
-    double
-      fill_alpha,
-      stroke_alpha;
-
-    PixelInfo
-      fill_color,
-      stroke_color;
-
     register Quantum
       *magick_restrict q;
 
@@ -4556,14 +4550,18 @@ RestoreMSCWarning
       }
     for (x=start_x; x <= stop_x; x++)
     {
+      double
+        fill_alpha,
+        mask_alpha,
+        stroke_alpha;
+
+      PixelInfo
+        fill_color,
+        stroke_color;
+
       /*
         Fill and/or stroke.
       */
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       fill_alpha=GetFillAlpha(polygon_info[id],mid,fill,draw_info->fill_rule,
         x,y,&stroke_alpha);
       if (draw_info->stroke_antialias == MagickFalse)
@@ -4571,14 +4569,13 @@ RestoreMSCWarning
           fill_alpha=fill_alpha > 0.25 ? 1.0 : 0.0;
           stroke_alpha=stroke_alpha > 0.25 ? 1.0 : 0.0;
         }
+      mask_alpha=QuantumScale*GetPixelWriteMask(image,q);
       GetFillColor(draw_info,x-start_x,y-start_y,&fill_color,exception);
-      fill_alpha=fill_alpha*fill_color.alpha;
-      CompositePixelOver(image,&fill_color,fill_alpha,q,(double)
-        GetPixelAlpha(image,q),q);
+      CompositePixelOver(image,&fill_color,mask_alpha*fill_alpha*
+        fill_color.alpha,q,(double) GetPixelAlpha(image,q),q);
       GetStrokeColor(draw_info,x-start_x,y-start_y,&stroke_color,exception);
-      stroke_alpha=stroke_alpha*stroke_color.alpha;
-      CompositePixelOver(image,&stroke_color,stroke_alpha,q,(double)
-        GetPixelAlpha(image,q),q);
+      CompositePixelOver(image,&stroke_color,mask_alpha*stroke_alpha*
+        stroke_color.alpha,q,(double) GetPixelAlpha(image,q),q);
       q+=GetPixelChannels(image);
     }
     if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)