From: Cristy Date: Sat, 28 Apr 2018 15:33:34 +0000 (-0400) Subject: ... X-Git-Tag: 7.0.7-29~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=997bf4e6299b18614f467f6e89b08adb180c735a;p=imagemagick ... --- diff --git a/MagickCore/draw.c b/MagickCore/draw.c index c38542942..b6bdd087c 100644 --- a/MagickCore/draw.c +++ b/MagickCore/draw.c @@ -168,7 +168,7 @@ typedef struct _PathInfo Forward declarations. */ static Image - *DrawImageClippingMask(Image *,const DrawInfo *,const char *,ExceptionInfo *); + *DrawClippingMask(Image *,const DrawInfo *,const char *,ExceptionInfo *); static MagickBooleanType DrawStrokePolygon(Image *,const DrawInfo *,const PrimitiveInfo *, @@ -1412,8 +1412,8 @@ MagickExport MagickBooleanType DrawClipPath(Image *image, MagickBooleanType status; - - clipping_mask=DrawImageClippingMask(image,draw_info,clip_path,exception); + + clipping_mask=DrawClippingMask(image,draw_info,clip_path,exception); if (clipping_mask == (Image *) NULL) return(MagickFalse); status=SetImageMask(image,WritePixelMask,clipping_mask,exception); @@ -1426,6 +1426,89 @@ MagickExport MagickBooleanType DrawClipPath(Image *image, % % % % % % +% D r a w C l i p p i n g M a s k % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% DrawClippingMask() draws the clip path and returns it as an image clipping +% mask. +% +% The format of the DrawClippingMask method is: +% +% Image *DrawClippingMask(Image *image,const DrawInfo *draw_info, +% const char *clip_path,ExceptionInfo *exception) +% +% A description of each parameter follows: +% +% o image: the image. +% +% o draw_info: the draw info. +% +% o clip_path: the clip path. +% +% o exception: return any errors or warnings in this structure. +% +*/ +static Image *DrawClippingMask(Image *image,const DrawInfo *draw_info, + const char *clip_path,ExceptionInfo *exception) +{ + Image + *clip_mask; + + DrawInfo + *clone_info; + + MagickStatusType + status; + + /* + Draw a clip path. + */ + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); + assert(draw_info != (const DrawInfo *) NULL); + clip_mask=CloneImage(image,image->columns,image->rows,MagickTrue,exception); + if (clip_mask == (Image *) NULL) + return((Image *) NULL); + (void) SetImageMask(clip_mask,ReadPixelMask,(Image *) NULL,exception); + (void) SetImageMask(clip_mask,WritePixelMask,(Image *) NULL,exception); + (void) QueryColorCompliance("#0000",AllCompliance, + &clip_mask->background_color,exception); + clip_mask->background_color.alpha=(MagickRealType) TransparentAlpha; + clip_mask->background_color.alpha_trait=BlendPixelTrait; + (void) SetImageBackgroundColor(clip_mask,exception); + if (image->debug != MagickFalse) + (void) LogMagickEvent(DrawEvent,GetMagickModule(),"\nbegin clip-path %s", + draw_info->clip_mask); + clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); + (void) CloneString(&clone_info->primitive,clip_path); + (void) QueryColorCompliance("#ffffff",AllCompliance,&clone_info->fill, + exception); + if (clone_info->clip_mask != (char *) NULL) + clone_info->clip_mask=DestroyString(clone_info->clip_mask); + (void) QueryColorCompliance("#00000000",AllCompliance,&clone_info->stroke, + exception); + clone_info->stroke_width=0.0; + clone_info->alpha=OpaqueAlpha; + clone_info->clip_path=MagickTrue; + status=DrawImage(clip_mask,clone_info,exception); + clone_info=DestroyDrawInfo(clone_info); + if (status == MagickFalse) + clip_mask=DestroyImage(clip_mask); + if (image->debug != MagickFalse) + (void) LogMagickEvent(DrawEvent,GetMagickModule(),"end clip-path"); + return(clip_mask); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % + D r a w D a s h P o l y g o n % % % % % @@ -2044,7 +2127,7 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, clip_path=GetNodeByURL(primitive,token); if (clip_path != (char *) NULL) { - graphic_context[n]->clipping_mask=DrawImageClippingMask(image, + graphic_context[n]->clipping_mask=DrawClippingMask(image, graphic_context[n],clip_path,exception); clip_path=DestroyString(clip_path); } @@ -3834,89 +3917,6 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image, % % % % % % -% D r a w I m a g e C l i p p i n g M a s k % -% % -% % -% % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% DrawImageClippingMask() draws the clip path and returns it as an image -% clipping mask. -% -% The format of the DrawImageClippingMask method is: -% -% Image *DrawImageClippingMask(Image *image,const DrawInfo *draw_info, -% const char *clip_path,ExceptionInfo *exception) -% -% A description of each parameter follows: -% -% o image: the image. -% -% o draw_info: the draw info. -% -% o clip_path: the clip path. -% -% o exception: return any errors or warnings in this structure. -% -*/ -static Image *DrawImageClippingMask(Image *image,const DrawInfo *draw_info, - const char *clip_path,ExceptionInfo *exception) -{ - Image - *clip_mask; - - DrawInfo - *clone_info; - - MagickStatusType - status; - - /* - Draw a clip path. - */ - assert(image != (Image *) NULL); - assert(image->signature == MagickCoreSignature); - if (image->debug != MagickFalse) - (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); - assert(draw_info != (const DrawInfo *) NULL); - clip_mask=CloneImage(image,image->columns,image->rows,MagickTrue,exception); - if (clip_mask == (Image *) NULL) - return((Image *) NULL); - (void) SetImageMask(clip_mask,ReadPixelMask,(Image *) NULL,exception); - (void) SetImageMask(clip_mask,WritePixelMask,(Image *) NULL,exception); - (void) QueryColorCompliance("#0000",AllCompliance, - &clip_mask->background_color,exception); - clip_mask->background_color.alpha=(MagickRealType) TransparentAlpha; - clip_mask->background_color.alpha_trait=BlendPixelTrait; - (void) SetImageBackgroundColor(clip_mask,exception); - if (image->debug != MagickFalse) - (void) LogMagickEvent(DrawEvent,GetMagickModule(),"\nbegin clip-path %s", - draw_info->clip_mask); - clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); - (void) CloneString(&clone_info->primitive,clip_path); - (void) QueryColorCompliance("#ffffff",AllCompliance,&clone_info->fill, - exception); - if (clone_info->clip_mask != (char *) NULL) - clone_info->clip_mask=DestroyString(clone_info->clip_mask); - (void) QueryColorCompliance("#00000000",AllCompliance,&clone_info->stroke, - exception); - clone_info->stroke_width=0.0; - clone_info->alpha=OpaqueAlpha; - clone_info->clip_path=MagickTrue; - status=DrawImage(clip_mask,clone_info,exception); - clone_info=DestroyDrawInfo(clone_info); - if (status == MagickFalse) - clip_mask=DestroyImage(clip_mask); - if (image->debug != MagickFalse) - (void) LogMagickEvent(DrawEvent,GetMagickModule(),"end clip-path"); - return(clip_mask); -} - -/* -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% % -% % -% % % D r a w P a t t e r n P a t h % % % % % @@ -5086,6 +5086,7 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image, } } image_view=DestroyCacheView(image_view); + status&=SetImageMask(image,WritePixelMask,(Image *) NULL,exception); if (image->debug != MagickFalse) (void) LogMagickEvent(DrawEvent,GetMagickModule()," end draw-primitive"); return(status != 0 ? MagickTrue : MagickFalse);