% July 1998 %
% %
% %
-% Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2011 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 %
PointInfo
*points;
- unsigned long
+ size_t
number_points;
- long
+ ssize_t
direction;
MagickBooleanType
ghostline;
- unsigned long
+ size_t
highwater;
} EdgeInfo;
EdgeInfo
*edges;
- unsigned long
+ size_t
number_edges;
} PolygonInfo;
static PrimitiveInfo
*TraceStrokePolygon(const DrawInfo *,const PrimitiveInfo *);
-static unsigned long
+static size_t
TracePath(PrimitiveInfo *,const char *);
static void
TraceArc(PrimitiveInfo *,const PointInfo,const PointInfo,const PointInfo),
TraceArcPath(PrimitiveInfo *,const PointInfo,const PointInfo,const PointInfo,
const MagickRealType,const MagickBooleanType,const MagickBooleanType),
- TraceBezier(PrimitiveInfo *,const unsigned long),
+ TraceBezier(PrimitiveInfo *,const size_t),
TraceCircle(PrimitiveInfo *,const PointInfo,const PointInfo),
TraceEllipse(PrimitiveInfo *,const PointInfo,const PointInfo,const PointInfo),
TraceLine(PrimitiveInfo *,const PointInfo,const PointInfo),
TraceRectangle(PrimitiveInfo *,const PointInfo,const PointInfo),
TraceRoundRectangle(PrimitiveInfo *,const PointInfo,const PointInfo,
PointInfo),
- TraceSquareLinecap(PrimitiveInfo *,const unsigned long,const MagickRealType);
+ TraceSquareLinecap(PrimitiveInfo *,const size_t,const MagickRealType);
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DrawInfo
*draw_info;
- draw_info=(DrawInfo *) AcquireAlignedMemory(1,sizeof(*draw_info));
+ draw_info=(DrawInfo *) AcquireMagickMemory(sizeof(*draw_info));
if (draw_info == (DrawInfo *) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
GetDrawInfo((ImageInfo *) NULL,draw_info);
DrawInfo
*clone_info;
- clone_info=(DrawInfo *) AcquireAlignedMemory(1,sizeof(*clone_info));
+ clone_info=(DrawInfo *) AcquireMagickMemory(sizeof(*clone_info));
if (clone_info == (DrawInfo *) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
GetDrawInfo(image_info,clone_info);
clone_info->kerning=draw_info->kerning;
clone_info->interline_spacing=draw_info->interline_spacing;
clone_info->interword_spacing=draw_info->interword_spacing;
+ clone_info->direction=draw_info->direction;
if (draw_info->density != (char *) NULL)
(void) CloneString(&clone_info->density,draw_info->density);
clone_info->align=draw_info->align;
(void) CloneString(&clone_info->server_name,draw_info->server_name);
if (draw_info->dash_pattern != (double *) NULL)
{
- register long
+ register ssize_t
x;
for (x=0; draw_info->dash_pattern[x] != 0.0; x++) ;
clone_info->gradient=draw_info->gradient;
if (draw_info->gradient.stops != (StopInfo *) NULL)
{
- unsigned long
+ size_t
number_stops;
number_stops=clone_info->gradient.number_stops;
register EdgeInfo
*p;
- register long
+ register ssize_t
i,
j;
(void) LogMagickEvent(DrawEvent,GetMagickModule()," begin active-edge");
p=polygon_info->edges;
- for (i=0; i < (long) polygon_info->number_edges; i++)
+ for (i=0; i < (ssize_t) polygon_info->number_edges; i++)
{
- (void) LogMagickEvent(DrawEvent,GetMagickModule()," edge %lu:",i);
+ (void) LogMagickEvent(DrawEvent,GetMagickModule()," edge %.20g:",
+ (double) i);
(void) LogMagickEvent(DrawEvent,GetMagickModule()," direction: %s",
p->direction != MagickFalse ? "down" : "up");
(void) LogMagickEvent(DrawEvent,GetMagickModule()," ghostline: %s",
p->ghostline != MagickFalse ? "transparent" : "opaque");
(void) LogMagickEvent(DrawEvent,GetMagickModule(),
- " bounds: %g,%g - %g,%g",p->bounds.x1,p->bounds.y1,p->bounds.x2,
- p->bounds.y2);
- for (j=0; j < (long) p->number_points; j++)
- (void) LogMagickEvent(DrawEvent,GetMagickModule()," %g,%g",
+ " bounds: %g %g - %g %g",p->bounds.x1,p->bounds.y1,
+ p->bounds.x2,p->bounds.y2);
+ for (j=0; j < (ssize_t) p->number_points; j++)
+ (void) LogMagickEvent(DrawEvent,GetMagickModule()," %g %g",
p->points[j].x,p->points[j].y);
p++;
}
(void) LogMagickEvent(DrawEvent,GetMagickModule()," end active-edge");
}
-static void ReversePoints(PointInfo *points,const unsigned long number_points)
+static void ReversePoints(PointInfo *points,const size_t number_points)
{
PointInfo
point;
- register long
+ register ssize_t
i;
- for (i=0; i < (long) (number_points >> 1); i++)
+ for (i=0; i < (ssize_t) (number_points >> 1); i++)
{
point=points[i];
points[i]=points[number_points-(i+1)];
SegmentInfo
bounds;
- register long
+ register ssize_t
i,
n;
MagickBooleanType
ghostline;
- unsigned long
+ size_t
edge,
number_edges,
number_points;
/*
Convert a path to the more efficient sorted rendering form.
*/
- polygon_info=(PolygonInfo *) AcquireAlignedMemory(1,sizeof(*polygon_info));
+ polygon_info=(PolygonInfo *) AcquireMagickMemory(sizeof(*polygon_info));
if (polygon_info == (PolygonInfo *) NULL)
return((PolygonInfo *) NULL);
number_edges=16;
if (polygon_info->edges == (EdgeInfo *) NULL)
return((PolygonInfo *) NULL);
}
- polygon_info->edges[edge].number_points=(unsigned long) n;
+ polygon_info->edges[edge].number_points=(size_t) n;
polygon_info->edges[edge].scanline=(-1.0);
polygon_info->edges[edge].highwater=0;
polygon_info->edges[edge].ghostline=ghostline;
- polygon_info->edges[edge].direction=(long) (direction > 0);
+ polygon_info->edges[edge].direction=(ssize_t) (direction > 0);
if (direction < 0)
- ReversePoints(points,(unsigned long) n);
+ ReversePoints(points,(size_t) n);
polygon_info->edges[edge].points=points;
polygon_info->edges[edge].bounds=bounds;
polygon_info->edges[edge].bounds.y1=points[0].y;
if (polygon_info->edges == (EdgeInfo *) NULL)
return((PolygonInfo *) NULL);
}
- polygon_info->edges[edge].number_points=(unsigned long) n;
+ polygon_info->edges[edge].number_points=(size_t) n;
polygon_info->edges[edge].scanline=(-1.0);
polygon_info->edges[edge].highwater=0;
polygon_info->edges[edge].ghostline=ghostline;
- polygon_info->edges[edge].direction=(long) (direction > 0);
+ polygon_info->edges[edge].direction=(ssize_t) (direction > 0);
if (direction < 0)
- ReversePoints(points,(unsigned long) n);
+ ReversePoints(points,(size_t) n);
polygon_info->edges[edge].points=points;
polygon_info->edges[edge].bounds=bounds;
polygon_info->edges[edge].bounds.y1=points[0].y;
direction=next_direction;
if (points == (PointInfo *) NULL)
continue;
- if (n == (long) number_points)
+ if (n == (ssize_t) number_points)
{
number_points<<=1;
points=(PointInfo *) ResizeQuantumMemory(points,(size_t) number_points,
if (polygon_info->edges == (EdgeInfo *) NULL)
return((PolygonInfo *) NULL);
}
- polygon_info->edges[edge].number_points=(unsigned long) n;
+ polygon_info->edges[edge].number_points=(size_t) n;
polygon_info->edges[edge].scanline=(-1.0);
polygon_info->edges[edge].highwater=0;
polygon_info->edges[edge].ghostline=ghostline;
- polygon_info->edges[edge].direction=(long) (direction > 0);
+ polygon_info->edges[edge].direction=(ssize_t) (direction > 0);
if (direction < 0)
- ReversePoints(points,(unsigned long) n);
+ ReversePoints(points,(size_t) n);
polygon_info->edges[edge].points=points;
polygon_info->edges[edge].bounds=bounds;
polygon_info->edges[edge].bounds.y1=points[0].y;
(void) LogMagickEvent(DrawEvent,GetMagickModule()," begin vector-path");
for (p=path_info; p->code != EndCode; p++)
(void) LogMagickEvent(DrawEvent,GetMagickModule(),
- " %g,%g %s",p->point.x,p->point.y,p->code == GhostlineCode ?
+ " %g %g %s",p->point.x,p->point.y,p->code == GhostlineCode ?
"moveto ghostline" : p->code == OpenCode ? "moveto open" :
p->code == MoveToCode ? "moveto" : p->code == LineToCode ? "lineto" :
"?");
static PathInfo *ConvertPrimitiveToPath(
const DrawInfo *magick_unused(draw_info),const PrimitiveInfo *primitive_info)
{
- long
- coordinates,
- start;
-
PathInfo
*path_info;
p,
q;
- register long
+ register ssize_t
i,
n;
+ ssize_t
+ coordinates,
+ start;
+
/*
Converts a PrimitiveInfo structure into a vector path structure.
*/
code=LineToCode;
if (coordinates <= 0)
{
- coordinates=(long) primitive_info[i].coordinates;
+ coordinates=(ssize_t) primitive_info[i].coordinates;
p=primitive_info[i].point;
start=n;
code=MoveToCode;
%
% The format of the DestroyEdge method is:
%
-% long DestroyEdge(PolygonInfo *polygon_info,const int edge)
+% ssize_t DestroyEdge(PolygonInfo *polygon_info,const int edge)
%
% A description of each parameter follows:
%
% o edge: the polygon edge number to destroy.
%
*/
-static unsigned long DestroyEdge(PolygonInfo *polygon_info,
- const unsigned long edge)
+static size_t DestroyEdge(PolygonInfo *polygon_info,
+ const size_t edge)
{
assert(edge < polygon_info->number_edges);
polygon_info->edges[edge].points=(PointInfo *) RelinquishMagickMemory(
*/
static PolygonInfo *DestroyPolygonInfo(PolygonInfo *polygon_info)
{
- register long
+ register ssize_t
i;
- for (i=0; i < (long) polygon_info->number_edges; i++)
+ for (i=0; i < (ssize_t) polygon_info->number_edges; i++)
polygon_info->edges[i].points=(PointInfo *)
RelinquishMagickMemory(polygon_info->edges[i].points);
polygon_info->edges=(EdgeInfo *) RelinquishMagickMemory(polygon_info->edges);
inverse_edge.x2=x;
}
else
- if ((z < 0.0) || ((unsigned long) (z+0.5) >= image->columns))
+ if ((z < 0.0) || ((size_t) floor(z+0.5) >= image->columns))
{
inverse_edge.x2=edge->x1;
return(inverse_edge);
inverse_edge.x2=x;
}
else
- if ((z < 0.0) || ((unsigned long) (z+0.5) >= image->rows))
+ if ((z < 0.0) || ((size_t) floor(z+0.5) >= image->rows))
{
inverse_edge.x2=edge->x2;
return(inverse_edge);
return(inverse_affine);
}
-static inline long MagickAbsoluteValue(const long x)
+static inline ssize_t MagickAbsoluteValue(const ssize_t x)
{
if (x < 0)
return(-x);
AffineMatrix
inverse_affine;
+ CacheView
+ *image_view,
+ *source_view;
+
ExceptionInfo
*exception;
- long
- y;
-
MagickBooleanType
status;
max,
point;
- register long
+ register ssize_t
i;
- ResampleFilter
- **resample_filter;
-
SegmentInfo
edge;
- CacheView
- *image_view,
- *source_view;
+ ssize_t
+ y;
/*
Determine bounding box.
inverse_affine=InverseAffineMatrix(affine);
GetMagickPixelPacket(image,&zero);
exception=(&image->exception);
- resample_filter=AcquireResampleFilterThreadSet(source,MagickTrue,exception);
image_view=AcquireCacheView(image);
source_view=AcquireCacheView(source);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(status)
#endif
- for (y=(long) (edge.y1+0.5); y <= (long) (edge.y2+0.5); y++)
+ for (y=(ssize_t) ceil(edge.y1-0.5); y <= (ssize_t) floor(edge.y2+0.5); y++)
{
- long
- x_offset;
-
MagickPixelPacket
composite,
pixel;
register IndexPacket
*restrict indexes;
- register long
- id,
+ register ssize_t
x;
register PixelPacket
SegmentInfo
inverse_edge;
+ ssize_t
+ x_offset;
+
inverse_edge=AffineEdge(source,&inverse_affine,(double) y,&edge);
if (inverse_edge.x2 < inverse_edge.x1)
continue;
- q=GetCacheViewAuthenticPixels(image_view,(long) (inverse_edge.x1+0.5),y,
- (unsigned long) ((long) (inverse_edge.x2+0.5)-(long) (inverse_edge.x1+
- 0.5)+1),1,exception);
+ 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);
if (q == (PixelPacket *) NULL)
continue;
- id=GetOpenMPThreadId();
indexes=GetCacheViewAuthenticIndexQueue(image_view);
pixel=zero;
composite=zero;
x_offset=0;
- for (x=(long) (inverse_edge.x1+0.5); x <= (long) (inverse_edge.x2+0.5); x++)
+ for (x=(ssize_t) ceil(inverse_edge.x1-0.5); x <= (ssize_t) floor(inverse_edge.x2+0.5); x++)
{
point.x=(double) x*inverse_affine.sx+y*inverse_affine.ry+
inverse_affine.tx;
point.y=(double) x*inverse_affine.rx+y*inverse_affine.sy+
inverse_affine.ty;
- (void) ResamplePixelColor(resample_filter[id],point.x,point.y,&pixel);
+ (void) InterpolateMagickPixelPacket(source,source_view,
+ UndefinedInterpolatePixel,point.x,point.y,&pixel,exception);
SetMagickPixelPacket(image,q,indexes+x_offset,&composite);
MagickPixelCompositeOver(&pixel,pixel.opacity,&composite,
composite.opacity,&composite);
if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
status=MagickFalse;
}
- resample_filter=DestroyResampleFilterThreadSet(resample_filter);
source_view=DestroyCacheView(source_view);
image_view=DestroyCacheView(image_view);
return(status);
DrawInfo
*clone_info;
- long
- coordinates;
-
MagickRealType
mid;
PrimitiveInfo
primitive_info[6];
- register long
+ register ssize_t
i;
SegmentInfo
bounds;
+ ssize_t
+ coordinates;
+
clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
(void) QueryColorDatabase("#0000",&clone_info->fill,&image->exception);
resolution.x=DefaultResolution;
if (polygon_info != (PolygonInfo *) NULL)
{
bounds=polygon_info->edges[0].bounds;
- for (i=1; i < (long) polygon_info->number_edges; i++)
+ for (i=1; i < (ssize_t) polygon_info->number_edges; i++)
{
if (polygon_info->edges[i].bounds.x1 < (double) bounds.x1)
bounds.x1=polygon_info->edges[i].bounds.x1;
bounds.y2+=mid;
bounds.y2=bounds.y2 < 0.0 ? 0.0 : bounds.y2 >= (double)
image->rows ? (double) image->rows-1 : bounds.y2;
- for (i=0; i < (long) polygon_info->number_edges; i++)
+ for (i=0; i < (ssize_t) polygon_info->number_edges; i++)
{
if (polygon_info->edges[i].direction != 0)
(void) QueryColorDatabase("red",&clone_info->stroke,
primitive_info[0].primitive=RectanglePrimitive;
TraceRectangle(primitive_info,start,end);
primitive_info[0].method=ReplaceMethod;
- coordinates=(long) primitive_info[0].coordinates;
+ coordinates=(ssize_t) primitive_info[0].coordinates;
primitive_info[coordinates].primitive=UndefinedPrimitive;
(void) DrawPrimitive(image,clone_info,primitive_info);
}
primitive_info[0].primitive=RectanglePrimitive;
TraceRectangle(primitive_info,start,end);
primitive_info[0].method=ReplaceMethod;
- coordinates=(long) primitive_info[0].coordinates;
+ coordinates=(ssize_t) primitive_info[0].coordinates;
primitive_info[coordinates].primitive=UndefinedPrimitive;
(void) DrawPrimitive(image,clone_info,primitive_info);
clone_info=DestroyDrawInfo(clone_info);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(draw_info != (const DrawInfo *) NULL);
- (void) FormatMagickString(clip_mask,MaxTextExtent,"%s",name);
+ (void) FormatLocaleString(clip_mask,MaxTextExtent,"%s",name);
value=GetImageArtifact(image,clip_mask);
if (value == (const char *) NULL)
return(MagickFalse);
DrawInfo
*clone_info;
- long
- j,
- n;
-
MagickRealType
length,
maximum_length,
PrimitiveInfo
*dash_polygon;
- register long
+ register ssize_t
i;
register MagickRealType
dx,
dy;
- unsigned long
+ size_t
number_vertices;
+ ssize_t
+ j,
+ n;
+
assert(draw_info != (const DrawInfo *) NULL);
if (image->debug != MagickFalse)
(void) LogMagickEvent(DrawEvent,GetMagickModule()," begin draw-dash");
clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
clone_info->miterlimit=0;
for (i=0; primitive_info[i].primitive != UndefinedPrimitive; i++) ;
- number_vertices=(unsigned long) i;
+ number_vertices=(size_t) i;
dash_polygon=(PrimitiveInfo *) AcquireQuantumMemory((size_t)
(2UL*number_vertices+1UL),sizeof(*dash_polygon));
if (dash_polygon == (PrimitiveInfo *) NULL)
status=MagickTrue;
maximum_length=0.0;
total_length=0.0;
- for (i=1; i < (long) number_vertices; i++)
+ for (i=1; i < (ssize_t) number_vertices; i++)
{
dx=primitive_info[i].point.x-primitive_info[i-1].point.x;
dy=primitive_info[i].point.y-primitive_info[i-1].point.y;
}
else
{
- if ((j+1) > (long) (2*number_vertices))
+ if ((j+1) > (ssize_t) (2*number_vertices))
break;
dash_polygon[j]=primitive_info[i-1];
dash_polygon[j].point.x=(double) (primitive_info[i-1].point.x+dx*
total_length/maximum_length);
dash_polygon[j].coordinates=1;
j++;
- dash_polygon[0].coordinates=(unsigned long) j;
+ dash_polygon[0].coordinates=(size_t) j;
dash_polygon[j].primitive=UndefinedPrimitive;
status|=DrawStrokePolygon(image,clone_info,dash_polygon);
}
dash_polygon[j].point.y+=MagickEpsilon;
dash_polygon[j].coordinates=1;
j++;
- dash_polygon[0].coordinates=(unsigned long) j;
+ dash_polygon[0].coordinates=(size_t) j;
dash_polygon[j].primitive=UndefinedPrimitive;
status|=DrawStrokePolygon(image,clone_info,dash_polygon);
}
double
value;
- value=strtod(point,&p);
+ value=InterpretLocaleValue(point,&p);
return((value == 0.0) && (p == point) ? MagickFalse : MagickTrue);
}
DrawInfo
**graphic_context;
- long
- j,
- k,
- n;
-
MagickBooleanType
proceed,
status;
register const char
*p;
- register long
+ register ssize_t
i,
x;
bounds;
size_t
- length;
-
- unsigned long
+ length,
number_points;
+ ssize_t
+ j,
+ k,
+ n;
+
/*
Ensure the annotation info is valid.
*/
/*
Allocate primitive info memory.
*/
- graphic_context=(DrawInfo **) AcquireAlignedMemory(1,sizeof(*graphic_context));
+ graphic_context=(DrawInfo **) AcquireMagickMemory(
+ sizeof(*graphic_context));
if (graphic_context == (DrawInfo **) NULL)
{
primitive=DestroyString(primitive);
if (LocaleCompare("affine",keyword) == 0)
{
GetMagickToken(q,&q,token);
- affine.sx=StringToDouble(token);
+ affine.sx=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
- affine.rx=StringToDouble(token);
+ affine.rx=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
- affine.ry=StringToDouble(token);
+ affine.ry=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
- affine.sy=StringToDouble(token);
+ affine.sy=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
- affine.tx=StringToDouble(token);
+ affine.tx=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
- affine.ty=StringToDouble(token);
+ affine.ty=InterpretLocaleValue(token,(char **) NULL);
break;
}
if (LocaleCompare("arc",keyword) == 0)
}
if (LocaleCompare("clip-rule",keyword) == 0)
{
- long
+ ssize_t
fill_rule;
GetMagickToken(q,&q,token);
- fill_rule=ParseMagickOption(MagickFillRuleOptions,MagickFalse,
+ fill_rule=ParseCommandOption(MagickFillRuleOptions,MagickFalse,
token);
if (fill_rule == -1)
{
}
if (LocaleCompare("clip-units",keyword) == 0)
{
- long
+ ssize_t
clip_units;
GetMagickToken(q,&q,token);
- clip_units=ParseMagickOption(MagickClipPathOptions,MagickFalse,
+ clip_units=ParseCommandOption(MagickClipPathOptions,MagickFalse,
token);
if (clip_units == -1)
{
{
if (LocaleCompare("decorate",keyword) == 0)
{
- long
+ ssize_t
decorate;
GetMagickToken(q,&q,token);
- decorate=ParseMagickOption(MagickDecorateOptions,MagickFalse,
+ decorate=ParseCommandOption(MagickDecorateOptions,MagickFalse,
token);
if (decorate == -1)
{
if (LocaleCompare("fill",keyword) == 0)
{
GetMagickToken(q,&q,token);
- (void) FormatMagickString(pattern,MaxTextExtent,"%s",token);
+ (void) FormatLocaleString(pattern,MaxTextExtent,"%s",token);
if (GetImageArtifact(image,pattern) != (const char *) NULL)
(void) DrawPatternPath(image,draw_info,token,
&graphic_context[n]->fill_pattern);
{
GetMagickToken(q,&q,token);
factor=strchr(token,'%') != (char *) NULL ? 0.01 : 1.0;
- graphic_context[n]->fill.opacity=RoundToQuantum((MagickRealType)
- QuantumRange*(1.0-factor*StringToDouble(token)));
+ graphic_context[n]->fill.opacity=ClampToQuantum((MagickRealType)
+ QuantumRange*(1.0-factor*InterpretLocaleValue(token,
+ (char **) NULL)));
break;
}
if (LocaleCompare("fill-rule",keyword) == 0)
{
- long
+ ssize_t
fill_rule;
GetMagickToken(q,&q,token);
- fill_rule=ParseMagickOption(MagickFillRuleOptions,MagickFalse,
+ fill_rule=ParseCommandOption(MagickFillRuleOptions,MagickFalse,
token);
if (fill_rule == -1)
{
if (LocaleCompare("font-size",keyword) == 0)
{
GetMagickToken(q,&q,token);
- graphic_context[n]->pointsize=StringToDouble(token);
+ graphic_context[n]->pointsize=InterpretLocaleValue(token,
+ (char **) NULL);
break;
}
if (LocaleCompare("font-stretch",keyword) == 0)
{
- long
+ ssize_t
stretch;
GetMagickToken(q,&q,token);
- stretch=ParseMagickOption(MagickStretchOptions,MagickFalse,token);
+ stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,token);
if (stretch == -1)
{
status=MagickFalse;
}
if (LocaleCompare("font-style",keyword) == 0)
{
- long
+ ssize_t
style;
GetMagickToken(q,&q,token);
- style=ParseMagickOption(MagickStyleOptions,MagickFalse,token);
+ style=ParseCommandOption(MagickStyleOptions,MagickFalse,token);
if (style == -1)
{
status=MagickFalse;
if (LocaleCompare("font-weight",keyword) == 0)
{
GetMagickToken(q,&q,token);
- graphic_context[n]->weight=(unsigned long) StringToLong(token);
+ graphic_context[n]->weight=StringToUnsignedLong(token);
if (LocaleCompare(token,"all") == 0)
graphic_context[n]->weight=0;
if (LocaleCompare(token,"bold") == 0)
}
if (LocaleCompare("gravity",keyword) == 0)
{
- long
+ ssize_t
gravity;
GetMagickToken(q,&q,token);
- gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,token);
+ gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,token);
if (gravity == -1)
{
status=MagickFalse;
{
if (LocaleCompare("image",keyword) == 0)
{
- long
+ ssize_t
compose;
primitive_type=ImagePrimitive;
GetMagickToken(q,&q,token);
- compose=ParseMagickOption(MagickComposeOptions,MagickFalse,token);
+ compose=ParseCommandOption(MagickComposeOptions,MagickFalse,token);
if (compose == -1)
{
status=MagickFalse;
if (LocaleCompare("interline-spacing",keyword) == 0)
{
GetMagickToken(q,&q,token);
- graphic_context[n]->interline_spacing=StringToDouble(token);
+ graphic_context[n]->interline_spacing=InterpretLocaleValue(token,
+ (char **) NULL);
break;
}
if (LocaleCompare("interword-spacing",keyword) == 0)
{
GetMagickToken(q,&q,token);
- graphic_context[n]->interword_spacing=StringToDouble(token);
+ graphic_context[n]->interword_spacing=InterpretLocaleValue(token,
+ (char **) NULL);
break;
}
status=MagickFalse;
if (LocaleCompare("kerning",keyword) == 0)
{
GetMagickToken(q,&q,token);
- graphic_context[n]->kerning=StringToDouble(token);
+ graphic_context[n]->kerning=InterpretLocaleValue(token,
+ (char **) NULL);
break;
}
status=MagickFalse;
{
GetMagickToken(q,&q,token);
factor=strchr(token,'%') != (char *) NULL ? 0.01 : 1.0;
- graphic_context[n]->opacity=RoundToQuantum((MagickRealType)
+ graphic_context[n]->opacity=ClampToQuantum((MagickRealType)
QuantumRange*(1.0-((1.0-QuantumScale*graphic_context[n]->opacity)*
- factor*StringToDouble(token))));
+ factor*InterpretLocaleValue(token,(char **) NULL))));
graphic_context[n]->fill.opacity=graphic_context[n]->opacity;
graphic_context[n]->stroke.opacity=graphic_context[n]->opacity;
break;
name[MaxTextExtent];
GetMagickToken(q,&q,token);
- (void) FormatMagickString(name,MaxTextExtent,"%s",token);
+ (void) FormatLocaleString(name,MaxTextExtent,"%s",token);
for (p=q; *q != '\0'; )
{
GetMagickToken(q,&q,token);
name[MaxTextExtent],
type[MaxTextExtent];
- ElementInfo
- element;
-
SegmentInfo
segment;
GetMagickToken(q,&q,token);
(void) CopyMagickString(type,token,MaxTextExtent);
GetMagickToken(q,&q,token);
- segment.x1=StringToDouble(token);
- element.cx=StringToDouble(token);
+ segment.x1=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
- segment.y1=StringToDouble(token);
- element.cy=StringToDouble(token);
+ segment.y1=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
- segment.x2=StringToDouble(token);
- element.major=StringToDouble(token);
+ segment.x2=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
- segment.y2=StringToDouble(token);
- element.minor=StringToDouble(token);
+ segment.y2=InterpretLocaleValue(token,(char **) NULL);
if (LocaleCompare(type,"radial") == 0)
{
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
- element.angle=StringToDouble(token);
}
for (p=q; *q != '\0'; )
{
bounds.y2=graphic_context[n]->affine.rx*segment.x2+
graphic_context[n]->affine.sy*segment.y2+
graphic_context[n]->affine.ty;
- (void) FormatMagickString(key,MaxTextExtent,"%s",name);
+ (void) FormatLocaleString(key,MaxTextExtent,"%s",name);
(void) SetImageArtifact(image,key,token);
- (void) FormatMagickString(key,MaxTextExtent,"%s-geometry",name);
- (void) FormatMagickString(geometry,MaxTextExtent,"%gx%g%+f%+f",
+ (void) FormatLocaleString(key,MaxTextExtent,"%s-geometry",name);
+ (void) FormatLocaleString(geometry,MaxTextExtent,
+ "%gx%g%+.15g%+.15g",
MagickMax(fabs(bounds.x2-bounds.x1+1.0),1.0),
MagickMax(fabs(bounds.y2-bounds.y1+1.0),1.0),
bounds.x1,bounds.y1);
GetMagickToken(q,&q,token);
(void) CopyMagickString(name,token,MaxTextExtent);
GetMagickToken(q,&q,token);
- bounds.x=(long) (StringToDouble(token)+0.5);
+ bounds.x=(ssize_t) ceil(InterpretLocaleValue(token,
+ (char **) NULL)-0.5);
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
- bounds.y=(long) (StringToDouble(token)+0.5);
+ bounds.y=(ssize_t) ceil(InterpretLocaleValue(token,
+ (char **) NULL)-0.5);
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
- bounds.width=(unsigned long) (StringToDouble(token)+0.5);
+ bounds.width=(size_t) floor(InterpretLocaleValue(token,
+ (char **) NULL)+0.5);
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
- bounds.height=(unsigned long) (StringToDouble(token)+0.5);
+ bounds.height=(size_t) floor(InterpretLocaleValue(token,
+ (char **) NULL)+0.5);
for (p=q; *q != '\0'; )
{
GetMagickToken(q,&q,token);
break;
}
(void) CopyMagickString(token,p,(size_t) (q-p-4+1));
- (void) FormatMagickString(key,MaxTextExtent,"%s",name);
+ (void) FormatLocaleString(key,MaxTextExtent,"%s",name);
(void) SetImageArtifact(image,key,token);
- (void) FormatMagickString(key,MaxTextExtent,"%s-geometry",name);
- (void) FormatMagickString(geometry,MaxTextExtent,
- "%lux%lu%+ld%+ld",bounds.width,bounds.height,bounds.x,
- bounds.y);
+ (void) FormatLocaleString(key,MaxTextExtent,"%s-geometry",name);
+ (void) FormatLocaleString(geometry,MaxTextExtent,
+ "%.20gx%.20g%+.20g%+.20g",(double) bounds.width,(double)
+ bounds.height,(double) bounds.x,(double) bounds.y);
(void) SetImageArtifact(image,key,geometry);
GetMagickToken(q,&q,token);
break;
if (LocaleCompare("rotate",keyword) == 0)
{
GetMagickToken(q,&q,token);
- angle=StringToDouble(token);
+ angle=InterpretLocaleValue(token,(char **) NULL);
affine.sx=cos(DegreesToRadians(fmod((double) angle,360.0)));
affine.rx=sin(DegreesToRadians(fmod((double) angle,360.0)));
affine.ry=(-sin(DegreesToRadians(fmod((double) angle,360.0))));
if (LocaleCompare("scale",keyword) == 0)
{
GetMagickToken(q,&q,token);
- affine.sx=StringToDouble(token);
+ affine.sx=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
- affine.sy=StringToDouble(token);
+ affine.sy=InterpretLocaleValue(token,(char **) NULL);
break;
}
if (LocaleCompare("skewX",keyword) == 0)
{
GetMagickToken(q,&q,token);
- angle=StringToDouble(token);
+ angle=InterpretLocaleValue(token,(char **) NULL);
affine.ry=sin(DegreesToRadians(angle));
break;
}
if (LocaleCompare("skewY",keyword) == 0)
{
GetMagickToken(q,&q,token);
- angle=StringToDouble(token);
+ angle=InterpretLocaleValue(token,(char **) NULL);
affine.rx=(-tan(DegreesToRadians(angle)/2.0));
break;
}
if (LocaleCompare("stroke",keyword) == 0)
{
GetMagickToken(q,&q,token);
- (void) FormatMagickString(pattern,MaxTextExtent,"%s",token);
+ (void) FormatLocaleString(pattern,MaxTextExtent,"%s",token);
if (GetImageArtifact(image,pattern) != (const char *) NULL)
(void) DrawPatternPath(image,draw_info,token,
&graphic_context[n]->stroke_pattern);
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
- graphic_context[n]->dash_pattern[j]=StringToDouble(token);
+ graphic_context[n]->dash_pattern[j]=InterpretLocaleValue(
+ token,(char **) NULL);
}
if ((x & 0x01) != 0)
for ( ; j < (2*x); j++)
if (LocaleCompare("stroke-dashoffset",keyword) == 0)
{
GetMagickToken(q,&q,token);
- graphic_context[n]->dash_offset=StringToDouble(token);
+ graphic_context[n]->dash_offset=InterpretLocaleValue(token,
+ (char **) NULL);
break;
}
if (LocaleCompare("stroke-linecap",keyword) == 0)
{
- long
+ ssize_t
linecap;
GetMagickToken(q,&q,token);
- linecap=ParseMagickOption(MagickLineCapOptions,MagickFalse,token);
+ linecap=ParseCommandOption(MagickLineCapOptions,MagickFalse,token);
if (linecap == -1)
{
status=MagickFalse;
}
if (LocaleCompare("stroke-linejoin",keyword) == 0)
{
- long
+ ssize_t
linejoin;
GetMagickToken(q,&q,token);
- linejoin=ParseMagickOption(MagickLineJoinOptions,MagickFalse,token);
+ linejoin=ParseCommandOption(MagickLineJoinOptions,MagickFalse,token);
if (linejoin == -1)
{
status=MagickFalse;
if (LocaleCompare("stroke-miterlimit",keyword) == 0)
{
GetMagickToken(q,&q,token);
- graphic_context[n]->miterlimit=(unsigned long) StringToLong(token);
+ graphic_context[n]->miterlimit=StringToUnsignedLong(token);
break;
}
if (LocaleCompare("stroke-opacity",keyword) == 0)
{
GetMagickToken(q,&q,token);
factor=strchr(token,'%') != (char *) NULL ? 0.01 : 1.0;
- graphic_context[n]->stroke.opacity=RoundToQuantum((MagickRealType)
- QuantumRange*(1.0-factor*StringToDouble(token)));
+ graphic_context[n]->stroke.opacity=ClampToQuantum((MagickRealType)
+ QuantumRange*(1.0-factor*InterpretLocaleValue(token,
+ (char **) NULL)));
break;
}
if (LocaleCompare("stroke-width",keyword) == 0)
{
GetMagickToken(q,&q,token);
- graphic_context[n]->stroke_width=StringToDouble(token);
+ graphic_context[n]->stroke_width=InterpretLocaleValue(token,
+ (char **) NULL);
break;
}
status=MagickFalse;
}
if (LocaleCompare("text-align",keyword) == 0)
{
- long
+ ssize_t
align;
GetMagickToken(q,&q,token);
- align=ParseMagickOption(MagickAlignOptions,MagickFalse,token);
+ align=ParseCommandOption(MagickAlignOptions,MagickFalse,token);
if (align == -1)
{
status=MagickFalse;
}
if (LocaleCompare("text-anchor",keyword) == 0)
{
- long
+ ssize_t
align;
GetMagickToken(q,&q,token);
- align=ParseMagickOption(MagickAlignOptions,MagickFalse,token);
+ align=ParseCommandOption(MagickAlignOptions,MagickFalse,token);
if (align == -1)
{
status=MagickFalse;
if (LocaleCompare("translate",keyword) == 0)
{
GetMagickToken(q,&q,token);
- affine.tx=StringToDouble(token);
+ affine.tx=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
- affine.ty=StringToDouble(token);
+ affine.ty=InterpretLocaleValue(token,(char **) NULL);
break;
}
status=MagickFalse;
if (LocaleCompare("viewbox",keyword) == 0)
{
GetMagickToken(q,&q,token);
- graphic_context[n]->viewbox.x=(long) (StringToDouble(token)+0.5);
+ graphic_context[n]->viewbox.x=(ssize_t) ceil(InterpretLocaleValue(
+ token,(char **) NULL)-0.5);
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
- graphic_context[n]->viewbox.y=(long) (StringToDouble(token)+0.5);
+ graphic_context[n]->viewbox.y=(ssize_t) ceil(InterpretLocaleValue(
+ token,(char **) NULL)-0.5);
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
- graphic_context[n]->viewbox.width=(unsigned long) (StringToDouble(token)+0.5);
+ graphic_context[n]->viewbox.width=(size_t) floor(
+ InterpretLocaleValue(token,(char **) NULL)+0.5);
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
- graphic_context[n]->viewbox.height=(unsigned long) (StringToDouble(token)+
- 0.5);
+ graphic_context[n]->viewbox.height=(size_t) floor(
+ InterpretLocaleValue(token,(char **) NULL)+0.5);
break;
}
status=MagickFalse;
graphic_context[n]->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
graphic_context[n]->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
graphic_context[n]->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
- graphic_context[n]->affine.tx=
- current.sx*affine.tx+current.ry*affine.ty+current.tx;
- graphic_context[n]->affine.ty=
- current.rx*affine.tx+current.sy*affine.ty+current.ty;
+ graphic_context[n]->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
+ current.tx;
+ graphic_context[n]->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
+ current.ty;
}
if (primitive_type == UndefinedPrimitive)
{
if (IsPoint(q) == MagickFalse)
break;
GetMagickToken(q,&q,token);
- point.x=StringToDouble(token);
+ point.x=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
- point.y=StringToDouble(token);
+ point.y=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(q,(const char **) NULL,token);
if (*token == ',')
GetMagickToken(q,&q,token);
primitive_info[i].coordinates=0;
primitive_info[i].method=FloodfillMethod;
i++;
- if (i < (long) number_points)
+ if (i < (ssize_t) number_points)
continue;
number_points<<=1;
primitive_info=(PrimitiveInfo *) ResizeQuantumMemory(primitive_info,
}
}
primitive_info[j].primitive=primitive_type;
- primitive_info[j].coordinates=(unsigned long) x;
+ primitive_info[j].coordinates=(size_t) x;
primitive_info[j].method=FloodfillMethod;
primitive_info[j].text=(char *) NULL;
/*
bounds.y1=primitive_info[j].point.y;
bounds.x2=primitive_info[j].point.x;
bounds.y2=primitive_info[j].point.y;
- for (k=1; k < (long) primitive_info[j].coordinates; k++)
+ for (k=1; k < (ssize_t) primitive_info[j].coordinates; k++)
{
point=primitive_info[j+k].point;
if (point.x < bounds.x1)
}
case RoundRectanglePrimitive:
{
- length*=5+4*BezierQuantum;
+ length*=5+8*BezierQuantum;
break;
}
case BezierPrimitive:
*t;
GetMagickToken(q,&q,token);
- k=1;
+ length=1;
t=token;
for (s=token; *s != '\0'; s=t)
{
double
value;
- value=strtod(s,&t);
+ value=InterpretLocaleValue(s,&t);
+ (void) value;
if (s == t)
{
t++;
continue;
}
- k++;
+ length++;
}
- length+=k*BezierQuantum;
+ length=3*length/2+6*BezierQuantum+360;
break;
}
case CirclePrimitive:
alpha=bounds.x2-bounds.x1;
beta=bounds.y2-bounds.y1;
radius=hypot((double) alpha,(double) beta);
- length=2*((size_t) (MagickPI*radius))+6*BezierQuantum+360+1;
+ length=2*((size_t) ceil((double) MagickPI*radius))+6*BezierQuantum+360;
break;
}
default:
break;
}
- if ((unsigned long) (i+length) >= number_points)
+ if ((size_t) (i+length) >= number_points)
{
/*
Resize based on speculative points required by primitive.
*/
- while ((unsigned long) (i+length) >= number_points)
- number_points<<=1;
+ number_points+=length+1;
primitive_info=(PrimitiveInfo *) ResizeQuantumMemory(primitive_info,
(size_t) number_points,sizeof(*primitive_info));
if (primitive_info == (PrimitiveInfo *) NULL)
break;
}
TracePoint(primitive_info+j,primitive_info[j].point);
- i=(long) (j+primitive_info[j].coordinates);
+ i=(ssize_t) (j+primitive_info[j].coordinates);
break;
}
case LinePrimitive:
}
TraceLine(primitive_info+j,primitive_info[j].point,
primitive_info[j+1].point);
- i=(long) (j+primitive_info[j].coordinates);
+ i=(ssize_t) (j+primitive_info[j].coordinates);
break;
}
case RectanglePrimitive:
}
TraceRectangle(primitive_info+j,primitive_info[j].point,
primitive_info[j+1].point);
- i=(long) (j+primitive_info[j].coordinates);
+ i=(ssize_t) (j+primitive_info[j].coordinates);
break;
}
case RoundRectanglePrimitive:
}
TraceRoundRectangle(primitive_info+j,primitive_info[j].point,
primitive_info[j+1].point,primitive_info[j+2].point);
- i=(long) (j+primitive_info[j].coordinates);
+ i=(ssize_t) (j+primitive_info[j].coordinates);
break;
}
case ArcPrimitive:
}
TraceArc(primitive_info+j,primitive_info[j].point,
primitive_info[j+1].point,primitive_info[j+2].point);
- i=(long) (j+primitive_info[j].coordinates);
+ i=(ssize_t) (j+primitive_info[j].coordinates);
break;
}
case EllipsePrimitive:
}
TraceEllipse(primitive_info+j,primitive_info[j].point,
primitive_info[j+1].point,primitive_info[j+2].point);
- i=(long) (j+primitive_info[j].coordinates);
+ i=(ssize_t) (j+primitive_info[j].coordinates);
break;
}
case CirclePrimitive:
}
TraceCircle(primitive_info+j,primitive_info[j].point,
primitive_info[j+1].point);
- i=(long) (j+primitive_info[j].coordinates);
+ i=(ssize_t) (j+primitive_info[j].coordinates);
break;
}
case PolylinePrimitive:
break;
}
TraceBezier(primitive_info+j,primitive_info[j].coordinates);
- i=(long) (j+primitive_info[j].coordinates);
+ i=(ssize_t) (j+primitive_info[j].coordinates);
break;
}
case PathPrimitive:
{
- i=(long) (j+TracePath(primitive_info+j,token));
+ i=(ssize_t) (j+TracePath(primitive_info+j,token));
break;
}
case ColorPrimitive:
case MattePrimitive:
{
- long
+ ssize_t
method;
if (primitive_info[j].coordinates != 1)
break;
}
GetMagickToken(q,&q,token);
- method=ParseMagickOption(MagickMethodOptions,MagickFalse,token);
+ method=ParseCommandOption(MagickMethodOptions,MagickFalse,token);
if (method == -1)
{
status=MagickFalse;
graphic_context[n]->bounds.y2=point.y;
if (primitive_info[i].primitive == ImagePrimitive)
break;
+ if (i >= (ssize_t) number_points)
+ ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
}
- if (i >= (long) number_points)
- ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
if (graphic_context[n]->render != MagickFalse)
{
if ((n != 0) && (graphic_context[n]->clip_mask != (char *) NULL) &&
*/
static inline MagickRealType GetStopColorOffset(const GradientInfo *gradient,
- const long x,const long y)
+ const ssize_t x,const ssize_t y)
{
switch (gradient->type)
{
MagickExport MagickBooleanType DrawGradientImage(Image *image,
const DrawInfo *draw_info)
{
+ CacheView
+ *image_view;
+
const GradientInfo
*gradient;
ExceptionInfo
*exception;
- long
- y;
-
MagickBooleanType
status;
RectangleInfo
bounding_box;
- CacheView
- *image_view;
+ ssize_t
+ y;
/*
Draw linear or radial gradient on image.
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(status)
#endif
- for (y=bounding_box.y; y < (long) bounding_box.height; y++)
+ for (y=bounding_box.y; y < (ssize_t) bounding_box.height; y++)
{
- long
- j;
-
MagickPixelPacket
composite,
pixel;
register IndexPacket
*restrict indexes;
- register long
+ register ssize_t
i,
x;
register PixelPacket
*restrict q;
+ ssize_t
+ j;
+
if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
offset=GetStopColorOffset(gradient,0,y);
if (gradient->type != RadialGradient)
offset/=length;
- for (x=bounding_box.x; x < (long) bounding_box.width; x++)
+ for (x=bounding_box.x; x < (ssize_t) bounding_box.width; x++)
{
SetMagickPixelPacket(image,q,indexes+x,&pixel);
switch (gradient->spread)
case UndefinedSpread:
case PadSpread:
{
- if ((x != (long) (gradient_vector->x1+0.5)) ||
- (y != (long) (gradient_vector->y1+0.5)))
+ if ((x != (ssize_t) ceil(gradient_vector->x1-0.5)) ||
+ (y != (ssize_t) ceil(gradient_vector->y1-0.5)))
{
offset=GetStopColorOffset(gradient,x,y);
if (gradient->type != RadialGradient)
offset/=length;
}
- for (i=0; i < (long) gradient->number_stops; i++)
+ for (i=0; i < (ssize_t) gradient->number_stops; i++)
if (offset < gradient->stops[i].offset)
break;
if ((offset < 0.0) || (i == 0))
composite=gradient->stops[0].color;
else
- if ((offset > 1.0) || (i == (long) gradient->number_stops))
+ if ((offset > 1.0) || (i == (ssize_t) gradient->number_stops))
composite=gradient->stops[gradient->number_stops-1].color;
else
{
}
case ReflectSpread:
{
- if ((x != (long) (gradient_vector->x1+0.5)) ||
- (y != (long) (gradient_vector->y1+0.5)))
+ if ((x != (ssize_t) ceil(gradient_vector->x1-0.5)) ||
+ (y != (ssize_t) ceil(gradient_vector->y1-0.5)))
{
offset=GetStopColorOffset(gradient,x,y);
if (gradient->type != RadialGradient)
}
if (offset < 0.0)
offset=(-offset);
- if ((long) fmod(offset,2.0) == 0)
+ if ((ssize_t) fmod(offset,2.0) == 0)
offset=fmod(offset,1.0);
else
offset=1.0-fmod(offset,1.0);
- for (i=0; i < (long) gradient->number_stops; i++)
+ for (i=0; i < (ssize_t) gradient->number_stops; i++)
if (offset < gradient->stops[i].offset)
break;
if (i == 0)
composite=gradient->stops[0].color;
else
- if (i == (long) gradient->number_stops)
+ if (i == (ssize_t) gradient->number_stops)
composite=gradient->stops[gradient->number_stops-1].color;
else
{
antialias=MagickFalse;
repeat=0.0;
- if ((x != (long) (gradient_vector->x1+0.5)) ||
- (y != (long) (gradient_vector->y1+0.5)))
+ if ((x != (ssize_t) ceil(gradient_vector->x1-0.5)) ||
+ (y != (ssize_t) ceil(gradient_vector->y1-0.5)))
{
offset=GetStopColorOffset(gradient,x,y);
if (gradient->type == LinearGradient)
offset=repeat/gradient->radius;
}
}
- for (i=0; i < (long) gradient->number_stops; i++)
+ for (i=0; i < (ssize_t) gradient->number_stops; i++)
if (offset < gradient->stops[i].offset)
break;
if (i == 0)
composite=gradient->stops[0].color;
else
- if (i == (long) gradient->number_stops)
+ if (i == (ssize_t) gradient->number_stops)
composite=gradient->stops[gradient->number_stops-1].color;
else
{
else
alpha=gradient->radius-repeat;
i=0;
- j=(long) gradient->number_stops-1L;
+ j=(ssize_t) gradient->number_stops-1L;
}
MagickPixelCompositeBlend(&gradient->stops[i].color,1.0-alpha,
&gradient->stops[j].color,alpha,&composite);
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(draw_info != (const DrawInfo *) NULL);
assert(name != (const char *) NULL);
- (void) FormatMagickString(property,MaxTextExtent,"%s",name);
+ (void) FormatLocaleString(property,MaxTextExtent,"%s",name);
path=GetImageArtifact(image,property);
if (path == (const char *) NULL)
return(MagickFalse);
- (void) FormatMagickString(property,MaxTextExtent,"%s-geometry",name);
+ (void) FormatLocaleString(property,MaxTextExtent,"%s-geometry",name);
geometry=GetImageArtifact(image,property);
if (geometry == (const char *) NULL)
return(MagickFalse);
static PolygonInfo **DestroyPolygonThreadSet(PolygonInfo **polygon_info)
{
- register long
+ register ssize_t
i;
assert(polygon_info != (PolygonInfo **) NULL);
- for (i=0; i < (long) GetOpenMPMaximumThreads(); i++)
+ for (i=0; i < (ssize_t) GetOpenMPMaximumThreads(); i++)
if (polygon_info[i] != (PolygonInfo *) NULL)
polygon_info[i]=DestroyPolygonInfo(polygon_info[i]);
- polygon_info=(PolygonInfo **) RelinquishAlignedMemory(polygon_info);
+ polygon_info=(PolygonInfo **) RelinquishMagickMemory(polygon_info);
return(polygon_info);
}
const PrimitiveInfo *primitive_info)
{
PathInfo
- *path_info;
-
- register long
- i;
+ *restrict path_info;
PolygonInfo
**polygon_info;
- unsigned long
+ register ssize_t
+ i;
+
+ size_t
number_threads;
number_threads=GetOpenMPMaximumThreads();
- polygon_info=(PolygonInfo **) AcquireAlignedMemory(number_threads,
+ polygon_info=(PolygonInfo **) AcquireQuantumMemory(number_threads,
sizeof(*polygon_info));
if (polygon_info == (PolygonInfo **) NULL)
return((PolygonInfo **) NULL);
path_info=ConvertPrimitiveToPath(draw_info,primitive_info);
if (path_info == (PathInfo *) NULL)
return(DestroyPolygonThreadSet(polygon_info));
- for (i=0; i < (long) number_threads; i++)
+ for (i=0; i < (ssize_t) number_threads; i++)
{
polygon_info[i]=ConvertPathToPolygon(draw_info,path_info);
if (polygon_info[i] == (PolygonInfo *) NULL)
static MagickRealType GetPixelOpacity(PolygonInfo *polygon_info,
const MagickRealType mid,const MagickBooleanType fill,
- const FillRule fill_rule,const long x,const long y,
+ const FillRule fill_rule,const double x,const double y,
MagickRealType *stroke_opacity)
{
- int
- winding_number;
-
- long
- j;
-
MagickRealType
alpha,
beta,
register const PointInfo
*q;
- register long
+ register ssize_t
i;
+ ssize_t
+ j,
+ winding_number;
+
/*
Compute fill & stroke opacity for this (x,y) point.
*/
*stroke_opacity=0.0;
subpath_opacity=0.0;
p=polygon_info->edges;
- for (j=0; j < (long) polygon_info->number_edges; j++, p++)
+ for (j=0; j < (ssize_t) polygon_info->number_edges; j++, p++)
{
if (y <= (p->bounds.y1-mid-0.5))
break;
if (y > (p->bounds.y2+mid+0.5))
{
- (void) DestroyEdge(polygon_info,j);
+ (void) DestroyEdge(polygon_info,(size_t) j);
continue;
}
if ((x <= (p->bounds.x1-mid-0.5)) || (x > (p->bounds.x2+mid+0.5)))
continue;
- for (i=MagickMax(p->highwater,1); i < (long) p->number_points; i++)
+ 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))
break;
if (p->scanline != y)
{
p->scanline=y;
- p->highwater=i;
+ p->highwater=(size_t) i;
}
/*
Compute distance between a point and an edge.
*/
winding_number=0;
p=polygon_info->edges;
- for (j=0; j < (long) polygon_info->number_edges; j++, p++)
+ for (j=0; j < (ssize_t) polygon_info->number_edges; j++, p++)
{
if (y <= p->bounds.y1)
break;
winding_number+=p->direction ? 1 : -1;
continue;
}
- for (i=MagickMax(p->highwater,1); i < (long) p->number_points; i++)
+ i=(ssize_t) MagickMax((double) p->highwater,1.0);
+ for ( ; i < (ssize_t) p->number_points; i++)
if (y <= p->points[i].y)
break;
q=p->points+i-1;
static MagickBooleanType DrawPolygonPrimitive(Image *image,
const DrawInfo *draw_info,const PrimitiveInfo *primitive_info)
{
+ CacheView
+ *image_view;
+
ExceptionInfo
*exception;
- long
- start,
- stop,
- y;
-
MagickBooleanType
fill,
status;
mid;
PolygonInfo
- **polygon_info;
+ **restrict polygon_info;
register EdgeInfo
*p;
- register long
+ register ssize_t
i;
SegmentInfo
bounds;
- CacheView
- *image_view;
+ ssize_t
+ start,
+ stop,
+ y;
/*
Compute bounding box.
(primitive_info->method == FloodfillMethod) ? MagickTrue : MagickFalse;
mid=ExpandAffine(&draw_info->affine)*draw_info->stroke_width/2.0;
bounds=polygon_info[0]->edges[0].bounds;
- for (i=1; i < (long) polygon_info[0]->number_edges; i++)
+ for (i=1; i < (ssize_t) polygon_info[0]->number_edges; i++)
{
p=polygon_info[0]->edges+i;
if (p->bounds.x1 < bounds.x1)
bounds.y2=p->bounds.y2;
}
bounds.x1-=(mid+1.0);
- bounds.x1=bounds.x1 < 0.0 ? 0.0 : (unsigned long) (bounds.x1+0.5) >=
+ bounds.x1=bounds.x1 < 0.0 ? 0.0 : (size_t) ceil(bounds.x1-0.5) >=
image->columns ? (double) image->columns-1.0 : bounds.x1;
bounds.y1-=(mid+1.0);
- bounds.y1=bounds.y1 < 0.0 ? 0.0 : (unsigned long) (bounds.y1+0.5) >=
+ bounds.y1=bounds.y1 < 0.0 ? 0.0 : (size_t) ceil(bounds.y1-0.5) >=
image->rows ? (double) image->rows-1.0 : bounds.y1;
bounds.x2+=(mid+1.0);
- bounds.x2=bounds.x2 < 0.0 ? 0.0 : (unsigned long) (bounds.x2+0.5) >=
+ bounds.x2=bounds.x2 < 0.0 ? 0.0 : (size_t) floor(bounds.x2+0.5) >=
image->columns ? (double) image->columns-1.0 : bounds.x2;
bounds.y2+=(mid+1.0);
- bounds.y2=bounds.y2 < 0.0 ? 0.0 : (unsigned long) (bounds.y2+0.5) >=
+ bounds.y2=bounds.y2 < 0.0 ? 0.0 : (size_t) floor(bounds.y2+0.5) >=
image->rows ? (double) image->rows-1.0 : bounds.y2;
status=MagickTrue;
exception=(&image->exception);
- start=(long) (bounds.x1+0.5);
- stop=(long) (bounds.x2+0.5);
+ start=(ssize_t) ceil(bounds.x1-0.5);
+ stop=(ssize_t) floor(bounds.x2+0.5);
image_view=AcquireCacheView(image);
if (primitive_info->coordinates == 1)
{
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(status)
#endif
- for (y=(long) (bounds.y1+0.5); y <= (long) (bounds.y2+0.5); y++)
+ for (y=(ssize_t) ceil(bounds.y1-0.5); y <= (ssize_t) floor(bounds.y2+0.5); y++)
{
MagickBooleanType
sync;
- register long
+ register ssize_t
x;
register PixelPacket
if (status == MagickFalse)
continue;
x=start;
- q=GetCacheViewAuthenticPixels(image_view,x,y,(unsigned long) (stop-x+1),
+ q=GetCacheViewAuthenticPixels(image_view,x,y,(size_t) (stop-x+1),
1,exception);
if (q == (PixelPacket *) NULL)
{
}
for ( ; x <= stop; x++)
{
- if ((x == (long) (primitive_info->point.x+0.5)) &&
- (y == (long) (primitive_info->point.y+0.5)))
+ if ((x == (ssize_t) ceil(primitive_info->point.x-0.5)) &&
+ (y == (ssize_t) ceil(primitive_info->point.y-0.5)))
(void) GetStrokeColor(draw_info,x,y,q);
q++;
}
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(status)
#endif
- for (y=(long) (bounds.y1+0.5); y <= (long) (bounds.y2+0.5); y++)
+ for (y=(ssize_t) ceil(bounds.y1-0.5); y <= (ssize_t) floor(bounds.y2+0.5); y++)
{
+ const int
+ id = GetOpenMPThreadId();
+
MagickRealType
fill_opacity,
stroke_opacity;
fill_color,
stroke_color;
- register long
- id,
- x;
-
register PixelPacket
*restrict q;
+ register ssize_t
+ x;
+
if (status == MagickFalse)
continue;
- q=GetCacheViewAuthenticPixels(image_view,start,y,(unsigned long) (stop-
+ q=GetCacheViewAuthenticPixels(image_view,start,y,(size_t) (stop-
start+1),1,exception);
if (q == (PixelPacket *) NULL)
{
status=MagickFalse;
continue;
}
- id=GetOpenMPThreadId();
for (x=start; x <= stop; x++)
{
/*
Fill and/or stroke.
*/
fill_opacity=GetPixelOpacity(polygon_info[id],mid,fill,
- draw_info->fill_rule,x,y,&stroke_opacity);
+ draw_info->fill_rule,(double) x,(double) y,&stroke_opacity);
if (draw_info->stroke_antialias == MagickFalse)
{
fill_opacity=fill_opacity > 0.25 ? 1.0 : 0.0;
"?"
};
- long
- coordinates,
- y;
-
PointInfo
p,
q,
point;
- register long
+ register ssize_t
i,
x;
- x=(long) (primitive_info->point.x+0.5);
- y=(long) (primitive_info->point.y+0.5);
+ ssize_t
+ coordinates,
+ y;
+
+ x=(ssize_t) ceil(primitive_info->point.x-0.5);
+ y=(ssize_t) ceil(primitive_info->point.y-0.5);
switch (primitive_info->primitive)
{
case PointPrimitive:
{
(void) LogMagickEvent(DrawEvent,GetMagickModule(),
- "PointPrimitive %ld,%ld %s",x,y,methods[primitive_info->method]);
+ "PointPrimitive %.20g,%.20g %s",(double) x,(double) y,
+ methods[primitive_info->method]);
return;
}
case ColorPrimitive:
{
(void) LogMagickEvent(DrawEvent,GetMagickModule(),
- "ColorPrimitive %ld,%ld %s",x,y,methods[primitive_info->method]);
+ "ColorPrimitive %.20g,%.20g %s",(double) x,(double) y,
+ methods[primitive_info->method]);
return;
}
case MattePrimitive:
{
(void) LogMagickEvent(DrawEvent,GetMagickModule(),
- "MattePrimitive %ld,%ld %s",x,y,methods[primitive_info->method]);
+ "MattePrimitive %.20g,%.20g %s",(double) x,(double) y,
+ methods[primitive_info->method]);
return;
}
case TextPrimitive:
{
(void) LogMagickEvent(DrawEvent,GetMagickModule(),
- "TextPrimitive %ld,%ld",x,y);
+ "TextPrimitive %.20g,%.20g",(double) x,(double) y);
return;
}
case ImagePrimitive:
{
(void) LogMagickEvent(DrawEvent,GetMagickModule(),
- "ImagePrimitive %ld,%ld",x,y);
+ "ImagePrimitive %.20g,%.20g",(double) x,(double) y);
return;
}
default:
point=primitive_info[i].point;
if (coordinates <= 0)
{
- coordinates=(long) primitive_info[i].coordinates;
+ coordinates=(ssize_t) primitive_info[i].coordinates;
(void) LogMagickEvent(DrawEvent,GetMagickModule(),
- " begin open (%ld)",coordinates);
+ " begin open (%.20g)",(double) coordinates);
p=point;
}
point=primitive_info[i].point;
if ((fabs(q.x-point.x) > MagickEpsilon) ||
(fabs(q.y-point.y) > MagickEpsilon))
- (void) LogMagickEvent(DrawEvent,GetMagickModule()," %ld: %g,%g",
- coordinates,point.x,point.y);
+ (void) LogMagickEvent(DrawEvent,GetMagickModule(),
+ " %.20g: %.18g,%.18g",(double) coordinates,point.x,point.y);
else
(void) LogMagickEvent(DrawEvent,GetMagickModule(),
- " %ld: %g,%g (duplicate)",coordinates,point.x,point.y);
+ " %.20g: %g %g (duplicate)",(double) coordinates,point.x,point.y);
q=point;
coordinates--;
if (coordinates > 0)
continue;
if ((fabs(p.x-point.x) > MagickEpsilon) ||
(fabs(p.y-point.y) > MagickEpsilon))
- (void) LogMagickEvent(DrawEvent,GetMagickModule()," end last (%ld)",
- coordinates);
+ (void) LogMagickEvent(DrawEvent,GetMagickModule()," end last (%.20g)",
+ (double) coordinates);
else
- (void) LogMagickEvent(DrawEvent,GetMagickModule()," end open (%ld)",
- coordinates);
+ (void) LogMagickEvent(DrawEvent,GetMagickModule()," end open (%.20g)",
+ (double) coordinates);
}
}
MagickExport MagickBooleanType DrawPrimitive(Image *image,
const DrawInfo *draw_info,const PrimitiveInfo *primitive_info)
{
+ CacheView
+ *image_view;
+
ExceptionInfo
*exception;
- long
- y;
-
MagickStatusType
status;
- register long
+ register ssize_t
i,
x;
- CacheView
- *image_view;
+ ssize_t
+ y;
if (image->debug != MagickFalse)
{
(void) LogMagickEvent(DrawEvent,GetMagickModule(),
" begin draw-primitive");
(void) LogMagickEvent(DrawEvent,GetMagickModule(),
- " affine: %g,%g,%g,%g,%g,%g",draw_info->affine.sx,
+ " affine: %g %g %g %g %g %g",draw_info->affine.sx,
draw_info->affine.rx,draw_info->affine.ry,draw_info->affine.sy,
draw_info->affine.tx,draw_info->affine.ty);
}
status=MagickTrue;
exception=(&image->exception);
- x=(long) (primitive_info->point.x+0.5);
- y=(long) (primitive_info->point.y+0.5);
+ x=(ssize_t) ceil(primitive_info->point.x-0.5);
+ y=(ssize_t) ceil(primitive_info->point.y-0.5);
image_view=AcquireCacheView(image);
switch (primitive_info->primitive)
{
PixelPacket
*q;
- if ((y < 0) || (y >= (long) image->rows))
+ if ((y < 0) || (y >= (ssize_t) image->rows))
break;
- if ((x < 0) || (x >= (long) image->columns))
+ if ((x < 0) || (x >= (ssize_t) image->columns))
break;
q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
if (q == (PixelPacket *) NULL)
target;
(void) GetOneCacheViewVirtualPixel(image_view,x,y,&target,exception);
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
register PixelPacket
*restrict q;
exception);
if (q == (PixelPacket *) NULL)
break;
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
if (IsColorSimilar(image,q,&target) == MagickFalse)
{
MagickBooleanType
sync;
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
- register long
- x;
-
register PixelPacket
*restrict q;
+ register ssize_t
+ x;
+
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
if (q == (PixelPacket *) NULL)
break;
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
(void) GetFillColor(draw_info,x,y,q);
q++;
if (q == (PixelPacket *) NULL)
break;
(void) GetFillColor(draw_info,x,y,&pixel);
- q->opacity=pixel.opacity;
+ SetOpacityPixelComponent(q,pixel.opacity);
(void) SyncCacheViewAuthenticPixels(image_view,exception);
break;
}
target;
(void) GetOneCacheViewVirtualPixel(image_view,x,y,&target,exception);
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
- register long
- x;
-
register PixelPacket
*restrict q;
+ register ssize_t
+ x;
+
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
if (q == (PixelPacket *) NULL)
break;
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
if (IsColorSimilar(image,q,&target) == MagickFalse)
{
continue;
}
(void) GetFillColor(draw_info,x,y,&pixel);
- q->opacity=pixel.opacity;
+ SetOpacityPixelComponent(q,pixel.opacity);
q++;
}
sync=SyncCacheViewAuthenticPixels(image_view,exception);
PixelPacket
pixel;
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
- register long
- x;
-
register PixelPacket
*restrict q;
+ register ssize_t
+ x;
+
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
if (q == (PixelPacket *) NULL)
break;
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
(void) GetFillColor(draw_info,x,y,&pixel);
- q->opacity=pixel.opacity;
+ SetOpacityPixelComponent(q,pixel.opacity);
q++;
}
sync=SyncCacheViewAuthenticPixels(image_view,exception);
break;
clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
(void) CloneString(&clone_info->text,primitive_info->text);
- (void) FormatMagickString(geometry,MaxTextExtent,"%+f%+f",
+ (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);
ImageInfo
*clone_info;
- long
- x1,
- y1;
-
RectangleInfo
geometry;
+ ssize_t
+ x1,
+ y1;
+
if (primitive_info->text == (char *) NULL)
break;
clone_info=AcquireImageInfo();
break;
(void) SetImageProgressMonitor(composite_image,(MagickProgressMonitor)
NULL,(void *) NULL);
- x1=(long) (primitive_info[1].point.x+0.5);
- y1=(long) (primitive_info[1].point.y+0.5);
- if (((x1 != 0L) && (x1 != (long) composite_image->columns)) ||
- ((y1 != 0L) && (y1 != (long) composite_image->rows)))
+ x1=(ssize_t) ceil(primitive_info[1].point.x-0.5);
+ y1=(ssize_t) ceil(primitive_info[1].point.y-0.5);
+ if (((x1 != 0L) && (x1 != (ssize_t) composite_image->columns)) ||
+ ((y1 != 0L) && (y1 != (ssize_t) composite_image->rows)))
{
char
geometry[MaxTextExtent];
/*
Resize image.
*/
- (void) FormatMagickString(geometry,MaxTextExtent,"%gx%g!",
+ (void) FormatLocaleString(geometry,MaxTextExtent,"%gx%g!",
primitive_info[1].point.x,primitive_info[1].point.y);
composite_image->filter=image->filter;
(void) TransformImage(&composite_image,(char *) NULL,geometry);
image->gravity=draw_info->gravity;
geometry.x=x;
geometry.y=y;
- (void) FormatMagickString(composite_geometry,MaxTextExtent,
- "%lux%lu%+ld%+ld",composite_image->columns,composite_image->rows,
- geometry.x,geometry.y);
+ (void) FormatLocaleString(composite_geometry,MaxTextExtent,
+ "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,(double)
+ composite_image->rows,(double) geometry.x,(double) geometry.y);
(void) ParseGravityGeometry(image,composite_geometry,&geometry,
&image->exception);
affine=draw_info->affine;
(primitive_info[i-1].point.x == primitive_info[0].point.x) &&
(primitive_info[i-1].point.y == primitive_info[0].point.y) ?
MagickTrue : MagickFalse;
- i=(long) primitive_info[0].coordinates;
+ i=(ssize_t) primitive_info[0].coordinates;
if ((((draw_info->linecap == RoundCap) ||
(closed_path != MagickFalse)) &&
(draw_info->linejoin == RoundJoin)) ||
PrimitiveInfo
linecap[5];
- register long
+ register ssize_t
i;
for (i=0; i < 4; i++)
(void) CloneString(&draw_info->encoding,option);
option=GetImageOption(clone_info,"kerning");
if (option != (const char *) NULL)
- draw_info->kerning=StringToDouble(option);
+ draw_info->kerning=InterpretLocaleValue(option,(char **) NULL);
option=GetImageOption(clone_info,"interline-spacing");
if (option != (const char *) NULL)
- draw_info->interline_spacing=StringToDouble(option);
+ draw_info->interline_spacing=InterpretLocaleValue(option,(char **) NULL);
+ draw_info->direction=UndefinedDirection;
option=GetImageOption(clone_info,"interword-spacing");
if (option != (const char *) NULL)
- draw_info->interword_spacing=StringToDouble(option);
+ draw_info->interword_spacing=InterpretLocaleValue(option,(char **) NULL);
+ option=GetImageOption(clone_info,"direction");
+ if (option != (const char *) NULL)
+ draw_info->direction=(DirectionType) ParseCommandOption(
+ MagickDirectionOptions,MagickFalse,option);
option=GetImageOption(clone_info,"fill");
if (option != (const char *) NULL)
(void) QueryColorDatabase(option,&draw_info->fill,exception);
(void) QueryColorDatabase(option,&draw_info->stroke,exception);
option=GetImageOption(clone_info,"strokewidth");
if (option != (const char *) NULL)
- draw_info->stroke_width=StringToDouble(option);
+ draw_info->stroke_width=InterpretLocaleValue(option,(char **) NULL);
option=GetImageOption(clone_info,"undercolor");
if (option != (const char *) NULL)
(void) QueryColorDatabase(option,&draw_info->undercolor,exception);
option=GetImageOption(clone_info,"gravity");
if (option != (const char *) NULL)
- draw_info->gravity=(GravityType) ParseMagickOption(MagickGravityOptions,
+ draw_info->gravity=(GravityType) ParseCommandOption(MagickGravityOptions,
MagickFalse,option);
exception=DestroyExceptionInfo(exception);
draw_info->signature=MagickSignature;
%
% The format of the Permutate method is:
%
-% void Permutate(long n,long k)
+% void Permutate(ssize_t n,ssize_t k)
%
% A description of each parameter follows:
%
%
%
*/
-static inline MagickRealType Permutate(const long n,const long k)
+static inline MagickRealType Permutate(const ssize_t n,const ssize_t k)
{
MagickRealType
r;
- register long
+ register ssize_t
i;
r=1.0;
register PrimitiveInfo
*p;
- register long
+ register ssize_t
i;
- unsigned long
+ size_t
arc_segments;
if ((start.x == end.x) && (start.y == end.y))
else
if ((theta > 0.0) && (sweep == MagickFalse))
theta-=(MagickRealType) (2.0*MagickPI);
- arc_segments=(unsigned long) ceil(fabs((double) (theta/(0.5*MagickPI+
+ arc_segments=(size_t) ceil(fabs((double) (theta/(0.5*MagickPI+
MagickEpsilon))));
p=primitive_info;
- for (i=0; i < (long) arc_segments; i++)
+ for (i=0; i < (ssize_t) arc_segments; i++)
{
beta=0.5*((alpha+(i+1)*theta/arc_segments)-(alpha+i*theta/arc_segments));
gamma=(8.0/3.0)*sin(fmod((double) (0.5*beta),DegreesToRadians(360.0)))*
points[2].y);
(p+3)->point.y=(double) (sine*radii.x*points[2].x+cosine*radii.y*
points[2].y);
- if (i == (long) (arc_segments-1))
+ if (i == (ssize_t) (arc_segments-1))
(p+3)->point=end;
TraceBezier(p,4);
p+=p->coordinates;
}
- primitive_info->coordinates=(unsigned long) (p-primitive_info);
- for (i=0; i < (long) primitive_info->coordinates; i++)
+ primitive_info->coordinates=(size_t) (p-primitive_info);
+ for (i=0; i < (ssize_t) primitive_info->coordinates; i++)
{
p->primitive=primitive_info->primitive;
p--;
}
static void TraceBezier(PrimitiveInfo *primitive_info,
- const unsigned long number_coordinates)
+ const size_t number_coordinates)
{
MagickRealType
alpha,
point,
*points;
- register long
- i,
- j;
-
register PrimitiveInfo
*p;
- unsigned long
+ register ssize_t
+ i,
+ j;
+
+ size_t
control_points,
quantum;
Allocate coeficients.
*/
quantum=number_coordinates;
- for (i=0; i < (long) number_coordinates; i++)
+ for (i=0; i < (ssize_t) number_coordinates; i++)
{
- for (j=i+1; j < (long) number_coordinates; j++)
+ 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)
- quantum=(unsigned long) alpha;
+ quantum=(size_t) alpha;
alpha=fabs(primitive_info[j].point.y-primitive_info[i].point.y);
if (alpha > (MagickRealType) quantum)
- quantum=(unsigned long) alpha;
+ quantum=(size_t) alpha;
}
}
- quantum=(unsigned long) MagickMin((double) quantum/number_coordinates,
+ quantum=(size_t) MagickMin((double) quantum/number_coordinates,
(double) BezierQuantum);
control_points=quantum*number_coordinates;
coefficients=(MagickRealType *) AcquireQuantumMemory((size_t)
Compute bezier points.
*/
end=primitive_info[number_coordinates-1].point;
- for (i=0; i < (long) number_coordinates; i++)
- coefficients[i]=Permutate((long) number_coordinates-1,i);
+ for (i=0; i < (ssize_t) number_coordinates; i++)
+ coefficients[i]=Permutate((ssize_t) number_coordinates-1,i);
weight=0.0;
- for (i=0; i < (long) control_points; i++)
+ for (i=0; i < (ssize_t) control_points; i++)
{
p=primitive_info;
point.x=0.0;
point.y=0.0;
alpha=pow((double) (1.0-weight),(double) number_coordinates-1.0);
- for (j=0; j < (long) number_coordinates; j++)
+ for (j=0; j < (ssize_t) number_coordinates; j++)
{
point.x+=alpha*coefficients[j]*p->point.x;
point.y+=alpha*coefficients[j]*p->point.y;
Bezier curves are just short segmented polys.
*/
p=primitive_info;
- for (i=0; i < (long) control_points; i++)
+ for (i=0; i < (ssize_t) control_points; i++)
{
TracePoint(p,points[i]);
p+=p->coordinates;
}
TracePoint(p,end);
p+=p->coordinates;
- primitive_info->coordinates=(unsigned long) (p-primitive_info);
- for (i=0; i < (long) primitive_info->coordinates; i++)
+ primitive_info->coordinates=(size_t) (p-primitive_info);
+ for (i=0; i < (ssize_t) primitive_info->coordinates; i++)
{
p->primitive=primitive_info->primitive;
p--;
register PrimitiveInfo
*p;
- register long
+ register ssize_t
i;
/*
}
delta=2.0/MagickMax(stop.x,stop.y);
step=(MagickRealType) (MagickPI/8.0);
- if (delta < (MagickPI/8.0))
- step=MagickPI/(4*(MagickPI/delta/2+0.5));
+ if ((delta >= 0.0) && (delta < (MagickRealType) (MagickPI/8.0)))
+ step=(MagickRealType) (MagickPI/(4*(MagickPI/delta/2+0.5)));
angle.x=DegreesToRadians(degrees.x);
y=degrees.y;
while (y < degrees.x)
point.y=sin(fmod(angle.y,DegreesToRadians(360.0)))*stop.y+start.y;
TracePoint(p,point);
p+=p->coordinates;
- primitive_info->coordinates=(unsigned long) (p-primitive_info);
- for (i=0; i < (long) primitive_info->coordinates; i++)
+ primitive_info->coordinates=(size_t) (p-primitive_info);
+ for (i=0; i < (ssize_t) primitive_info->coordinates; i++)
{
p->primitive=primitive_info->primitive;
p--;
primitive_info->coordinates=2;
}
-static unsigned long TracePath(PrimitiveInfo *primitive_info,const char *path)
+static size_t TracePath(PrimitiveInfo *primitive_info,const char *path)
{
char
token[MaxTextExtent];
register PrimitiveInfo
*q;
- register long
+ register ssize_t
i;
- unsigned long
+ size_t
number_coordinates,
z_count;
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
- arc.x=StringToDouble(token);
+ arc.x=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
- arc.y=StringToDouble(token);
+ arc.y=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
- angle=StringToDouble(token);
+ angle=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
- x=StringToDouble(token);
+ x=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
- y=StringToDouble(token);
+ y=InterpretLocaleValue(token,(char **) NULL);
end.x=(double) (attribute == (int) 'A' ? x : point.x+x);
end.y=(double) (attribute == (int) 'A' ? y : point.y+y);
TraceArcPath(q,point,end,arc,angle,large_arc,sweep);
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
- x=StringToDouble(token);
+ x=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
- y=StringToDouble(token);
+ y=InterpretLocaleValue(token,(char **) NULL);
end.x=(double) (attribute == (int) 'C' ? x : point.x+x);
end.y=(double) (attribute == (int) 'C' ? y : point.y+y);
points[i]=end;
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
- x=StringToDouble(token);
+ x=InterpretLocaleValue(token,(char **) NULL);
point.x=(double) (attribute == (int) 'H' ? x: point.x+x);
TracePoint(q,point);
q+=q->coordinates;
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
- x=StringToDouble(token);
+ x=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
- y=StringToDouble(token);
+ y=InterpretLocaleValue(token,(char **) NULL);
point.x=(double) (attribute == (int) 'L' ? x : point.x+x);
point.y=(double) (attribute == (int) 'L' ? y : point.y+y);
TracePoint(q,point);
{
if (q != primitive_info)
{
- primitive_info->coordinates=(unsigned long) (q-primitive_info);
+ primitive_info->coordinates=(size_t) (q-primitive_info);
number_coordinates+=primitive_info->coordinates;
primitive_info=q;
}
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
- x=StringToDouble(token);
+ x=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
- y=StringToDouble(token);
+ y=InterpretLocaleValue(token,(char **) NULL);
point.x=(double) (attribute == (int) 'M' ? x : point.x+x);
point.y=(double) (attribute == (int) 'M' ? y : point.y+y);
if (i == 0)
i++;
TracePoint(q,point);
q+=q->coordinates;
- if (attribute == (int) 'M')
+ if ((i != 0) && (attribute == (int) 'M'))
{
TracePoint(q,point);
q+=q->coordinates;
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
- x=StringToDouble(token);
+ x=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
- y=StringToDouble(token);
+ y=InterpretLocaleValue(token,(char **) NULL);
if (*p == ',')
p++;
end.x=(double) (attribute == (int) 'Q' ? x : point.x+x);
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
- x=StringToDouble(token);
+ x=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
- y=StringToDouble(token);
+ y=InterpretLocaleValue(token,(char **) NULL);
if (*p == ',')
p++;
end.x=(double) (attribute == (int) 'S' ? x : point.x+x);
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
- x=StringToDouble(token);
+ x=InterpretLocaleValue(token,(char **) NULL);
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
- y=StringToDouble(token);
+ y=InterpretLocaleValue(token,(char **) NULL);
end.x=(double) (attribute == (int) 'T' ? x : point.x+x);
end.y=(double) (attribute == (int) 'T' ? y : point.y+y);
points[i]=end;
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
- y=StringToDouble(token);
+ y=InterpretLocaleValue(token,(char **) NULL);
point.y=(double) (attribute == (int) 'V' ? y : point.y+y);
TracePoint(q,point);
q+=q->coordinates;
point=start;
TracePoint(q,point);
q+=q->coordinates;
- primitive_info->coordinates=(unsigned long) (q-primitive_info);
+ primitive_info->coordinates=(size_t) (q-primitive_info);
number_coordinates+=primitive_info->coordinates;
primitive_info=q;
z_count++;
default:
{
if (isalpha((int) ((unsigned char) attribute)) != 0)
- (void) fprintf(stderr,"attribute not recognized: %c\n",attribute);
+ (void) FormatLocaleFile(stderr,"attribute not recognized: %c\n",
+ attribute);
break;
}
}
}
- primitive_info->coordinates=(unsigned long) (q-primitive_info);
+ primitive_info->coordinates=(size_t) (q-primitive_info);
number_coordinates+=primitive_info->coordinates;
- for (i=0; i < (long) number_coordinates; i++)
+ for (i=0; i < (ssize_t) number_coordinates; i++)
{
q--;
q->primitive=primitive_type;
register PrimitiveInfo
*p;
- register long
+ register ssize_t
i;
p=primitive_info;
p+=p->coordinates;
TracePoint(p,start);
p+=p->coordinates;
- primitive_info->coordinates=(unsigned long) (p-primitive_info);
- for (i=0; i < (long) primitive_info->coordinates; i++)
+ primitive_info->coordinates=(size_t) (p-primitive_info);
+ for (i=0; i < (ssize_t) primitive_info->coordinates; i++)
{
p->primitive=primitive_info->primitive;
p--;
register PrimitiveInfo
*p;
- register long
+ register ssize_t
i;
p=primitive_info;
p+=p->coordinates;
TracePoint(p,primitive_info->point);
p+=p->coordinates;
- primitive_info->coordinates=(unsigned long) (p-primitive_info);
- for (i=0; i < (long) primitive_info->coordinates; i++)
+ primitive_info->coordinates=(size_t) (p-primitive_info);
+ for (i=0; i < (ssize_t) primitive_info->coordinates; i++)
{
p->primitive=primitive_info->primitive;
p--;
}
static void TraceSquareLinecap(PrimitiveInfo *primitive_info,
- const unsigned long number_vertices,const MagickRealType offset)
+ const size_t number_vertices,const MagickRealType offset)
{
MagickRealType
distance;
- long
- j;
-
register MagickRealType
dx,
dy;
- register long
+ register ssize_t
i;
+ ssize_t
+ j;
+
dx=0.0;
dy=0.0;
- for (i=1; i < (long) number_vertices; i++)
+ for (i=1; i < (ssize_t) number_vertices; i++)
{
dx=primitive_info[0].point.x-primitive_info[i].point.x;
dy=primitive_info[0].point.y-primitive_info[i].point.y;
(fabs((double) dy) >= MagickEpsilon))
break;
}
- if (i == (long) number_vertices)
- i=(long) number_vertices-1L;
+ if (i == (ssize_t) number_vertices)
+ i=(ssize_t) number_vertices-1L;
distance=hypot((double) dx,(double) dy);
primitive_info[0].point.x=(double) (primitive_info[i].point.x+
dx*(distance+offset)/distance);
primitive_info[0].point.y=(double) (primitive_info[i].point.y+
dy*(distance+offset)/distance);
- for (j=(long) number_vertices-2; j >= 0; j--)
+ for (j=(ssize_t) number_vertices-2; j >= 0; j--)
{
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;
slope,
theta;
- long
- j,
- n,
- p,
- q;
-
MagickBooleanType
closed_path;
*polygon_primitive,
*stroke_polygon;
- register long
+ register ssize_t
i;
- unsigned long
+ size_t
arc_segments,
max_strokes,
number_vertices;
+ ssize_t
+ j,
+ n,
+ p,
+ q;
+
/*
Allocate paths.
*/
*/
dx.p=0.0;
dy.p=0.0;
- for (n=1; n < (long) number_vertices; n++)
+ for (n=1; n < (ssize_t) number_vertices; n++)
{
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) >= MagickEpsilon) || (fabs(dy.p) >= MagickEpsilon))
break;
}
- if (n == (long) number_vertices)
- n=(long) number_vertices-1L;
+ 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) <= MagickEpsilon)
q=0;
path_q[p++]=box_q[0];
path_p[q++]=box_p[0];
- for (i=(long) n+1; i < (long) number_vertices; i++)
+ for (i=(ssize_t) n+1; i < (ssize_t) number_vertices; i++)
{
/*
Compute the slope for this line segment, q.
box_q[3].y)/(slope.p-slope.q));
box_q[4].y=(double) (slope.p*(box_q[4].x-box_q[0].x)+box_q[0].y);
}
- if (q >= (long) (max_strokes-6*BezierQuantum-360))
+ if (q >= (ssize_t) (max_strokes-6*BezierQuantum-360))
{
max_strokes+=6*BezierQuantum+360;
path_p=(PointInfo *) ResizeQuantumMemory(path_p,(size_t) max_strokes,
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);
- arc_segments=(unsigned long) ceil((double) ((theta.q-theta.p)/
+ 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;
path_q[q].y=box_q[1].y;
q++;
- for (j=1; j < (long) arc_segments; j++)
+ for (j=1; j < (ssize_t) arc_segments; j++)
{
delta_theta=(MagickRealType) (j*(theta.q-theta.p)/arc_segments);
path_q[q].x=(double) (center.x+mid*cos(fmod((double)
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);
- arc_segments=(unsigned long) ceil((double) ((theta.p-theta.q)/
+ 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 < (long) arc_segments; j++)
+ for (j=1; j < (ssize_t) arc_segments; j++)
{
delta_theta=(MagickRealType) (j*(theta.q-theta.p)/arc_segments);
path_p[p].x=(double) (center.x+mid*cos(fmod((double)
(p+q+2UL*closed_path+2UL),sizeof(*stroke_polygon));
if (stroke_polygon != (PrimitiveInfo *) NULL)
{
- for (i=0; i < (long) p; i++)
+ for (i=0; i < (ssize_t) p; i++)
{
stroke_polygon[i]=polygon_primitive[0];
stroke_polygon[i].point=path_p[i];
stroke_polygon[i].point=stroke_polygon[0].point;
i++;
}
- for ( ; i < (long) (p+q+closed_path); i++)
+ for ( ; i < (ssize_t) (p+q+closed_path); i++)
{
stroke_polygon[i]=polygon_primitive[0];
stroke_polygon[i].point=path_q[p+q+closed_path-(i+1)];
stroke_polygon[i].point=stroke_polygon[0].point;
i++;
stroke_polygon[i].primitive=UndefinedPrimitive;
- stroke_polygon[0].coordinates=(unsigned long) (p+q+2*closed_path+1);
+ stroke_polygon[0].coordinates=(size_t) (p+q+2*closed_path+1);
}
path_p=(PointInfo *) RelinquishMagickMemory(path_p);
path_q=(PointInfo *) RelinquishMagickMemory(path_q);