From: Cristy Date: Fri, 24 Jun 2016 16:46:10 +0000 (-0400) Subject: ... X-Git-Tag: 7.0.2-2~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=04a15690d451ac9c08c9a9b2ef6669fdf70c32e4;p=imagemagick ... --- diff --git a/MagickCore/draw.c b/MagickCore/draw.c index 4cb0353fe..f96a72c2e 100644 --- a/MagickCore/draw.c +++ b/MagickCore/draw.c @@ -89,7 +89,7 @@ Define declarations. */ #define BezierQuantum 200 -#define DrawEpsilon (1.0e-6) +#define DrawEpsilon (1.0e-7) /* @@ -311,7 +311,7 @@ MagickExport DrawInfo *CloneDrawInfo(const ImageInfo *image_info, register ssize_t x; - for (x=0; fabs(draw_info->dash_pattern[x]) >= DrawEpsilon; x++) ; + for (x=0; fabs(draw_info->dash_pattern[x]) >= MagickEpsilon; x++) ; clone_info->dash_pattern=(double *) AcquireQuantumMemory((size_t) x+1UL, sizeof(*clone_info->dash_pattern)); if (clone_info->dash_pattern == (double *) NULL) @@ -394,13 +394,13 @@ static int CompareEdges(const void *x,const void *y) */ p=(const EdgeInfo *) x; q=(const EdgeInfo *) y; - if ((p->points[0].y-DrawEpsilon) > q->points[0].y) + if ((p->points[0].y-MagickEpsilon) > q->points[0].y) return(1); - if ((p->points[0].y+DrawEpsilon) < q->points[0].y) + if ((p->points[0].y+MagickEpsilon) < q->points[0].y) return(-1); - if ((p->points[0].x-DrawEpsilon) > q->points[0].x) + if ((p->points[0].x-MagickEpsilon) > q->points[0].x) return(1); - if ((p->points[0].x+DrawEpsilon) < q->points[0].x) + if ((p->points[0].x+MagickEpsilon) < q->points[0].x) return(-1); if (((p->points[1].x-p->points[0].x)*(q->points[1].y-q->points[0].y)- (p->points[1].y-p->points[0].y)*(q->points[1].x-q->points[0].x)) > 0.0) @@ -766,8 +766,8 @@ static PathInfo *ConvertPrimitiveToPath(const PrimitiveInfo *primitive_info) /* Eliminate duplicate points. */ - if ((i == 0) || (fabs(q.x-primitive_info[i].point.x) >= DrawEpsilon) || - (fabs(q.y-primitive_info[i].point.y) >= DrawEpsilon)) + if ((i == 0) || (fabs(q.x-primitive_info[i].point.x) >= MagickEpsilon) || + (fabs(q.y-primitive_info[i].point.y) >= MagickEpsilon)) { path_info[n].code=code; path_info[n].point=primitive_info[i].point; @@ -776,8 +776,8 @@ static PathInfo *ConvertPrimitiveToPath(const PrimitiveInfo *primitive_info) } if (coordinates > 0) continue; - if ((fabs(p.x-primitive_info[i].point.x) < DrawEpsilon) && - (fabs(p.y-primitive_info[i].point.y) < DrawEpsilon)) + if ((fabs(p.x-primitive_info[i].point.x) < MagickEpsilon) && + (fabs(p.y-primitive_info[i].point.y) < MagickEpsilon)) continue; /* Mark the p point as open if it does not match the q. @@ -986,7 +986,7 @@ static SegmentInfo AffineEdge(const Image *image,const AffineMatrix *affine, inverse_edge.x2=edge->x2; inverse_edge.y2=edge->y2; z=affine->ry*y+affine->tx; - if (affine->sx >= DrawEpsilon) + if (affine->sx >= MagickEpsilon) { intercept=(-z/affine->sx); x=intercept; @@ -998,7 +998,7 @@ static SegmentInfo AffineEdge(const Image *image,const AffineMatrix *affine, inverse_edge.x2=x; } else - if (affine->sx < -DrawEpsilon) + if (affine->sx < -MagickEpsilon) { intercept=(-z+(double) image->columns)/affine->sx; x=intercept; @@ -1019,7 +1019,7 @@ static SegmentInfo AffineEdge(const Image *image,const AffineMatrix *affine, Determine top and bottom edges. */ z=affine->sy*y+affine->ty; - if (affine->rx >= DrawEpsilon) + if (affine->rx >= MagickEpsilon) { intercept=(-z/affine->rx); x=intercept; @@ -1031,7 +1031,7 @@ static SegmentInfo AffineEdge(const Image *image,const AffineMatrix *affine, inverse_edge.x2=x; } else - if (affine->rx < -DrawEpsilon) + if (affine->rx < -MagickEpsilon) { intercept=(-z+(double) image->rows)/affine->rx; x=intercept; @@ -1520,7 +1520,7 @@ static MagickBooleanType DrawDashPolygon(const DrawInfo *draw_info, dash_polygon[0]=primitive_info[0]; scale=ExpandAffine(&draw_info->affine); length=scale*(draw_info->dash_pattern[0]-0.5); - offset=fabs(draw_info->dash_offset) >= DrawEpsilon ? + offset=fabs(draw_info->dash_offset) >= MagickEpsilon ? scale*draw_info->dash_offset : 0.0; j=1; for (n=0; offset > 0.0; j=0) @@ -1552,10 +1552,10 @@ static MagickBooleanType DrawDashPolygon(const DrawInfo *draw_info, dx=primitive_info[i].point.x-primitive_info[i-1].point.x; dy=primitive_info[i].point.y-primitive_info[i-1].point.y; maximum_length=hypot((double) dx,dy); - if (fabs(length) < DrawEpsilon) + if (fabs(length) < MagickEpsilon) { n++; - if (fabs(draw_info->dash_pattern[n]) < DrawEpsilon) + if (fabs(draw_info->dash_pattern[n]) < MagickEpsilon) n=0; length=scale*(draw_info->dash_pattern[n]+(n == 0 ? -0.5 : 0.5)); } @@ -1587,7 +1587,7 @@ static MagickBooleanType DrawDashPolygon(const DrawInfo *draw_info, status&=DrawStrokePolygon(image,clone_info,dash_polygon,exception); } n++; - if (fabs(draw_info->dash_pattern[n]) < DrawEpsilon) + if (fabs(draw_info->dash_pattern[n]) < MagickEpsilon) n=0; length=scale*(draw_info->dash_pattern[n]+(n == 0 ? -0.5 : 0.5)); } @@ -1601,8 +1601,8 @@ static MagickBooleanType DrawDashPolygon(const DrawInfo *draw_info, if ((total_length <= maximum_length) && ((n & 0x01) == 0) && (j > 1)) { dash_polygon[j]=primitive_info[i-1]; - dash_polygon[j].point.x+=DrawEpsilon; - dash_polygon[j].point.y+=DrawEpsilon; + dash_polygon[j].point.x+=MagickEpsilon; + dash_polygon[j].point.y+=MagickEpsilon; dash_polygon[j].coordinates=1; j++; dash_polygon[0].coordinates=(size_t) j; @@ -1657,7 +1657,7 @@ static inline MagickBooleanType IsPoint(const char *point) value; value=StringToDouble(point,&p); - return((fabs(value) < DrawEpsilon) && (p == point) ? MagickFalse : MagickTrue); + return((fabs(value) < MagickEpsilon) && (p == point) ? MagickFalse : MagickTrue); } static inline void TracePoint(PrimitiveInfo *primitive_info, @@ -2841,12 +2841,12 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, } if (status == MagickFalse) break; - if ((fabs(affine.sx-1.0) >= DrawEpsilon) || - (fabs(affine.rx) >= DrawEpsilon) || - (fabs(affine.ry) >= DrawEpsilon) || - (fabs(affine.sy-1.0) >= DrawEpsilon) || - (fabs(affine.tx) >= DrawEpsilon) || - (fabs(affine.ty) >= DrawEpsilon)) + if ((fabs(affine.sx-1.0) >= MagickEpsilon) || + (fabs(affine.rx) >= MagickEpsilon) || + (fabs(affine.ry) >= MagickEpsilon) || + (fabs(affine.sy-1.0) >= MagickEpsilon) || + (fabs(affine.tx) >= MagickEpsilon) || + (fabs(affine.ty) >= MagickEpsilon)) { graphic_context[n]->affine.sx=current.sx*affine.sx+current.ry*affine.rx; graphic_context[n]->affine.rx=current.rx*affine.sx+current.sy*affine.rx; @@ -3362,7 +3362,7 @@ static int StopInfoCompare(const void *x,const void *y) stop_2=(StopInfo *) y; if (stop_1->offset > stop_2->offset) return(1); - if (fabs(stop_1->offset-stop_2->offset) <= DrawEpsilon) + if (fabs(stop_1->offset-stop_2->offset) <= MagickEpsilon) return(0); return(-1); } @@ -3872,7 +3872,7 @@ static double GetFillAlpha(PolygonInfo *polygon_info,const double mid, else { beta=1.0; - if (fabs(distance-1.0) >= DrawEpsilon) + if (fabs(distance-1.0) >= MagickEpsilon) beta=sqrt((double) distance); alpha=beta-mid-0.5; if (*stroke_alpha < ((alpha-0.25)*(alpha-0.25))) @@ -3889,10 +3889,10 @@ static double GetFillAlpha(PolygonInfo *polygon_info,const double mid, } if (distance > 1.0) continue; - if (fabs(beta) < DrawEpsilon) + if (fabs(beta) < MagickEpsilon) { beta=1.0; - if (fabs(distance-1.0) >= DrawEpsilon) + if (fabs(distance-1.0) >= MagickEpsilon) beta=sqrt(distance); } alpha=beta-1.0; @@ -4276,8 +4276,8 @@ static void LogPrimitiveInfo(const PrimitiveInfo *primitive_info) p=point; } point=primitive_info[i].point; - if ((fabs(q.x-point.x) >= DrawEpsilon) || - (fabs(q.y-point.y) >= DrawEpsilon)) + if ((fabs(q.x-point.x) >= MagickEpsilon) || + (fabs(q.y-point.y) >= MagickEpsilon)) (void) LogMagickEvent(DrawEvent,GetMagickModule(), " %.20g: %.18g,%.18g",(double) coordinates,point.x,point.y); else @@ -4287,8 +4287,8 @@ static void LogPrimitiveInfo(const PrimitiveInfo *primitive_info) coordinates--; if (coordinates > 0) continue; - if ((fabs(p.x-point.x) >= DrawEpsilon) || - (fabs(p.y-point.y) >= DrawEpsilon)) + if ((fabs(p.x-point.x) >= MagickEpsilon) || + (fabs(p.y-point.y) >= MagickEpsilon)) (void) LogMagickEvent(DrawEvent,GetMagickModule()," end last (%.20g)", (double) coordinates); else @@ -4693,8 +4693,8 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image, LogPrimitiveInfo(primitive_info); scale=ExpandAffine(&draw_info->affine); if ((draw_info->dash_pattern != (double *) NULL) && - (fabs(draw_info->dash_pattern[0]) >= DrawEpsilon) && - ((scale*draw_info->stroke_width) >= DrawEpsilon) && + (fabs(draw_info->dash_pattern[0]) >= MagickEpsilon) && + ((scale*draw_info->stroke_width) >= MagickEpsilon) && (draw_info->stroke.alpha != (Quantum) TransparentAlpha)) { /* @@ -4965,7 +4965,7 @@ MagickExport void GetDrawInfo(const ImageInfo *image_info,DrawInfo *draw_info) if (clone_info->density != (char *) NULL) draw_info->density=AcquireString(clone_info->density); draw_info->text_antialias=clone_info->antialias; - if (fabs(clone_info->pointsize) != DrawEpsilon) + if (fabs(clone_info->pointsize) != MagickEpsilon) draw_info->pointsize=clone_info->pointsize; draw_info->border_color=clone_info->border_color; if (clone_info->server_name != (char *) NULL) @@ -5138,7 +5138,7 @@ static void TraceArcPath(PrimitiveInfo *primitive_info,const PointInfo start, } radii.x=fabs(arc.x); radii.y=fabs(arc.y); - if ((fabs(radii.x) < DrawEpsilon) || (fabs(radii.y) < DrawEpsilon)) + if ((fabs(radii.x) < MagickEpsilon) || (fabs(radii.y) < MagickEpsilon)) { TraceLine(primitive_info,start,end); return; @@ -5149,7 +5149,7 @@ static void TraceArcPath(PrimitiveInfo *primitive_info,const PointInfo start, center.y=(double) (cosine*(end.y-start.y)/2-sine*(end.x-start.x)/2); delta=(center.x*center.x)/(radii.x*radii.x)+(center.y*center.y)/ (radii.y*radii.y); - if (delta < DrawEpsilon) + if (delta < MagickEpsilon) { TraceLine(primitive_info,start,end); return; @@ -5184,7 +5184,7 @@ static void TraceArcPath(PrimitiveInfo *primitive_info,const PointInfo start, if ((theta > 0.0) && (sweep == MagickFalse)) theta-=(double) (2.0*MagickPI); arc_segments=(size_t) ceil(fabs((double) (theta/(0.5*MagickPI+ - DrawEpsilon)))); + MagickEpsilon)))); p=primitive_info; for (i=0; i < (ssize_t) arc_segments; i++) { @@ -5370,7 +5370,7 @@ static void TraceEllipse(PrimitiveInfo *primitive_info,const PointInfo start, /* Ellipses are just short segmented polys. */ - if ((fabs(stop.x) < DrawEpsilon) && (fabs(stop.y) < DrawEpsilon)) + if ((fabs(stop.x) < MagickEpsilon) && (fabs(stop.y) < MagickEpsilon)) { TracePoint(primitive_info,start); return; @@ -5407,8 +5407,8 @@ static void TraceLine(PrimitiveInfo *primitive_info,const PointInfo start, const PointInfo end) { TracePoint(primitive_info,start); - if ((fabs(start.x-end.x) < DrawEpsilon) && - (fabs(start.y-end.y) < DrawEpsilon)) + if ((fabs(start.x-end.x) < MagickEpsilon) && + (fabs(start.y-end.y) < MagickEpsilon)) { primitive_info->primitive=PointPrimitive; primitive_info->coordinates=1; @@ -5901,8 +5901,8 @@ static void TraceSquareLinecap(PrimitiveInfo *primitive_info, { dx=primitive_info[0].point.x-primitive_info[i].point.x; dy=primitive_info[0].point.y-primitive_info[i].point.y; - if ((fabs((double) dx) >= DrawEpsilon) || - (fabs((double) dy) >= DrawEpsilon)) + if ((fabs((double) dx) >= MagickEpsilon) || + (fabs((double) dy) >= MagickEpsilon)) break; } if (i == (ssize_t) number_vertices) @@ -5916,8 +5916,8 @@ static void TraceSquareLinecap(PrimitiveInfo *primitive_info, { dx=primitive_info[number_vertices-1].point.x-primitive_info[j].point.x; dy=primitive_info[number_vertices-1].point.y-primitive_info[j].point.y; - if ((fabs((double) dx) >= DrawEpsilon) || - (fabs((double) dy) >= DrawEpsilon)) + if ((fabs((double) dx) >= MagickEpsilon) || + (fabs((double) dy) >= MagickEpsilon)) break; } distance=hypot((double) dx,(double) dy); @@ -6021,27 +6021,27 @@ static PrimitiveInfo *TraceStrokePolygon(const DrawInfo *draw_info, { dx.p=polygon_primitive[n].point.x-polygon_primitive[0].point.x; dy.p=polygon_primitive[n].point.y-polygon_primitive[0].point.y; - if ((fabs(dx.p) >= DrawEpsilon) || (fabs(dy.p) >= DrawEpsilon)) + if ((fabs(dx.p) >= MagickEpsilon) || (fabs(dy.p) >= MagickEpsilon)) break; } if (n == (ssize_t) number_vertices) n=(ssize_t) number_vertices-1L; slope.p=0.0; inverse_slope.p=0.0; - if (fabs(dx.p) < DrawEpsilon) + if (fabs(dx.p) < MagickEpsilon) { if (dx.p >= 0.0) - slope.p=dy.p < 0.0 ? -1.0/DrawEpsilon : 1.0/DrawEpsilon; + slope.p=dy.p < 0.0 ? -1.0/MagickEpsilon : 1.0/MagickEpsilon; else - slope.p=dy.p < 0.0 ? 1.0/DrawEpsilon : -1.0/DrawEpsilon; + slope.p=dy.p < 0.0 ? 1.0/MagickEpsilon : -1.0/MagickEpsilon; } else - if (fabs(dy.p) < DrawEpsilon) + if (fabs(dy.p) < MagickEpsilon) { if (dy.p >= 0.0) - inverse_slope.p=dx.p < 0.0 ? -1.0/DrawEpsilon : 1.0/DrawEpsilon; + inverse_slope.p=dx.p < 0.0 ? -1.0/MagickEpsilon : 1.0/MagickEpsilon; else - inverse_slope.p=dx.p < 0.0 ? 1.0/DrawEpsilon : -1.0/DrawEpsilon; + inverse_slope.p=dx.p < 0.0 ? 1.0/MagickEpsilon : -1.0/MagickEpsilon; } else { @@ -6096,20 +6096,20 @@ static PrimitiveInfo *TraceStrokePolygon(const DrawInfo *draw_info, continue; slope.q=0.0; inverse_slope.q=0.0; - if (fabs(dx.q) < DrawEpsilon) + if (fabs(dx.q) < MagickEpsilon) { if (dx.q >= 0.0) - slope.q=dy.q < 0.0 ? -1.0/DrawEpsilon : 1.0/DrawEpsilon; + slope.q=dy.q < 0.0 ? -1.0/MagickEpsilon : 1.0/MagickEpsilon; else - slope.q=dy.q < 0.0 ? 1.0/DrawEpsilon : -1.0/DrawEpsilon; + slope.q=dy.q < 0.0 ? 1.0/MagickEpsilon : -1.0/MagickEpsilon; } else - if (fabs(dy.q) < DrawEpsilon) + if (fabs(dy.q) < MagickEpsilon) { if (dy.q >= 0.0) - inverse_slope.q=dx.q < 0.0 ? -1.0/DrawEpsilon : 1.0/DrawEpsilon; + inverse_slope.q=dx.q < 0.0 ? -1.0/MagickEpsilon : 1.0/MagickEpsilon; else - inverse_slope.q=dx.q < 0.0 ? 1.0/DrawEpsilon : -1.0/DrawEpsilon; + inverse_slope.q=dx.q < 0.0 ? 1.0/MagickEpsilon : -1.0/MagickEpsilon; } else { @@ -6141,7 +6141,7 @@ static PrimitiveInfo *TraceStrokePolygon(const DrawInfo *draw_info, box_q[3].x=polygon_primitive[i].point.x-offset.x; box_q[3].y=polygon_primitive[i].point.y-offset.y; } - if (fabs((double) (slope.p-slope.q)) < DrawEpsilon) + if (fabs((double) (slope.p-slope.q)) < MagickEpsilon) { box_p[4]=box_p[1]; box_q[4]=box_q[1];