% %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% July 1998 %
% %
% %
-% Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 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 %
#include "MagickCore/blob.h"
#include "MagickCore/cache.h"
#include "MagickCore/cache-view.h"
+#include "MagickCore/channel.h"
#include "MagickCore/color.h"
#include "MagickCore/colorspace-private.h"
#include "MagickCore/composite.h"
Define declarations.
*/
#define BezierQuantum 200
-#define DrawEpsilon ((MagickRealType) 1.0e-12)
\f
/*
Typedef declarations.
SegmentInfo
bounds;
- MagickRealType
+ double
scanline;
PointInfo
typedef struct _ElementInfo
{
- MagickRealType
+ double
cx,
cy,
major,
static void
TraceArc(PrimitiveInfo *,const PointInfo,const PointInfo,const PointInfo),
TraceArcPath(PrimitiveInfo *,const PointInfo,const PointInfo,const PointInfo,
- const MagickRealType,const MagickBooleanType,const MagickBooleanType),
+ const double,const MagickBooleanType,const MagickBooleanType),
TraceBezier(PrimitiveInfo *,const size_t),
TraceCircle(PrimitiveInfo *,const PointInfo,const PointInfo),
TraceEllipse(PrimitiveInfo *,const PointInfo,const PointInfo,const PointInfo),
TraceRectangle(PrimitiveInfo *,const PointInfo,const PointInfo),
TraceRoundRectangle(PrimitiveInfo *,const PointInfo,const PointInfo,
PointInfo),
- TraceSquareLinecap(PrimitiveInfo *,const size_t,const MagickRealType);
+ TraceSquareLinecap(PrimitiveInfo *,const size_t,const double);
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% CloneDrawInfo() makes a copy of the given draw_info structure. If NULL
-% is specified, a new draw_info structure is created initialized to
-% default values, according to the given image_info.
+% is specified, a new DrawInfo structure is created initialized to default
+% values.
%
% The format of the CloneDrawInfo method is:
%
*/
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)
next_direction=((path_info[i].point.y > point.y) ||
((path_info[i].point.y == point.y) &&
(path_info[i].point.x > point.x))) ? 1 : -1;
- if ((direction != 0) && (direction != next_direction))
+ if ((points != (PointInfo *) NULL) && (direction != 0) &&
+ (direction != next_direction))
{
/*
New edge.
/*
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;
}
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.
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;
inverse_edge.x2=x;
}
else
- if (affine->sx < -DrawEpsilon)
+ if (affine->sx < -MagickEpsilon)
{
intercept=(-z+(double) image->columns)/affine->sx;
x=intercept;
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;
inverse_edge.x2=x;
}
else
- if (affine->rx < -DrawEpsilon)
+ if (affine->rx < -MagickEpsilon)
{
intercept=(-z+(double) image->rows)/affine->rx;
x=intercept;
return(inverse_edge);
}
-static inline MagickRealType DrawEpsilonReciprocal(const MagickRealType x)
-{
- MagickRealType sign = x < (MagickRealType) 0.0 ? (MagickRealType) -1.0 :
- (MagickRealType) 1.0;
- return((sign*x) >= DrawEpsilon ? (MagickRealType) 1.0/x : sign*(
- (MagickRealType) 1.0/DrawEpsilon));
-}
-
static AffineMatrix InverseAffineMatrix(const AffineMatrix *affine)
{
AffineMatrix
double
determinant;
- determinant=DrawEpsilonReciprocal(affine->sx*affine->sy-affine->rx*
+ determinant=PerceptibleReciprocal(affine->sx*affine->sy-affine->rx*
affine->ry);
inverse_affine.sx=determinant*affine->sy;
inverse_affine.rx=determinant*(-affine->rx);
SegmentInfo
edge;
- size_t
- height,
- width;
-
ssize_t
start,
stop,
inverse_affine=InverseAffineMatrix(affine);
GetPixelInfo(image,&zero);
start=(ssize_t) ceil(edge.y1-0.5);
- stop=(ssize_t) ceil(edge.y2-0.5);
- height=(size_t) (floor(edge.y2+0.5)-ceil(edge.y1-0.5));
- width=(size_t) (floor(edge.x2+0.5)-ceil(edge.x1-0.5));
+ stop=(ssize_t) floor(edge.y2+0.5);
source_view=AcquireVirtualCacheView(source,exception);
image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(static) shared(status) \
- dynamic_number_threads(image,width,height,1)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ magick_threads(source,image,1,1)
#endif
for (y=start; y <= stop; y++)
{
if (inverse_edge.x2 < inverse_edge.x1)
continue;
q=GetCacheViewAuthenticPixels(image_view,(ssize_t) ceil(inverse_edge.x1-
- 0.5),y,(size_t) ((ssize_t) floor(inverse_edge.x2+0.5)-(ssize_t) floor(
- inverse_edge.x1+0.5)+1),1,exception);
+ 0.5),y,(size_t) (floor(inverse_edge.x2+0.5)-ceil(inverse_edge.x1-0.5)+1),
+ 1,exception);
if (q == (Quantum *) NULL)
continue;
pixel=zero;
DrawInfo
*clone_info;
- MagickRealType
+ double
mid;
PointInfo
status=NegateImage(clip_mask,MagickFalse,exception);
(void) SetImageMask(image,clip_mask,exception);
clip_mask=DestroyImage(clip_mask);
+ status&=DrawImage(image,clone_info,exception);
clone_info=DestroyDrawInfo(clone_info);
- status=DrawImage(image,clone_info,exception);
if (image->debug != MagickFalse)
(void) LogMagickEvent(DrawEvent,GetMagickModule(),"end clip-path");
return(status != 0 ? MagickTrue : MagickFalse);
DrawInfo
*clone_info;
- MagickRealType
+ double
length,
maximum_length,
offset,
register ssize_t
i;
- register MagickRealType
+ register double
dx,
dy;
{
offset-=length;
n++;
- length=scale*(draw_info->dash_pattern[n]+(n == 0 ? -0.5 : 0.5));
+ length=scale*(draw_info->dash_pattern[n]+0.5);
continue;
}
if (offset < length)
j++;
dash_polygon[0].coordinates=(size_t) j;
dash_polygon[j].primitive=UndefinedPrimitive;
- status|=DrawStrokePolygon(image,clone_info,dash_polygon,exception);
+ status&=DrawStrokePolygon(image,clone_info,dash_polygon,exception);
}
n++;
if (draw_info->dash_pattern[n] == 0.0)
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;
dash_polygon[j].primitive=UndefinedPrimitive;
- status|=DrawStrokePolygon(image,clone_info,dash_polygon,exception);
+ status&=DrawStrokePolygon(image,clone_info,dash_polygon,exception);
}
dash_polygon=(PrimitiveInfo *) RelinquishMagickMemory(dash_polygon);
clone_info=DestroyDrawInfo(clone_info);
**graphic_context;
MagickBooleanType
- proceed,
+ proceed;
+
+ MagickStatusType
status;
- MagickRealType
+ double
angle,
factor,
primitive_extent;
if (*draw_info->primitive != '@')
primitive=AcquireString(draw_info->primitive);
else
- primitive=FileToString(draw_info->primitive+1,~0,exception);
+ primitive=FileToString(draw_info->primitive+1,~0UL,exception);
if (primitive == (char *) NULL)
return(MagickFalse);
- primitive_extent=(MagickRealType) strlen(primitive);
+ primitive_extent=(double) strlen(primitive);
(void) SetImageArtifact(image,"MVG",primitive);
n=0;
/*
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
image->filename);
}
- number_points=2047;
+ number_points=6553;
primitive_info=(PrimitiveInfo *) AcquireQuantumMemory((size_t) number_points,
sizeof(*primitive_info));
if (primitive_info == (PrimitiveInfo *) NULL)
graphic_context[n]->decorate=(DecorationType) decorate;
break;
}
+ if (LocaleCompare("direction",keyword) == 0)
+ {
+ ssize_t
+ direction;
+
+ GetMagickToken(q,&q,token);
+ direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
+ token);
+ if (direction == -1)
+ status=MagickFalse;
+ else
+ graphic_context[n]->direction=(DirectionType) direction;
+ break;
+ }
status=MagickFalse;
break;
}
&graphic_context[n]->fill_pattern,exception);
else
{
- status=QueryColorCompliance(token,AllCompliance,
+ status&=QueryColorCompliance(token,AllCompliance,
&graphic_context[n]->fill,exception);
if (status == MagickFalse)
{
{
GetMagickToken(q,&q,token);
factor=strchr(token,'%') != (char *) NULL ? 0.01 : 1.0;
- graphic_context[n]->fill.alpha=(MagickRealType) QuantumRange*
+ graphic_context[n]->fill.alpha=(double) QuantumRange*
factor*StringToDouble(token,(char **) NULL);
break;
}
if (n <= 0)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- DrawError,"UnbalancedGraphicContextPushPop","'%s'",token);
+ DrawError,"UnbalancedGraphicContextPushPop","`%s'",token);
n=0;
break;
}
if (graphic_context == (DrawInfo **) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","'%s'",
+ ResourceLimitError,"MemoryAllocationFailed","`%s'",
image->filename);
break;
}
&graphic_context[n]->stroke_pattern,exception);
else
{
- status=QueryColorCompliance(token,AllCompliance,
+ status&=QueryColorCompliance(token,AllCompliance,
&graphic_context[n]->stroke,exception);
if (status == MagickFalse)
{
if (graphic_context[n]->dash_pattern == (double *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","'%s'",
+ ResourceLimitError,"MemoryAllocationFailed","`%s'",
image->filename);
break;
}
{
GetMagickToken(q,&q,token);
factor=strchr(token,'%') != (char *) NULL ? 0.01 : 1.0;
- graphic_context[n]->stroke.alpha=(MagickRealType) QuantumRange*
+ graphic_context[n]->stroke.alpha=(double) QuantumRange*
factor*StringToDouble(token,(char **) NULL);
break;
}
if (primitive_info == (PrimitiveInfo *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","'%s'",image->filename);
+ ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
break;
}
}
{
if (primitive_info[j].coordinates > 107)
(void) ThrowMagickException(exception,GetMagickModule(),DrawError,
- "TooManyBezierCoordinates","'%s'",token);
+ "TooManyBezierCoordinates","`%s'",token);
length=BezierQuantum*primitive_info[j].coordinates;
break;
}
case ArcPrimitive:
case EllipsePrimitive:
{
- MagickRealType
+ double
alpha,
beta,
radius;
if (primitive_info == (PrimitiveInfo *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","'%s'",
+ ResourceLimitError,"MemoryAllocationFailed","`%s'",
image->filename);
break;
}
if ((n != 0) && (graphic_context[n]->clip_mask != (char *) NULL) &&
(LocaleCompare(graphic_context[n]->clip_mask,
graphic_context[n-1]->clip_mask) != 0))
- (void) DrawClipPath(image,graphic_context[n],
+ status&=DrawClipPath(image,graphic_context[n],
graphic_context[n]->clip_mask,exception);
- (void) DrawPrimitive(image,graphic_context[n],primitive_info,exception);
+ status&=DrawPrimitive(image,graphic_context[n],primitive_info,
+ exception);
}
if (primitive_info->text != (char *) NULL)
primitive_info->text=(char *) RelinquishMagickMemory(
primitive_extent);
if (proceed == MagickFalse)
break;
+ if (status == 0)
+ break;
}
if (image->debug != MagickFalse)
(void) LogMagickEvent(DrawEvent,GetMagickModule(),"end draw-image");
if (status == MagickFalse)
ThrowBinaryException(DrawError,"NonconformingDrawingPrimitiveDefinition",
keyword);
- return(status);
+ return(status != 0 ? MagickTrue : MagickFalse);
}
\f
/*
%
*/
-static inline MagickRealType GetStopColorOffset(const GradientInfo *gradient,
+static inline double GetStopColorOffset(const GradientInfo *gradient,
const ssize_t x,const ssize_t y)
{
switch (gradient->type)
case UndefinedGradient:
case LinearGradient:
{
- MagickRealType
+ double
gamma,
length,
offset,
q.y=(double) y-gradient_vector->y1;
length=sqrt(q.x*q.x+q.y*q.y);
gamma=sqrt(p.x*p.x+p.y*p.y)*length;
- gamma=DrawEpsilonReciprocal(gamma);
+ gamma=PerceptibleReciprocal(gamma);
scale=p.x*q.x+p.y*q.y;
offset=gamma*scale*length;
return(offset);
}
case RadialGradient:
{
- MagickRealType
+ double
length,
offset;
const SegmentInfo
*gradient_vector;
+ double
+ length;
+
MagickBooleanType
status;
PixelInfo
zero;
- MagickRealType
- length;
-
PointInfo
point;
RectangleInfo
bounding_box;
- size_t
- height,
- width;
-
ssize_t
y;
bounding_box=gradient->bounding_box;
status=MagickTrue;
GetPixelInfo(image,&zero);
- height=bounding_box.height-bounding_box.y;
- width=bounding_box.width-bounding_box.x;
image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(static) shared(status) \
- dynamic_number_threads(image,width,height,1)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ magick_threads(image,image,1,1)
#endif
for (y=bounding_box.y; y < (ssize_t) bounding_box.height; y++)
{
composite,
pixel;
- MagickRealType
+ double
alpha,
offset;
MagickBooleanType
antialias;
- MagickRealType
+ double
repeat;
antialias=MagickFalse;
image_info->size=AcquireString(geometry);
*pattern=AcquireImage(image_info,exception);
image_info=DestroyImageInfo(image_info);
- (void) QueryColorCompliance("#00000000",AllCompliance,
+ (void) QueryColorCompliance("#000000ff",AllCompliance,
&(*pattern)->background_color,exception);
(void) SetImageBackgroundColor(*pattern,exception);
if (image->debug != MagickFalse)
size_t
number_threads;
- number_threads=GetOpenMPMaximumThreads();
+ number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
polygon_info=(PolygonInfo **) AcquireQuantumMemory(number_threads,
sizeof(*polygon_info));
if (polygon_info == (PolygonInfo **) NULL)
return(polygon_info);
}
-static MagickRealType GetFillAlpha(PolygonInfo *polygon_info,
- const MagickRealType mid,const MagickBooleanType fill,
- const FillRule fill_rule,const double x,const double y,
- MagickRealType *stroke_alpha)
+static double GetFillAlpha(PolygonInfo *polygon_info,const double mid,
+ const MagickBooleanType fill,const FillRule fill_rule,const ssize_t x,
+ const ssize_t y,double *stroke_alpha)
{
- MagickRealType
+ double
alpha,
beta,
distance,
PointInfo
delta;
- register EdgeInfo
- *p;
-
register const PointInfo
*q;
+ register EdgeInfo
+ *p;
+
register ssize_t
i;
p=polygon_info->edges;
for (j=0; j < (ssize_t) polygon_info->number_edges; j++, p++)
{
- if (y <= (p->bounds.y1-mid-0.5))
+ if ((double) y <= (p->bounds.y1-mid-0.5))
break;
- if (y > (p->bounds.y2+mid+0.5))
+ if ((double) y > (p->bounds.y2+mid+0.5))
{
(void) DestroyEdge(polygon_info,(size_t) j);
continue;
}
- if ((x <= (p->bounds.x1-mid-0.5)) || (x > (p->bounds.x2+mid+0.5)))
+ if (((double) x <= (p->bounds.x1-mid-0.5)) ||
+ ((double) x > (p->bounds.x2+mid+0.5)))
continue;
i=(ssize_t) MagickMax((double) p->highwater,1.0);
for ( ; i < (ssize_t) p->number_points; i++)
{
- if (y <= (p->points[i-1].y-mid-0.5))
+ if ((double) y <= (p->points[i-1].y-mid-0.5))
break;
- if (y > (p->points[i].y+mid+0.5))
+ if ((double) y > (p->points[i].y+mid+0.5))
continue;
- if (p->scanline != y)
+ if (p->scanline != (double) y)
{
- p->scanline=y;
+ p->scanline=(double) y;
p->highwater=(size_t) i;
}
/*
beta=delta.x*(x-q->x)+delta.y*(y-q->y);
if (beta < 0.0)
{
- delta.x=x-q->x;
- delta.y=y-q->y;
+ delta.x=(double) x-q->x;
+ delta.y=(double) y-q->y;
distance=delta.x*delta.x+delta.y*delta.y;
}
else
alpha=delta.x*delta.x+delta.y*delta.y;
if (beta > alpha)
{
- delta.x=x-(q+1)->x;
- delta.y=y-(q+1)->y;
+ delta.x=(double) x-(q+1)->x;
+ delta.y=(double) y-(q+1)->y;
distance=delta.x*delta.x+delta.y*delta.y;
}
else
p=polygon_info->edges;
for (j=0; j < (ssize_t) polygon_info->number_edges; j++, p++)
{
- if (y <= p->bounds.y1)
+ if ((double) y <= p->bounds.y1)
break;
- if ((y > p->bounds.y2) || (x <= p->bounds.x1))
+ if (((double) y > p->bounds.y2) || ((double) x <= p->bounds.x1))
continue;
- if (x > p->bounds.x2)
+ if ((double) x > p->bounds.x2)
{
winding_number+=p->direction ? 1 : -1;
continue;
}
i=(ssize_t) MagickMax((double) p->highwater,1.0);
for ( ; i < (ssize_t) p->number_points; i++)
- if (y <= p->points[i].y)
+ if ((double) y <= p->points[i].y)
break;
q=p->points+i-1;
if ((((q+1)->x-q->x)*(y-q->y)) <= (((q+1)->y-q->y)*(x-q->x)))
fill,
status;
- MagickRealType
+ double
mid;
PolygonInfo
SegmentInfo
bounds;
- size_t
- height,
- width;
-
ssize_t
start,
stop,
polygon_info=AcquirePolygonThreadSet(draw_info,primitive_info);
if (polygon_info == (PolygonInfo **) NULL)
return(MagickFalse);
+DisableMSCWarning(4127)
if (0)
DrawBoundingRectangles(image,draw_info,polygon_info[0],exception);
+RestoreMSCWarning
if (image->debug != MagickFalse)
(void) LogMagickEvent(DrawEvent,GetMagickModule()," begin draw-polygon");
fill=(primitive_info->method == FillToBorderMethod) ||
}
bounds.x1-=(mid+1.0);
bounds.x1=bounds.x1 < 0.0 ? 0.0 : (size_t) ceil(bounds.x1-0.5) >=
- image->columns ? (double) image->columns-1.0 : bounds.x1;
+ image->columns ? (double) image->columns-1 : bounds.x1;
bounds.y1-=(mid+1.0);
bounds.y1=bounds.y1 < 0.0 ? 0.0 : (size_t) ceil(bounds.y1-0.5) >=
- image->rows ? (double) image->rows-1.0 : bounds.y1;
+ image->rows ? (double) image->rows-1 : bounds.y1;
bounds.x2+=(mid+1.0);
bounds.x2=bounds.x2 < 0.0 ? 0.0 : (size_t) floor(bounds.x2+0.5) >=
- image->columns ? (double) image->columns-1.0 : bounds.x2;
+ image->columns ? (double) image->columns-1 : bounds.x2;
bounds.y2+=(mid+1.0);
bounds.y2=bounds.y2 < 0.0 ? 0.0 : (size_t) floor(bounds.y2+0.5) >=
- image->rows ? (double) image->rows-1.0 : bounds.y2;
+ image->rows ? (double) image->rows-1 : bounds.y2;
status=MagickTrue;
image_view=AcquireAuthenticCacheView(image,exception);
- height=(size_t) (floor(bounds.y2+0.5)-ceil(bounds.y1-0.5));
- width=(size_t) (floor(bounds.x2+0.5)-ceil(bounds.x1-0.5));
if (primitive_info->coordinates == 1)
{
/*
start=(ssize_t) ceil(bounds.y1-0.5);
stop=(ssize_t) floor(bounds.y2+0.5);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(static) shared(status) \
- dynamic_number_threads(image,width,height,1)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ magick_threads(image,image,1,1)
#endif
for (y=start; y <= stop; y++)
{
start=(ssize_t) ceil(bounds.x1-0.5);
stop=(ssize_t) floor(bounds.x2+0.5);
x=start;
- q=GetCacheViewAuthenticPixels(image_view,x,y,(size_t) (stop-x+1),
- 1,exception);
+ q=GetCacheViewAuthenticPixels(image_view,x,y,(size_t) (stop-x+1),1,
+ exception);
if (q == (Quantum *) NULL)
{
status=MagickFalse;
/*
Draw polygon or line.
*/
- if (image->matte == MagickFalse)
+ if (image->alpha_trait != BlendPixelTrait)
(void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
start=(ssize_t) ceil(bounds.y1-0.5);
stop=(ssize_t) floor(bounds.y2+0.5);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(static) shared(status) \
- dynamic_number_threads(image,width,height,1)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ magick_threads(image,image,1,1)
#endif
for (y=start; y <= stop; y++)
{
const int
id = GetOpenMPThreadId();
- MagickRealType
+ double
fill_alpha,
stroke_alpha;
Fill and/or stroke.
*/
fill_alpha=GetFillAlpha(polygon_info[id],mid,fill,draw_info->fill_rule,
- (double) x,(double) y,&stroke_alpha);
+ x,y,&stroke_alpha);
if (draw_info->stroke_antialias == MagickFalse)
{
fill_alpha=fill_alpha > 0.25 ? 1.0 : 0.0;
}
(void) GetFillColor(draw_info,x,y,&fill_color,exception);
fill_alpha=fill_alpha*fill_color.alpha;
- CompositePixelOver(image,&fill_color,fill_alpha,q,(MagickRealType)
+ CompositePixelOver(image,&fill_color,fill_alpha,q,(double)
GetPixelAlpha(image,q),q);
(void) GetStrokeColor(draw_info,x,y,&stroke_color,exception);
stroke_alpha=stroke_alpha*stroke_color.alpha;
- CompositePixelOver(image,&stroke_color,stroke_alpha,q,(MagickRealType)
+ CompositePixelOver(image,&stroke_color,stroke_alpha,q,(double)
GetPixelAlpha(image,q),q);
q+=GetPixelChannels(image);
}
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
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
if (q == (Quantum *) NULL)
break;
(void) GetFillColor(draw_info,x,y,&fill_color,exception);
- CompositePixelOver(image,&fill_color,(MagickRealType) fill_color.alpha,q,
- (MagickRealType) GetPixelAlpha(image,q),q);
+ CompositePixelOver(image,&fill_color,(double) fill_color.alpha,q,
+ (double) GetPixelAlpha(image,q),q);
(void) SyncCacheViewAuthenticPixels(image_view,exception);
break;
}
&target,exception);
if (primitive_info->method == FillToBorderMethod)
{
- target.red=(MagickRealType) draw_info->border_color.red;
- target.green=(MagickRealType) draw_info->border_color.green;
- target.blue=(MagickRealType) draw_info->border_color.blue;
+ target.red=(double) draw_info->border_color.red;
+ target.green=(double) draw_info->border_color.green;
+ target.blue=(double) draw_info->border_color.blue;
}
- (void) FloodfillPaintImage(image,draw_info,&target,x,y,
+ status&=FloodfillPaintImage(image,draw_info,&target,x,y,
primitive_info->method == FloodfillMethod ? MagickFalse :
MagickTrue,exception);
break;
}
case MattePrimitive:
{
- if (image->matte == MagickFalse)
+ if (image->alpha_trait != BlendPixelTrait)
(void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
switch (primitive_info->method)
{
&target,exception);
if (primitive_info->method == FillToBorderMethod)
{
- target.red=(MagickRealType) draw_info->border_color.red;
- target.green=(MagickRealType) draw_info->border_color.green;
- target.blue=(MagickRealType) draw_info->border_color.blue;
+ target.red=(double) draw_info->border_color.red;
+ target.green=(double) draw_info->border_color.green;
+ target.blue=(double) draw_info->border_color.blue;
}
- channel_mask=SetPixelChannelMask(image,AlphaChannel);
- (void) FloodfillPaintImage(image,draw_info,&target,x,y,
+ channel_mask=SetImageChannelMask(image,AlphaChannel);
+ status&=FloodfillPaintImage(image,draw_info,&target,x,y,
primitive_info->method == FloodfillMethod ? MagickFalse :
MagickTrue,exception);
- (void) SetPixelChannelMask(image,channel_mask);
+ (void) SetImageChannelMask(image,channel_mask);
break;
}
case ResetMethod:
(void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
primitive_info->point.x,primitive_info->point.y);
(void) CloneString(&clone_info->geometry,geometry);
- status=AnnotateImage(image,clone_info,exception);
+ status&=AnnotateImage(image,clone_info,exception);
clone_info=DestroyDrawInfo(clone_info);
break;
}
(void) TransformImage(&composite_image,(char *) NULL,geometry,
exception);
}
- if (composite_image->matte == MagickFalse)
+ if (composite_image->alpha_trait != BlendPixelTrait)
(void) SetImageAlphaChannel(composite_image,OpaqueAlphaChannel,
exception);
if (draw_info->alpha != OpaqueAlpha)
}
default:
{
- MagickRealType
+ double
mid,
scale;
scale=ExpandAffine(&draw_info->affine);
if ((draw_info->dash_pattern != (double *) NULL) &&
(draw_info->dash_pattern[0] != 0.0) &&
- ((scale*draw_info->stroke_width) >= DrawEpsilon) &&
+ ((scale*draw_info->stroke_width) >= MagickEpsilon) &&
(draw_info->stroke.alpha != (Quantum) TransparentAlpha))
{
/*
clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
clone_info->stroke_width=0.0;
clone_info->stroke.alpha=(Quantum) TransparentAlpha;
- status=DrawPolygonPrimitive(image,clone_info,primitive_info,
+ status&=DrawPolygonPrimitive(image,clone_info,primitive_info,
exception);
clone_info=DestroyDrawInfo(clone_info);
(void) DrawDashPolygon(draw_info,primitive_info,image,exception);
clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
clone_info->stroke_width=0.0;
clone_info->stroke.alpha=(Quantum) TransparentAlpha;
- status=DrawPolygonPrimitive(image,clone_info,primitive_info,
+ status&=DrawPolygonPrimitive(image,clone_info,primitive_info,
exception);
clone_info=DestroyDrawInfo(clone_info);
- status|=DrawStrokePolygon(image,draw_info,primitive_info,exception);
+ status&=DrawStrokePolygon(image,draw_info,primitive_info,exception);
break;
}
- status=DrawPolygonPrimitive(image,draw_info,primitive_info,exception);
+ status&=DrawPolygonPrimitive(image,draw_info,primitive_info,exception);
break;
}
}
for (i=0; i < 4; i++)
linecap[i]=(*primitive_info);
linecap[0].coordinates=4;
- linecap[1].point.x+=(double) (10.0*DrawEpsilon);
- linecap[2].point.x+=(double) (10.0*DrawEpsilon);
- linecap[2].point.y+=(double) (10.0*DrawEpsilon);
- linecap[3].point.y+=(double) (10.0*DrawEpsilon);
+ linecap[1].point.x+=(double) (10.0*MagickEpsilon);
+ linecap[2].point.x+=(double) (10.0*MagickEpsilon);
+ linecap[2].point.y+=(double) (10.0*MagickEpsilon);
+ linecap[3].point.y+=(double) (10.0*MagickEpsilon);
linecap[4].primitive=UndefinedPrimitive;
(void) DrawPolygonPrimitive(image,draw_info,linecap,exception);
}
*clone_info;
MagickBooleanType
- closed_path,
+ closed_path;
+
+ MagickStatusType
status;
PrimitiveInfo
for (p=primitive_info; p->primitive != UndefinedPrimitive; p+=p->coordinates)
{
stroke_polygon=TraceStrokePolygon(draw_info,p);
- status=DrawPolygonPrimitive(image,clone_info,stroke_polygon,exception);
+ status&=DrawPolygonPrimitive(image,clone_info,stroke_polygon,exception);
+ if (status == 0)
+ break;
stroke_polygon=(PrimitiveInfo *) RelinquishMagickMemory(stroke_polygon);
q=p+p->coordinates-1;
closed_path=(q->point.x == p->point.x) && (q->point.y == p->point.y) ?
if (image->debug != MagickFalse)
(void) LogMagickEvent(DrawEvent,GetMagickModule(),
" end draw-stroke-polygon");
- return(status);
+ return(status != 0 ? MagickTrue : MagickFalse);
}
\f
/*
exception=AcquireExceptionInfo();
(void) QueryColorCompliance("#000F",AllCompliance,&draw_info->fill,
exception);
- (void) QueryColorCompliance("#FFF0",AllCompliance,&draw_info->stroke,
+ (void) QueryColorCompliance("#FFFF",AllCompliance,&draw_info->stroke,
exception);
draw_info->stroke_width=1.0;
draw_info->alpha=OpaqueAlpha;
%
%
*/
-static inline MagickRealType Permutate(const ssize_t n,const ssize_t k)
+static inline double Permutate(const ssize_t n,const ssize_t k)
{
- MagickRealType
+ double
r;
register ssize_t
}
static void TraceArcPath(PrimitiveInfo *primitive_info,const PointInfo start,
- const PointInfo end,const PointInfo arc,const MagickRealType angle,
+ const PointInfo end,const PointInfo arc,const double angle,
const MagickBooleanType large_arc,const MagickBooleanType sweep)
{
- MagickRealType
+ double
alpha,
beta,
delta,
points[3],
radii;
- register MagickRealType
+ register double
cosine,
sine;
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;
points[1].y=(double) (cosine*end.y/radii.y-sine*end.x/radii.y);
alpha=points[1].x-points[0].x;
beta=points[1].y-points[0].y;
- factor=DrawEpsilonReciprocal(alpha*alpha+beta*beta)-0.25;
+ factor=PerceptibleReciprocal(alpha*alpha+beta*beta)-0.25;
if (factor <= 0.0)
factor=0.0;
else
alpha=atan2(points[0].y-center.y,points[0].x-center.x);
theta=atan2(points[1].y-center.y,points[1].x-center.x)-alpha;
if ((theta < 0.0) && (sweep != MagickFalse))
- theta+=(MagickRealType) (2.0*MagickPI);
+ theta+=(double) (2.0*MagickPI);
else
if ((theta > 0.0) && (sweep == MagickFalse))
- theta-=(MagickRealType) (2.0*MagickPI);
+ 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++)
{
static void TraceBezier(PrimitiveInfo *primitive_info,
const size_t number_coordinates)
{
- MagickRealType
+ double
alpha,
*coefficients,
weight;
for (j=i+1; j < (ssize_t) number_coordinates; j++)
{
alpha=fabs(primitive_info[j].point.x-primitive_info[i].point.x);
- if (alpha > (MagickRealType) quantum)
+ if (alpha > (double) quantum)
quantum=(size_t) alpha;
alpha=fabs(primitive_info[j].point.y-primitive_info[i].point.y);
- if (alpha > (MagickRealType) quantum)
+ if (alpha > (double) quantum)
quantum=(size_t) alpha;
}
}
quantum=(size_t) MagickMin((double) quantum/number_coordinates,
(double) BezierQuantum);
control_points=quantum*number_coordinates;
- coefficients=(MagickRealType *) AcquireQuantumMemory((size_t)
+ coefficients=(double *) AcquireQuantumMemory((size_t)
number_coordinates,sizeof(*coefficients));
points=(PointInfo *) AcquireQuantumMemory((size_t) control_points,
sizeof(*points));
- if ((coefficients == (MagickRealType *) NULL) ||
+ if ((coefficients == (double *) NULL) ||
(points == (PointInfo *) NULL))
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
/*
p--;
}
points=(PointInfo *) RelinquishMagickMemory(points);
- coefficients=(MagickRealType *) RelinquishMagickMemory(coefficients);
+ coefficients=(double *) RelinquishMagickMemory(coefficients);
}
static void TraceCircle(PrimitiveInfo *primitive_info,const PointInfo start,
const PointInfo end)
{
- MagickRealType
+ double
alpha,
beta,
radius;
static void TraceEllipse(PrimitiveInfo *primitive_info,const PointInfo start,
const PointInfo stop,const PointInfo degrees)
{
- MagickRealType
+ double
delta,
step,
y;
return;
}
delta=2.0/MagickMax(stop.x,stop.y);
- step=(MagickRealType) (MagickPI/8.0);
- if ((delta >= 0.0) && (delta < (MagickRealType) (MagickPI/8.0)))
- step=(MagickRealType) (MagickPI/(4*(MagickPI/delta/2+0.5)));
+ step=(double) (MagickPI/8.0);
+ if ((delta >= 0.0) && (delta < (double) (MagickPI/8.0)))
+ step=(double) (MagickPI/(4*(MagickPI/delta/2+0.5)));
angle.x=DegreesToRadians(degrees.x);
y=degrees.y;
while (y < degrees.x)
y+=360.0;
- angle.y=(double) (DegreesToRadians(y)-DrawEpsilon);
+ angle.y=(double) 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;
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;
attribute,
last_attribute;
- MagickRealType
+ double
x,
y;
z_count;
attribute=0;
+ end.x=0.0;
+ end.y=0.0;
point.x=0.0;
point.y=0.0;
start.x=0.0;
start.y=0.0;
number_coordinates=0;
z_count=0;
+ (void) ResetMagickMemory(points,0,sizeof(*points));
primitive_type=primitive_info->primitive;
q=primitive_info;
for (p=path; *p != '\0'; )
large_arc,
sweep;
- MagickRealType
+ double
angle;
PointInfo
}
static void TraceSquareLinecap(PrimitiveInfo *primitive_info,
- const size_t number_vertices,const MagickRealType offset)
+ const size_t number_vertices,const double offset)
{
- MagickRealType
+ double
distance;
- register MagickRealType
+ register double
dx,
dy;
{
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)
{
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);
dy*(distance+offset)/distance);
}
+static inline double DrawEpsilonReciprocal(const double x)
+{
+#define DrawEpsilon ((double) 1.0e-10)
+
+ double sign = x < (double) 0.0 ? (double) -1.0 :
+ (double) 1.0;
+ return((sign*x) >= DrawEpsilon ? (double) 1.0/x : sign*(
+ (double) 1.0/DrawEpsilon));
+}
+
static PrimitiveInfo *TraceStrokePolygon(const DrawInfo *draw_info,
const PrimitiveInfo *primitive_info)
{
MagickBooleanType
closed_path;
- MagickRealType
+ double
delta_theta,
dot_product,
mid,
{
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)
slope.p=DrawEpsilonReciprocal(dx.p)*dy.p;
inverse_slope.p=(-1.0*DrawEpsilonReciprocal(slope.p));
mid=ExpandAffine(&draw_info->affine)*draw_info->stroke_width/2.0;
- miterlimit=(MagickRealType) (draw_info->miterlimit*draw_info->miterlimit*
+ miterlimit=(double) (draw_info->miterlimit*draw_info->miterlimit*
mid*mid);
if ((draw_info->linecap == SquareCap) && (closed_path == MagickFalse))
TraceSquareLinecap(polygon_primitive,number_vertices,mid);
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];
theta.p=atan2(box_q[1].y-center.y,box_q[1].x-center.x);
theta.q=atan2(box_q[2].y-center.y,box_q[2].x-center.x);
if (theta.q < theta.p)
- theta.q+=(MagickRealType) (2.0*MagickPI);
+ theta.q+=(double) (2.0*MagickPI);
arc_segments=(size_t) ceil((double) ((theta.q-theta.p)/
(2.0*sqrt((double) (1.0/mid)))));
path_q[q].x=box_q[1].x;
q++;
for (j=1; j < (ssize_t) arc_segments; j++)
{
- delta_theta=(MagickRealType) (j*(theta.q-theta.p)/arc_segments);
+ delta_theta=(double) (j*(theta.q-theta.p)/arc_segments);
path_q[q].x=(double) (center.x+mid*cos(fmod((double)
(theta.p+delta_theta),DegreesToRadians(360.0))));
path_q[q].y=(double) (center.y+mid*sin(fmod((double)
theta.p=atan2(box_p[1].y-center.y,box_p[1].x-center.x);
theta.q=atan2(box_p[2].y-center.y,box_p[2].x-center.x);
if (theta.p < theta.q)
- theta.p+=(MagickRealType) (2.0*MagickPI);
+ theta.p+=(double) (2.0*MagickPI);
arc_segments=(size_t) ceil((double) ((theta.p-theta.q)/
(2.0*sqrt((double) (1.0/mid)))));
path_p[p++]=box_p[1];
for (j=1; j < (ssize_t) arc_segments; j++)
{
- delta_theta=(MagickRealType) (j*(theta.q-theta.p)/arc_segments);
+ delta_theta=(double) (j*(theta.q-theta.p)/arc_segments);
path_p[p].x=(double) (center.x+mid*cos(fmod((double)
(theta.p+delta_theta),DegreesToRadians(360.0))));
path_p[p].y=(double) (center.y+mid*sin(fmod((double)