% July 1998 %
% %
% %
-% Copyright 1999-2016 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2017 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
% obtain a copy of the License at %
% %
-% http://www.imagemagick.org/script/license.php %
+% https://www.imagemagick.org/script/license.php %
% %
% Unless required by applicable law or agreed to in writing, software %
% distributed under the License is distributed on an "AS IS" BASIS, %
clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
(void) QueryColorCompliance("#000F",AllCompliance,&clone_info->fill,
exception);
- resolution.x=DefaultResolution;
- resolution.y=DefaultResolution;
+ resolution.x=96.0;
+ resolution.y=96.0;
if (clone_info->density != (char *) NULL)
{
GeometryInfo
if ((flags & SigmaValue) == MagickFalse)
resolution.y=resolution.x;
}
- mid=(resolution.x/72.0)*ExpandAffine(&clone_info->affine)*
+ mid=(resolution.x/96.0)*ExpandAffine(&clone_info->affine)*
clone_info->stroke_width/2.0;
bounds.x1=0.0;
bounds.y1=0.0;
clip_mask=CloneImage(image,image->columns,image->rows,MagickTrue,exception);
if (clip_mask == (Image *) NULL)
return(MagickFalse);
- (void) QueryColorCompliance("#ffffff",AllCompliance,
+ (void) QueryColorCompliance("#0000",AllCompliance,
&clip_mask->background_color,exception);
clip_mask->background_color.alpha=(MagickRealType) TransparentAlpha;
(void) SetImageBackgroundColor(clip_mask,exception);
draw_info->clip_mask);
clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
(void) CloneString(&clone_info->primitive,value);
- (void) QueryColorCompliance("#000000",AllCompliance,&clone_info->fill,
+ (void) QueryColorCompliance("#ffffff",AllCompliance,&clone_info->fill,
exception);
- if (clone_info->clip_mask != (char *) NULL)
- clone_info->clip_mask=DestroyString(clone_info->clip_mask);
- status=DrawImage(clip_mask,clone_info,exception);
+ clone_info->clip_mask=(char *) NULL;
+ status=NegateImage(clip_mask,MagickFalse,exception);
(void) SetImageMask(image,ReadPixelMask,clip_mask,exception);
clip_mask=DestroyImage(clip_mask);
+ status&=DrawImage(image,clone_info,exception);
clone_info=DestroyDrawInfo(clone_info);
if (image->debug != MagickFalse)
(void) LogMagickEvent(DrawEvent,GetMagickModule(),"end clip-path");
double
angle,
factor,
+ points_extent,
primitive_extent;
DrawInfo
proceed;
MagickSizeType
- length,
number_points;
MagickStatusType
{
GetNextToken(q,&q,extent,token);
factor=strchr(token,'%') != (char *) NULL ? 0.01 : 1.0;
- graphic_context[n]->fill.alpha=QuantumRange-ClampToQuantum(
- (MagickRealType) QuantumRange*(1.0-factor*StringToDouble(token,
- &next_token)));
+ graphic_context[n]->fill.alpha=(MagickRealType) (QuantumRange-
+ ClampToQuantum((MagickRealType) QuantumRange*(1.0-factor*
+ StringToDouble(token,&next_token))));
if (token == next_token)
status=MagickFalse;
break;
{
GetNextToken(q,&q,extent,token);
factor=strchr(token,'%') != (char *) NULL ? 0.01 : 1.0;
+ graphic_context[n]->alpha=(Quantum) (QuantumRange*(1.0-
+ (QuantumScale*graphic_context[n]->alpha*(1.0-factor*
+ StringToDouble(token,&next_token)))));
graphic_context[n]->fill_alpha=QuantumRange*(1.0-(QuantumScale*
graphic_context[n]->fill_alpha*(1.0-factor*StringToDouble(token,
&next_token))));
{
GetNextToken(q,&q,extent,token);
factor=strchr(token,'%') != (char *) NULL ? 0.01 : 1.0;
- graphic_context[n]->stroke.alpha=QuantumRange-ClampToQuantum(
- (MagickRealType) QuantumRange*(1.0-factor*StringToDouble(token,
- &next_token)));
+ graphic_context[n]->stroke.alpha=(MagickRealType) (QuantumRange-
+ ClampToQuantum((MagickRealType) QuantumRange*(1.0-factor*
+ StringToDouble(token,&next_token))));
if (token == next_token)
status=MagickFalse;
break;
(size_t) number_points,sizeof(*primitive_info));
if ((primitive_info == (PrimitiveInfo *) NULL) ||
(number_points != (MagickSizeType) ((size_t) number_points)))
- {
- (void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
- break;
- }
+ ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
+ image->filename);
}
primitive_info[j].primitive=primitive_type;
primitive_info[j].coordinates=(size_t) x;
/*
Speculate how many points our primitive might consume.
*/
- length=primitive_info[j].coordinates;
+ points_extent=(double) primitive_info[j].coordinates;
switch (primitive_type)
{
case RectanglePrimitive:
{
- length*=5;
+ points_extent*=5;
break;
}
case RoundRectanglePrimitive:
alpha=bounds.x2-bounds.x1;
beta=bounds.y2-bounds.y1;
radius=hypot((double) alpha,(double) beta);
- length*=5;
- length+=2*((size_t) ceil((double) MagickPI*radius))+6*BezierQuantum+360;
+ points_extent*=5;
+ points_extent+=2*ceil((double) MagickPI*radius)+6*BezierQuantum+360;
break;
}
case BezierPrimitive:
if (primitive_info[j].coordinates > 107)
(void) ThrowMagickException(exception,GetMagickModule(),DrawError,
"TooManyBezierCoordinates","`%s'",token);
- length=BezierQuantum*primitive_info[j].coordinates;
+ points_extent=(double) (BezierQuantum*primitive_info[j].coordinates);
break;
}
case PathPrimitive:
*t;
GetNextToken(q,&q,extent,token);
- length=1;
+ points_extent=1;
t=token;
for (s=token; *s != '\0'; s=t)
{
t++;
continue;
}
- length++;
+ points_extent++;
}
- length=length*BezierQuantum;
+ points_extent=points_extent*BezierQuantum;
break;
}
case CirclePrimitive:
alpha=bounds.x2-bounds.x1;
beta=bounds.y2-bounds.y1;
radius=hypot((double) alpha,(double) beta);
- length=2*((size_t) ceil((double) MagickPI*radius))+6*BezierQuantum+360;
+ points_extent=2*ceil((double) MagickPI*radius)+6*BezierQuantum+360;
break;
}
default:
break;
}
- if ((i+length) >= number_points)
+ if (((double) ((size_t) points_extent)) < points_extent)
+ {
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
+ break;
+ }
+ if (((MagickSizeType) (i+points_extent)) >= number_points)
{
/*
Resize based on speculative points required by primitive.
*/
- number_points+=length+1;
+ number_points+=points_extent+1;
primitive_info=(PrimitiveInfo *) ResizeQuantumMemory(primitive_info,
(size_t) number_points,sizeof(*primitive_info));
if ((primitive_info == (PrimitiveInfo *) NULL) ||
(fabs(primitive_info[i-1].point.y-primitive_info[0].point.y) < DrawEpsilon) ?
MagickTrue : MagickFalse;
i=(ssize_t) primitive_info[0].coordinates;
- if (((closed_path != MagickFalse) &&
- (draw_info->linejoin == RoundJoin)) ||
- (primitive_info[i].primitive != UndefinedPrimitive))
- {
- (void) DrawPolygonPrimitive(image,draw_info,primitive_info,
- exception);
- break;
- }
- if (draw_info->linecap == RoundCap)
+ if ((((draw_info->linecap == RoundCap) ||
+ (closed_path != MagickFalse)) &&
+ (draw_info->linejoin == RoundJoin)) ||
+ (primitive_info[i].primitive != UndefinedPrimitive))
{
(void) DrawPolygonPrimitive(image,draw_info,primitive_info,
exception);
exception);
draw_info->stroke_width=1.0;
draw_info->fill_rule=EvenOddRule;
+ draw_info->alpha=OpaqueAlpha;
draw_info->fill_alpha=OpaqueAlpha;
draw_info->stroke_alpha=OpaqueAlpha;
- draw_info->alpha=OpaqueAlpha;
draw_info->linecap=ButtCap;
draw_info->linejoin=MiterJoin;
draw_info->miterlimit=10;
(fabs(primitive_info[number_vertices-1].point.x-primitive_info[0].point.x) < DrawEpsilon) &&
(fabs(primitive_info[number_vertices-1].point.y-primitive_info[0].point.y) < DrawEpsilon) ?
MagickTrue : MagickFalse;
- if ((draw_info->linejoin == RoundJoin) ||
- ((draw_info->linejoin == MiterJoin) && (closed_path != MagickFalse)))
+ if (((draw_info->linejoin == RoundJoin) ||
+ (draw_info->linejoin == MiterJoin)) && (closed_path != MagickFalse))
{
polygon_primitive[number_vertices]=primitive_info[1];
number_vertices++;