From c8788620f42bcb01d7a2fb06ff9465981ce5ec8d Mon Sep 17 00:00:00 2001 From: Cristy Date: Tue, 1 May 2018 15:58:57 -0400 Subject: [PATCH] ... --- MagickCore/draw.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/MagickCore/draw.c b/MagickCore/draw.c index a3460ba29..aa8ecda86 100644 --- a/MagickCore/draw.c +++ b/MagickCore/draw.c @@ -1808,7 +1808,7 @@ static inline MagickBooleanType IsPoint(const char *point) return((fabs(value) < DrawEpsilon) && (p == point) ? MagickFalse : MagickTrue); } -static size_t ReckonEllipseCoordinates(const PointInfo stop, +static size_t ReckonEllipseCoordinates(const PointInfo radii, const PointInfo degrees) { double @@ -1822,7 +1822,9 @@ static size_t ReckonEllipseCoordinates(const PointInfo stop, /* Ellipses are just short segmented polys. */ - delta=2.0*PerceptibleReciprocal(MagickMax(stop.x,stop.y)); + if ((fabs(radii.x) < MagickEpsilon) || (fabs(radii.y) < MagickEpsilon)) + return(0); + delta=2.0*PerceptibleReciprocal(MagickMax(radii.x,radii.y)); step=MagickPI/8.0; if ((delta >= 0.0) && (delta < (MagickPI/8.0))) step=MagickPI/(4.0*(MagickPI*PerceptibleReciprocal(delta)/2.0)); @@ -5726,7 +5728,7 @@ static void TraceCircle(PrimitiveInfo *primitive_info,const PointInfo start, } static void TraceEllipse(PrimitiveInfo *primitive_info,const PointInfo start, - const PointInfo stop,const PointInfo degrees) + const PointInfo radii,const PointInfo degrees) { double delta, @@ -5746,7 +5748,10 @@ static void TraceEllipse(PrimitiveInfo *primitive_info,const PointInfo start, /* Ellipses are just short segmented polys. */ - delta=2.0*PerceptibleReciprocal(MagickMax(stop.x,stop.y)); + primitive_info->coordinates=0; + if ((fabs(radii.x) < MagickEpsilon) || (fabs(radii.y) < MagickEpsilon)) + return; + delta=2.0*PerceptibleReciprocal(MagickMax(radii.x,radii.y)); step=MagickPI/8.0; if ((delta >= 0.0) && (delta < (MagickPI/8.0))) step=MagickPI/(4.0*(MagickPI*PerceptibleReciprocal(delta)/2.0)); @@ -5757,13 +5762,13 @@ static void TraceEllipse(PrimitiveInfo *primitive_info,const PointInfo start, angle.y=DegreesToRadians(y); for (p=primitive_info; angle.x < angle.y; angle.x+=step) { - point.x=cos(fmod(angle.x,DegreesToRadians(360.0)))*stop.x+start.x; - point.y=sin(fmod(angle.x,DegreesToRadians(360.0)))*stop.y+start.y; + point.x=cos(fmod(angle.x,DegreesToRadians(360.0)))*radii.x+start.x; + point.y=sin(fmod(angle.x,DegreesToRadians(360.0)))*radii.y+start.y; TracePoint(p,point); p+=p->coordinates; } - point.x=cos(fmod(angle.y,DegreesToRadians(360.0)))*stop.x+start.x; - point.y=sin(fmod(angle.y,DegreesToRadians(360.0)))*stop.y+start.y; + point.x=cos(fmod(angle.y,DegreesToRadians(360.0)))*radii.x+start.x; + point.y=sin(fmod(angle.y,DegreesToRadians(360.0)))*radii.y+start.y; TracePoint(p,point); p+=p->coordinates; primitive_info->coordinates=(size_t) (p-primitive_info); @@ -6266,6 +6271,12 @@ static void TraceRectangle(PrimitiveInfo *primitive_info,const PointInfo start, register ssize_t i; + if ((fabs(start.x-end.x) < DrawEpsilon) || + (fabs(start.y-end.y) < DrawEpsilon)) + { + primitive_info->coordinates=0; + return; + } p=primitive_info; TracePoint(p,start); p+=p->coordinates; @@ -6303,9 +6314,14 @@ static void TraceRoundRectangle(PrimitiveInfo *primitive_info, register ssize_t i; - p=primitive_info; offset.x=fabs(end.x-start.x); offset.y=fabs(end.y-start.y); + if ((offset.x < DrawEpsilon) || (offset.y < DrawEpsilon)) + { + primitive_info->coordinates=0; + return; + } + p=primitive_info; if (arc.x > (0.5*offset.x)) arc.x=0.5*offset.x; if (arc.y > (0.5*offset.y)) -- 2.40.0