This source file includes following definitions.
- MVGPrintf
- MVGAutoWrapPrintf
- MVGAppendColor
- MVGAppendPointsCommand
- AdjustAffine
- AcquireDrawingWand
- ClearDrawingWand
- CloneDrawingWand
- DestroyDrawingWand
- DrawAffine
- DrawAnnotation
- DrawArc
- DrawBezier
- DrawCircle
- DrawClearException
- DrawComposite
- DrawColor
- DrawComment
- DrawEllipse
- DrawGetBorderColor
- DrawGetClipPath
- DrawGetClipRule
- DrawGetClipUnits
- DrawGetDensity
- DrawGetException
- DrawGetExceptionType
- DrawGetFillColor
- DrawGetFillOpacity
- DrawGetFillRule
- DrawGetFont
- DrawGetFontFamily
- DrawGetFontResolution
- DrawGetFontSize
- DrawGetFontStretch
- DrawGetFontStyle
- DrawGetFontWeight
- DrawGetGravity
- DrawGetOpacity
- DrawGetStrokeAntialias
- DrawGetStrokeColor
- DrawGetStrokeDashArray
- DrawGetStrokeDashOffset
- DrawGetStrokeLineCap
- DrawGetStrokeLineJoin
- DrawGetStrokeMiterLimit
- DrawGetStrokeOpacity
- DrawGetStrokeWidth
- DrawGetTextAlignment
- DrawGetTextAntialias
- DrawGetTextDecoration
- DrawGetTextDirection
- DrawGetTextEncoding
- DrawGetTextKerning
- DrawGetTextInterlineSpacing
- DrawGetTextInterwordSpacing
- SetMagickPixelPacket
- DrawGetVectorGraphics
- DrawGetTextUnderColor
- DrawLine
- DrawMatte
- DrawPathClose
- DrawPathCurveTo
- DrawPathCurveToAbsolute
- DrawPathCurveToRelative
- DrawPathCurveToQuadraticBezier
- DrawPathCurveToQuadraticBezierAbsolute
- DrawPathCurveToQuadraticBezierRelative
- DrawPathCurveToQuadraticBezierSmooth
- DrawPathCurveToQuadraticBezierSmoothAbsolute
- DrawPathCurveToQuadraticBezierSmoothRelative
- DrawPathCurveToSmooth
- DrawPathCurveToSmoothAbsolute
- DrawPathCurveToSmoothRelative
- DrawPathEllipticArc
- DrawPathEllipticArcAbsolute
- DrawPathEllipticArcRelative
- DrawPathFinish
- DrawPathLineTo
- DrawPathLineToAbsolute
- DrawPathLineToRelative
- DrawPathLineToHorizontal
- DrawPathLineToHorizontalAbsolute
- DrawPathLineToHorizontalRelative
- DrawPathLineToVertical
- DrawPathLineToVerticalAbsolute
- DrawPathLineToVerticalRelative
- DrawPathMoveTo
- DrawPathMoveToAbsolute
- DrawPathMoveToRelative
- DrawPathStart
- DrawPoint
- DrawPolygon
- DrawPolyline
- DrawPopClipPath
- DrawPopDefs
- DrawPopPattern
- DrawPushClipPath
- DrawPushDefs
- DrawPushPattern
- DrawRectangle
- DrawRender
- DrawResetVectorGraphics
- DrawRotate
- DrawRoundRectangle
- DrawScale
- IsColorEqual
- DrawSetBorderColor
- DrawSetClipPath
- DrawSetClipRule
- DrawSetClipUnits
- DrawSetDensity
- DrawSetFillColor
- DrawSetFillOpacity
- DrawSetFontResolution
- DrawSetOpacity
- DrawSetFillPatternURL
- DrawSetFillRule
- DrawSetFont
- DrawSetFontFamily
- DrawSetFontSize
- DrawSetFontStretch
- DrawSetFontStyle
- DrawSetFontWeight
- DrawSetGravity
- DrawSetStrokeColor
- DrawSetStrokePatternURL
- DrawSetStrokeAntialias
- DrawSetStrokeDashArray
- DrawSetStrokeDashOffset
- DrawSetStrokeLineCap
- DrawSetStrokeLineJoin
- DrawSetStrokeMiterLimit
- DrawSetStrokeOpacity
- DrawSetStrokeWidth
- DrawSetTextAlignment
- DrawSetTextAntialias
- DrawSetTextDecoration
- DrawSetTextDirection
- DrawSetTextEncoding
- DrawSetTextKerning
- DrawSetTextInterlineSpacing
- DrawSetTextInterwordSpacing
- DrawSetTextUnderColor
- IsPoint
- DrawSetVectorGraphics
- DrawSkewX
- DrawSkewY
- DrawTranslate
- DrawSetViewbox
- IsDrawingWand
- NewDrawingWand
- PeekDrawingWand
- PopDrawingWand
- PushDrawingWand
#include "wand/studio.h"
#include "wand/MagickWand.h"
#include "wand/magick-wand-private.h"
#include "wand/wand.h"
#include "magick/string-private.h"
#define DRAW_BINARY_IMPLEMENTATION 0
#define CurrentContext (wand->graphic_context[wand->index])
#define DrawingWandId "DrawingWand"
#define ThrowDrawException(severity,tag,reason) (void) ThrowMagickException( \
wand->exception,GetMagickModule(),severity,tag,"`%s'",reason);
typedef enum
{
PathDefaultOperation,
PathCloseOperation,
PathCurveToOperation,
PathCurveToQuadraticBezierOperation,
PathCurveToQuadraticBezierSmoothOperation,
PathCurveToSmoothOperation,
PathEllipticArcOperation,
PathLineToHorizontalOperation,
PathLineToOperation,
PathLineToVerticalOperation,
PathMoveToOperation
} PathOperation;
typedef enum
{
DefaultPathMode,
AbsolutePathMode,
RelativePathMode
} PathMode;
struct _DrawingWand
{
size_t
id;
char
name[MaxTextExtent];
Image
*image;
ExceptionInfo
*exception;
char
*mvg;
size_t
mvg_alloc,
mvg_length;
size_t
mvg_width;
char
*pattern_id;
RectangleInfo
pattern_bounds;
size_t
pattern_offset;
size_t
index;
DrawInfo
**graphic_context;
MagickBooleanType
filter_off;
size_t
indent_depth;
PathOperation
path_operation;
PathMode
path_mode;
MagickBooleanType
destroy,
debug;
size_t
signature;
};
static int
MVGPrintf(DrawingWand *,const char *,...) wand_attribute((format
(printf,2,3))),
MVGAutoWrapPrintf(DrawingWand *,const char *,...) wand_attribute((format
(printf,2,3)));
static void
MVGAppendColor(DrawingWand *,const PixelPacket *);
static int MVGPrintf(DrawingWand *wand,const char *format,...)
{
size_t
extent;
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",format);
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
extent=20UL*MaxTextExtent;
if (wand->mvg == (char *) NULL)
{
wand->mvg=(char *) AcquireQuantumMemory(extent,sizeof(*wand->mvg));
if (wand->mvg == (char *) NULL)
{
ThrowDrawException(ResourceLimitError,"MemoryAllocationFailed",
wand->name);
return(-1);
}
wand->mvg_alloc=extent;
wand->mvg_length=0;
}
if (wand->mvg_alloc < (wand->mvg_length+10*MaxTextExtent))
{
extent+=wand->mvg_alloc;
wand->mvg=(char *) ResizeQuantumMemory(wand->mvg,extent,
sizeof(*wand->mvg));
if (wand->mvg == (char *) NULL)
{
ThrowDrawException(ResourceLimitError,"MemoryAllocationFailed",
wand->name);
return(-1);
}
wand->mvg_alloc=extent;
}
{
int
count;
ssize_t
offset;
va_list
argp;
while (wand->mvg_width < wand->indent_depth)
{
wand->mvg[wand->mvg_length]=' ';
wand->mvg_length++;
wand->mvg_width++;
}
wand->mvg[wand->mvg_length]='\0';
count=(-1);
offset=(ssize_t) wand->mvg_alloc-wand->mvg_length-1;
if (offset > 0)
{
va_start(argp,format);
#if defined(MAGICKCORE_HAVE_VSNPRINTF)
count=vsnprintf(wand->mvg+wand->mvg_length,(size_t) offset,format,argp);
#else
count=vsprintf(wand->mvg+wand->mvg_length,format,argp);
#endif
va_end(argp);
}
if ((count < 0) || (count > (int) offset))
ThrowDrawException(DrawError,"UnableToPrint",format)
else
{
wand->mvg_length+=count;
wand->mvg_width+=count;
}
wand->mvg[wand->mvg_length]='\0';
if ((wand->mvg_length > 1) && (wand->mvg[wand->mvg_length-1] == '\n'))
wand->mvg_width=0;
assert((wand->mvg_length+1) < wand->mvg_alloc);
return(count);
}
}
static int MVGAutoWrapPrintf(DrawingWand *wand,const char *format,...)
{
char
buffer[MaxTextExtent];
int
count;
va_list
argp;
va_start(argp,format);
#if defined(MAGICKCORE_HAVE_VSNPRINTF)
count=vsnprintf(buffer,sizeof(buffer)-1,format,argp);
#else
count=vsprintf(buffer,format,argp);
#endif
va_end(argp);
buffer[sizeof(buffer)-1]='\0';
if (count < 0)
ThrowDrawException(DrawError,"UnableToPrint",format)
else
{
if (((wand->mvg_width + count) > 78) && (buffer[count-1] != '\n'))
(void) MVGPrintf(wand, "\n");
(void) MVGPrintf(wand,"%s",buffer);
}
return(count);
}
static void MVGAppendColor(DrawingWand *wand,const PixelPacket *color)
{
if ((GetPixelRed(color) == 0) &&
(GetPixelGreen(color) == 0) &&
(GetPixelBlue(color) == 0) &&
(GetPixelOpacity(color) == (Quantum) TransparentOpacity))
(void) MVGPrintf(wand,"none");
else
{
char
tuple[MaxTextExtent];
MagickPixelPacket
pixel;
GetMagickPixelPacket(wand->image,&pixel);
pixel.colorspace=sRGBColorspace;
pixel.matte=color->opacity != OpaqueOpacity ? MagickTrue : MagickFalse;
pixel.red=(MagickRealType) GetPixelRed(color);
pixel.green=(MagickRealType) GetPixelGreen(color);
pixel.blue=(MagickRealType) GetPixelBlue(color);
pixel.opacity=(MagickRealType) GetPixelOpacity(color);
GetColorTuple(&pixel,MagickTrue,tuple);
(void) MVGPrintf(wand,"%s",tuple);
}
}
static void MVGAppendPointsCommand(DrawingWand *wand,const char *command,
const size_t number_coordinates,const PointInfo *coordinates)
{
const PointInfo
*coordinate;
size_t
i;
(void) MVGPrintf(wand,"%s",command);
for (i=number_coordinates, coordinate=coordinates; i != 0; i--)
{
(void) MVGAutoWrapPrintf(wand," %.20g %.20g",coordinate->x,coordinate->y);
coordinate++;
}
(void) MVGPrintf(wand, "\n");
}
static void AdjustAffine(DrawingWand *wand,const AffineMatrix *affine)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((affine->sx != 1.0) || (affine->rx != 0.0) || (affine->ry != 0.0) ||
(affine->sy != 1.0) || (affine->tx != 0.0) || (affine->ty != 0.0))
{
AffineMatrix
current;
current=CurrentContext->affine;
CurrentContext->affine.sx=affine->sx*current.sx+affine->ry*current.rx;
CurrentContext->affine.rx=affine->rx*current.sx+affine->sy*current.rx;
CurrentContext->affine.ry=affine->sx*current.ry+affine->ry*current.sy;
CurrentContext->affine.sy=affine->rx*current.ry+affine->sy*current.sy;
CurrentContext->affine.tx=affine->sx*current.tx+affine->ry*current.ty+
affine->tx;
CurrentContext->affine.ty=affine->rx*current.tx+affine->sy*current.ty+
affine->ty;
}
}
WandExport DrawingWand *AcquireDrawingWand(const DrawInfo *draw_info,
Image *image)
{
DrawingWand
*wand;
wand=NewDrawingWand();
if (draw_info != (const DrawInfo *) NULL)
{
CurrentContext=DestroyDrawInfo(CurrentContext);
CurrentContext=CloneDrawInfo((ImageInfo *) NULL,draw_info);
}
if (image != (Image *) NULL)
{
wand->image=DestroyImage(wand->image);
wand->destroy=MagickFalse;
}
wand->image=image;
return(wand);
}
WandExport void ClearDrawingWand(DrawingWand *wand)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
for ( ; wand->index > 0; wand->index--)
CurrentContext=DestroyDrawInfo(CurrentContext);
CurrentContext=DestroyDrawInfo(CurrentContext);
wand->graphic_context=(DrawInfo **) RelinquishMagickMemory(
wand->graphic_context);
if (wand->pattern_id != (char *) NULL)
wand->pattern_id=DestroyString(wand->pattern_id);
wand->mvg=DestroyString(wand->mvg);
if ((wand->destroy != MagickFalse) && (wand->image != (Image *) NULL))
wand->image=DestroyImage(wand->image);
else
wand->image=(Image *) NULL;
wand->mvg=(char *) NULL;
wand->mvg_alloc=0;
wand->mvg_length=0;
wand->mvg_width=0;
wand->pattern_id=(char *) NULL;
wand->pattern_offset=0;
wand->pattern_bounds.x=0;
wand->pattern_bounds.y=0;
wand->pattern_bounds.width=0;
wand->pattern_bounds.height=0;
wand->index=0;
wand->graphic_context=(DrawInfo **) AcquireMagickMemory(
sizeof(*wand->graphic_context));
if (wand->graphic_context == (DrawInfo **) NULL)
{
ThrowDrawException(ResourceLimitError,"MemoryAllocationFailed",
wand->name);
return;
}
CurrentContext=CloneDrawInfo((ImageInfo *) NULL,(DrawInfo *) NULL);
wand->filter_off=MagickTrue;
wand->indent_depth=0;
wand->path_operation=PathDefaultOperation;
wand->path_mode=DefaultPathMode;
wand->image=AcquireImage((const ImageInfo *) NULL);
ClearMagickException(wand->exception);
wand->destroy=MagickTrue;
wand->debug=IsEventLogging();
}
WandExport DrawingWand *CloneDrawingWand(const DrawingWand *wand)
{
DrawingWand
*clone_wand;
register ssize_t
i;
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
clone_wand=(DrawingWand *) AcquireMagickMemory(sizeof(*clone_wand));
if (clone_wand == (DrawingWand *) NULL)
ThrowWandFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",GetExceptionMessage(errno));
(void) ResetMagickMemory(clone_wand,0,sizeof(*clone_wand));
clone_wand->id=AcquireWandId();
(void) FormatLocaleString(clone_wand->name,MaxTextExtent,"DrawingWand-%.20g",
(double) clone_wand->id);
clone_wand->exception=AcquireExceptionInfo();
InheritException(clone_wand->exception,wand->exception);
clone_wand->mvg=AcquireString(wand->mvg);
clone_wand->mvg_length=strlen(clone_wand->mvg);
clone_wand->mvg_alloc=wand->mvg_length+1;
clone_wand->mvg_width=wand->mvg_width;
clone_wand->pattern_id=AcquireString(wand->pattern_id);
clone_wand->pattern_offset=wand->pattern_offset;
clone_wand->pattern_bounds=wand->pattern_bounds;
clone_wand->index=wand->index;
clone_wand->graphic_context=(DrawInfo **) AcquireQuantumMemory((size_t)
wand->index+1UL,sizeof(*wand->graphic_context));
if (clone_wand->graphic_context == (DrawInfo **) NULL)
ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
GetExceptionMessage(errno));
for (i=0; i <= (ssize_t) wand->index; i++)
clone_wand->graphic_context[i]=
CloneDrawInfo((ImageInfo *) NULL,wand->graphic_context[i]);
clone_wand->filter_off=wand->filter_off;
clone_wand->indent_depth=wand->indent_depth;
clone_wand->path_operation=wand->path_operation;
clone_wand->path_mode=wand->path_mode;
clone_wand->image=wand->image;
if (wand->image != (Image *) NULL)
clone_wand->image=CloneImage(wand->image,0,0,MagickTrue,
clone_wand->exception);
clone_wand->destroy=MagickTrue;
clone_wand->debug=IsEventLogging();
if (clone_wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",clone_wand->name);
clone_wand->signature=WandSignature;
return(clone_wand);
}
WandExport DrawingWand *DestroyDrawingWand(DrawingWand *wand)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
for ( ; wand->index > 0; wand->index--)
CurrentContext=DestroyDrawInfo(CurrentContext);
CurrentContext=DestroyDrawInfo(CurrentContext);
wand->graphic_context=(DrawInfo **) RelinquishMagickMemory(
wand->graphic_context);
if (wand->pattern_id != (char *) NULL)
wand->pattern_id=DestroyString(wand->pattern_id);
wand->mvg=DestroyString(wand->mvg);
if ((wand->destroy != MagickFalse) && (wand->image != (Image *) NULL))
wand->image=DestroyImage(wand->image);
wand->image=(Image *) NULL;
wand->exception=DestroyExceptionInfo(wand->exception);
wand->signature=(~WandSignature);
RelinquishWandId(wand->id);
wand=(DrawingWand *) RelinquishMagickMemory(wand);
return(wand);
}
WandExport void DrawAffine(DrawingWand *wand,const AffineMatrix *affine)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
assert(affine != (const AffineMatrix *) NULL);
AdjustAffine(wand,affine);
(void) MVGPrintf(wand,"affine %.20g %.20g %.20g %.20g %.20g %.20g\n",
affine->sx,affine->rx,affine->ry,affine->sy,affine->tx,affine->ty);
}
WandExport void DrawAnnotation(DrawingWand *wand,const double x,const double y,
const unsigned char *text)
{
char
*escaped_text;
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
assert(text != (const unsigned char *) NULL);
escaped_text=EscapeString((const char *) text,'\'');
if (escaped_text != (char *) NULL)
{
(void) MVGPrintf(wand,"text %.20g %.20g '%s'\n",x,y,escaped_text);
escaped_text=DestroyString(escaped_text);
}
}
WandExport void DrawArc(DrawingWand *wand,const double sx,const double sy,
const double ex,const double ey,const double sd,const double ed)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) MVGPrintf(wand,"arc %.20g %.20g %.20g %.20g %.20g %.20g\n",sx,sy,ex,
ey,sd,ed);
}
WandExport void DrawBezier(DrawingWand *wand,
const size_t number_coordinates,const PointInfo *coordinates)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
assert(coordinates != (const PointInfo *) NULL);
MVGAppendPointsCommand(wand,"bezier",number_coordinates,coordinates);
}
WandExport void DrawCircle(DrawingWand *wand,const double ox,const double oy,
const double px,const double py)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) MVGPrintf(wand,"circle %.20g %.20g %.20g %.20g\n",ox,oy,px,py);
}
WandExport MagickBooleanType DrawClearException(DrawingWand *wand)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
ClearMagickException(wand->exception);
return(MagickTrue);
}
WandExport MagickBooleanType DrawComposite(DrawingWand *wand,
const CompositeOperator compose,const double x,const double y,
const double width,const double height,MagickWand *magick_wand)
{
char
*base64,
*media_type;
const char
*mode;
ImageInfo
*image_info;
Image
*clone_image,
*image;
register char
*p;
register ssize_t
i;
size_t
blob_length,
encoded_length;
unsigned char
*blob;
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
assert(magick_wand != (MagickWand *) NULL);
image=GetImageFromMagickWand(magick_wand);
if (image == (Image *) NULL)
return(MagickFalse);
clone_image=CloneImage(image,0,0,MagickTrue,wand->exception);
if (clone_image == (Image *) NULL)
return(MagickFalse);
image_info=AcquireImageInfo();
(void) CopyMagickString(image_info->magick,"MIFF",MaxTextExtent);
blob_length=2048;
blob=(unsigned char *) ImageToBlob(image_info,clone_image,&blob_length,
wand->exception);
image_info=DestroyImageInfo(image_info);
clone_image=DestroyImageList(clone_image);
if (blob == (void *) NULL)
return(MagickFalse);
encoded_length=0;
base64=Base64Encode(blob,blob_length,&encoded_length);
blob=(unsigned char *) RelinquishMagickMemory(blob);
if (base64 == (char *) NULL)
{
char
buffer[MaxTextExtent];
(void) FormatLocaleString(buffer,MaxTextExtent,"%.20g bytes",(double)
(4L*blob_length/3L+4L));
ThrowDrawException(ResourceLimitWarning,"MemoryAllocationFailed",
wand->name);
return(MagickFalse);
}
mode=CommandOptionToMnemonic(MagickComposeOptions,(ssize_t) compose);
media_type=MagickToMime(image->magick);
(void) MVGPrintf(wand,"image %s %.20g %.20g %.20g %.20g 'data:%s;base64,\n",
mode,x,y,width,height,media_type);
p=base64;
for (i=(ssize_t) encoded_length; i > 0; i-=76)
{
(void) MVGPrintf(wand,"%.76s",p);
p+=76;
if (i > 76)
(void) MVGPrintf(wand,"\n");
}
(void) MVGPrintf(wand,"'\n");
media_type=DestroyString(media_type);
base64=DestroyString(base64);
return(MagickTrue);
}
WandExport void DrawColor(DrawingWand *wand,const double x,const double y,
const PaintMethod paint_method)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) MVGPrintf(wand,"color %.20g %.20g '%s'\n",x,y,CommandOptionToMnemonic(
MagickMethodOptions,(ssize_t) paint_method));
}
WandExport void DrawComment(DrawingWand *wand,const char *comment)
{
(void) MVGPrintf(wand,"#%s\n",comment);
}
WandExport void DrawEllipse(DrawingWand *wand,const double ox,const double oy,
const double rx,const double ry,const double start,const double end)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) MVGPrintf(wand,"ellipse %.20g %.20g %.20g %.20g %.20g %.20g\n",ox,oy,
rx,ry,start,end);
}
WandExport void DrawGetBorderColor(const DrawingWand *wand,
PixelWand *border_color)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
assert(border_color != (PixelWand *) NULL);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
PixelSetQuantumColor(border_color,&CurrentContext->border_color);
}
WandExport char *DrawGetClipPath(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if (CurrentContext->clip_mask != (char *) NULL)
return((char *) AcquireString(CurrentContext->clip_mask));
return((char *) NULL);
}
WandExport FillRule DrawGetClipRule(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->fill_rule);
}
WandExport ClipPathUnits DrawGetClipUnits(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->clip_units);
}
WandExport char *DrawGetDensity(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == MagickSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if (CurrentContext->density != (char *) NULL)
return((char *) AcquireString(CurrentContext->density));
return((char *) NULL);
}
WandExport char *DrawGetException(const DrawingWand *wand,
ExceptionType *severity)
{
char
*description;
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
assert(severity != (ExceptionType *) NULL);
*severity=wand->exception->severity;
description=(char *) AcquireQuantumMemory(2UL*MaxTextExtent,
sizeof(*description));
if (description == (char *) NULL)
ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
wand->name);
*description='\0';
if (wand->exception->reason != (char *) NULL)
(void) CopyMagickString(description,GetLocaleExceptionMessage(
wand->exception->severity,wand->exception->reason),
MaxTextExtent);
if (wand->exception->description != (char *) NULL)
{
(void) ConcatenateMagickString(description," (",MaxTextExtent);
(void) ConcatenateMagickString(description,GetLocaleExceptionMessage(
wand->exception->severity,wand->exception->description),
MaxTextExtent);
(void) ConcatenateMagickString(description,")",MaxTextExtent);
}
return(description);
}
WandExport ExceptionType DrawGetExceptionType(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(wand->exception->severity);
}
WandExport void DrawGetFillColor(const DrawingWand *wand,PixelWand *fill_color)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
assert(fill_color != (PixelWand *) NULL);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
PixelSetQuantumColor(fill_color,&CurrentContext->fill);
}
WandExport double DrawGetFillOpacity(const DrawingWand *wand)
{
double
alpha;
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
alpha=(double) QuantumScale*(QuantumRange-CurrentContext->fill.opacity);
return(alpha);
}
WandExport FillRule DrawGetFillRule(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->fill_rule);
}
WandExport char *DrawGetFont(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if (CurrentContext->font != (char *) NULL)
return(AcquireString(CurrentContext->font));
return((char *) NULL);
}
WandExport char *DrawGetFontFamily(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if (CurrentContext->family != NULL)
return(AcquireString(CurrentContext->family));
return((char *) NULL);
}
WandExport MagickBooleanType DrawGetFontResolution(const DrawingWand *wand,
double *x,double *y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
*x=72.0;
*y=72.0;
if (CurrentContext->density != (char *) NULL)
{
GeometryInfo
geometry_info;
MagickStatusType
flags;
flags=ParseGeometry(CurrentContext->density,&geometry_info);
*x=geometry_info.rho;
*y=geometry_info.sigma;
if ((flags & SigmaValue) == MagickFalse)
*y=(*x);
}
return(MagickTrue);
}
WandExport double DrawGetFontSize(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->pointsize);
}
WandExport StretchType DrawGetFontStretch(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->stretch);
}
WandExport StyleType DrawGetFontStyle(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->style);
}
WandExport size_t DrawGetFontWeight(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->weight);
}
WandExport GravityType DrawGetGravity(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->gravity);
}
WandExport double DrawGetOpacity(const DrawingWand *wand)
{
double
alpha;
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
alpha=(double) QuantumScale*(QuantumRange-CurrentContext->opacity);
return(alpha);
}
WandExport MagickBooleanType DrawGetStrokeAntialias(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->stroke_antialias);
}
WandExport void DrawGetStrokeColor(const DrawingWand *wand,
PixelWand *stroke_color)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
assert(stroke_color != (PixelWand *) NULL);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
PixelSetQuantumColor(stroke_color,&CurrentContext->stroke);
}
WandExport double *DrawGetStrokeDashArray(const DrawingWand *wand,
size_t *number_elements)
{
double
*dasharray;
register const double
*p;
register double
*q;
register ssize_t
i;
size_t
n;
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
assert(number_elements != (size_t *) NULL);
n=0;
p=CurrentContext->dash_pattern;
if (p != (const double *) NULL)
while (*p++ != 0.0)
n++;
*number_elements=n;
dasharray=(double *) NULL;
if (n != 0)
{
dasharray=(double *) AcquireQuantumMemory((size_t) n+1UL,
sizeof(*dasharray));
p=CurrentContext->dash_pattern;
q=dasharray;
for (i=0; i < (ssize_t) n; i++)
*q++=(*p++);
*q=0.0;
}
return(dasharray);
}
WandExport double DrawGetStrokeDashOffset(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->dash_offset);
}
WandExport LineCap DrawGetStrokeLineCap(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->linecap);
}
WandExport LineJoin DrawGetStrokeLineJoin(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->linejoin);
}
WandExport size_t DrawGetStrokeMiterLimit(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return CurrentContext->miterlimit;
}
WandExport double DrawGetStrokeOpacity(const DrawingWand *wand)
{
double
alpha;
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
alpha=(double) QuantumScale*(QuantumRange-CurrentContext->stroke.opacity);
return(alpha);
}
WandExport double DrawGetStrokeWidth(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->stroke_width);
}
WandExport AlignType DrawGetTextAlignment(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->align);
}
WandExport MagickBooleanType DrawGetTextAntialias(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->text_antialias);
}
WandExport DecorationType DrawGetTextDecoration(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->decorate);
}
WandExport DirectionType DrawGetTextDirection(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->direction);
}
WandExport char *DrawGetTextEncoding(const DrawingWand *wand)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if (CurrentContext->encoding != (char *) NULL)
return((char *) AcquireString(CurrentContext->encoding));
return((char *) NULL);
}
WandExport double DrawGetTextKerning(DrawingWand *wand)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->kerning);
}
WandExport double DrawGetTextInterlineSpacing(DrawingWand *wand)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->interline_spacing);
}
WandExport double DrawGetTextInterwordSpacing(DrawingWand *wand)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->interword_spacing);
}
static inline void SetMagickPixelPacket(const Image *image,
const PixelPacket *color,const IndexPacket *index,MagickPixelPacket *pixel)
{
pixel->red=(MagickRealType) GetPixelRed(color);
pixel->green=(MagickRealType) GetPixelGreen(color);
pixel->blue=(MagickRealType) GetPixelBlue(color);
if (image->matte != MagickFalse)
pixel->opacity=(MagickRealType) GetPixelOpacity(color);
if (((image->colorspace == CMYKColorspace) ||
(image->storage_class == PseudoClass)) &&
(index != (const IndexPacket *) NULL))
pixel->index=(MagickRealType) GetPixelIndex(index);
}
WandExport char *DrawGetVectorGraphics(DrawingWand *wand)
{
char
value[MaxTextExtent],
*xml;
MagickPixelPacket
pixel;
register ssize_t
i;
XMLTreeInfo
*child,
*xml_info;
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
xml_info=NewXMLTreeTag("drawing-wand");
if (xml_info == (XMLTreeInfo *) NULL)
return((char *) NULL);
(void) SetXMLTreeContent(xml_info," ");
GetMagickPixelPacket(wand->image,&pixel);
child=AddChildToXMLTree(xml_info,"clip-path",0);
if (child != (XMLTreeInfo *) NULL)
(void) SetXMLTreeContent(child,CurrentContext->clip_mask);
child=AddChildToXMLTree(xml_info,"clip-units",0);
if (child != (XMLTreeInfo *) NULL)
{
(void) CopyMagickString(value,CommandOptionToMnemonic(
MagickClipPathOptions,(ssize_t) CurrentContext->clip_units),
MaxTextExtent);
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"decorate",0);
if (child != (XMLTreeInfo *) NULL)
{
(void) CopyMagickString(value,CommandOptionToMnemonic(
MagickDecorateOptions,(ssize_t) CurrentContext->decorate),
MaxTextExtent);
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"encoding",0);
if (child != (XMLTreeInfo *) NULL)
(void) SetXMLTreeContent(child,CurrentContext->encoding);
child=AddChildToXMLTree(xml_info,"fill",0);
if (child != (XMLTreeInfo *) NULL)
{
if (CurrentContext->fill.opacity != OpaqueOpacity)
pixel.matte=CurrentContext->fill.opacity != OpaqueOpacity ?
MagickTrue : MagickFalse;
SetMagickPixelPacket(wand->image,&CurrentContext->fill,
(const IndexPacket *) NULL,&pixel);
GetColorTuple(&pixel,MagickTrue,value);
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"fill-opacity",0);
if (child != (XMLTreeInfo *) NULL)
{
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",
(double) (QuantumScale*(QuantumRange-CurrentContext->fill.opacity)));
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"fill-rule",0);
if (child != (XMLTreeInfo *) NULL)
{
(void) CopyMagickString(value,CommandOptionToMnemonic(
MagickFillRuleOptions,(ssize_t) CurrentContext->fill_rule),
MaxTextExtent);
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"font",0);
if (child != (XMLTreeInfo *) NULL)
(void) SetXMLTreeContent(child,CurrentContext->font);
child=AddChildToXMLTree(xml_info,"font-family",0);
if (child != (XMLTreeInfo *) NULL)
(void) SetXMLTreeContent(child,CurrentContext->family);
child=AddChildToXMLTree(xml_info,"font-size",0);
if (child != (XMLTreeInfo *) NULL)
{
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",
CurrentContext->pointsize);
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"font-stretch",0);
if (child != (XMLTreeInfo *) NULL)
{
(void) CopyMagickString(value,CommandOptionToMnemonic(
MagickStretchOptions,(ssize_t) CurrentContext->stretch),MaxTextExtent);
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"font-style",0);
if (child != (XMLTreeInfo *) NULL)
{
(void) CopyMagickString(value,CommandOptionToMnemonic(
MagickStyleOptions,(ssize_t) CurrentContext->style),MaxTextExtent);
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"font-weight",0);
if (child != (XMLTreeInfo *) NULL)
{
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
CurrentContext->weight);
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"gravity",0);
if (child != (XMLTreeInfo *) NULL)
{
(void) CopyMagickString(value,CommandOptionToMnemonic(
MagickGravityOptions,(ssize_t) CurrentContext->gravity),MaxTextExtent);
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"stroke",0);
if (child != (XMLTreeInfo *) NULL)
{
if (CurrentContext->stroke.opacity != OpaqueOpacity)
pixel.matte=CurrentContext->stroke.opacity != OpaqueOpacity ?
MagickTrue : MagickFalse;
SetMagickPixelPacket(wand->image,&CurrentContext->stroke,
(const IndexPacket *) NULL,&pixel);
GetColorTuple(&pixel,MagickTrue,value);
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"stroke-antialias",0);
if (child != (XMLTreeInfo *) NULL)
{
(void) FormatLocaleString(value,MaxTextExtent,"%d",
CurrentContext->stroke_antialias != MagickFalse ? 1 : 0);
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"stroke-dasharray",0);
if ((child != (XMLTreeInfo *) NULL) &&
(CurrentContext->dash_pattern != (double *) NULL))
{
char
*dash_pattern;
dash_pattern=AcquireString((char *) NULL);
for (i=0; CurrentContext->dash_pattern[i] != 0.0; i++)
{
if (i != 0)
(void) ConcatenateString(&dash_pattern,",");
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",
CurrentContext->dash_pattern[i]);
(void) ConcatenateString(&dash_pattern,value);
}
(void) SetXMLTreeContent(child,dash_pattern);
dash_pattern=DestroyString(dash_pattern);
}
child=AddChildToXMLTree(xml_info,"stroke-dashoffset",0);
if (child != (XMLTreeInfo *) NULL)
{
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",
CurrentContext->dash_offset);
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"stroke-linecap",0);
if (child != (XMLTreeInfo *) NULL)
{
(void) CopyMagickString(value,CommandOptionToMnemonic(
MagickLineCapOptions,(ssize_t) CurrentContext->linecap),MaxTextExtent);
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"stroke-linejoin",0);
if (child != (XMLTreeInfo *) NULL)
{
(void) CopyMagickString(value,CommandOptionToMnemonic(
MagickLineJoinOptions,(ssize_t) CurrentContext->linejoin),
MaxTextExtent);
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"stroke-miterlimit",0);
if (child != (XMLTreeInfo *) NULL)
{
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
CurrentContext->miterlimit);
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"stroke-opacity",0);
if (child != (XMLTreeInfo *) NULL)
{
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",
(double) (QuantumScale*(QuantumRange-CurrentContext->stroke.opacity)));
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"stroke-width",0);
if (child != (XMLTreeInfo *) NULL)
{
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",
CurrentContext->stroke_width);
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"text-align",0);
if (child != (XMLTreeInfo *) NULL)
{
(void) CopyMagickString(value,CommandOptionToMnemonic(MagickAlignOptions,
(ssize_t) CurrentContext->align),MaxTextExtent);
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"text-antialias",0);
if (child != (XMLTreeInfo *) NULL)
{
(void) FormatLocaleString(value,MaxTextExtent,"%d",
CurrentContext->text_antialias != MagickFalse ? 1 : 0);
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"text-undercolor",0);
if (child != (XMLTreeInfo *) NULL)
{
if (CurrentContext->undercolor.opacity != OpaqueOpacity)
pixel.matte=CurrentContext->undercolor.opacity != OpaqueOpacity ?
MagickTrue : MagickFalse;
SetMagickPixelPacket(wand->image,&CurrentContext->undercolor,
(const IndexPacket *) NULL,&pixel);
GetColorTuple(&pixel,MagickTrue,value);
(void) SetXMLTreeContent(child,value);
}
child=AddChildToXMLTree(xml_info,"vector-graphics",0);
if (child != (XMLTreeInfo *) NULL)
(void) SetXMLTreeContent(child,wand->mvg);
xml=XMLTreeInfoToXML(xml_info);
xml_info=DestroyXMLTree(xml_info);
return(xml);
}
WandExport void DrawGetTextUnderColor(const DrawingWand *wand,
PixelWand *under_color)
{
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
assert(under_color != (PixelWand *) NULL);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
PixelSetQuantumColor(under_color,&CurrentContext->undercolor);
}
WandExport void DrawLine(DrawingWand *wand,const double sx,const double sy,
const double ex,const double ey)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) MVGPrintf(wand,"line %.20g %.20g %.20g %.20g\n",sx,sy,ex,ey);
}
WandExport void DrawMatte(DrawingWand *wand,const double x,const double y,
const PaintMethod paint_method)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) MVGPrintf(wand,"matte %.20g %.20g '%s'\n",x,y,CommandOptionToMnemonic(
MagickMethodOptions,(ssize_t) paint_method));
}
WandExport void DrawPathClose(DrawingWand *wand)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) MVGAutoWrapPrintf(wand,"%s",wand->path_mode == AbsolutePathMode ?
"Z" : "z");
}
static void DrawPathCurveTo(DrawingWand *wand,const PathMode mode,
const double x1,const double y1,const double x2,const double y2,
const double x,const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->path_operation != PathCurveToOperation) ||
(wand->path_mode != mode))
{
wand->path_operation=PathCurveToOperation;
wand->path_mode=mode;
(void) MVGAutoWrapPrintf(wand, "%c%.20g %.20g %.20g %.20g %.20g %.20g",
mode == AbsolutePathMode ? 'C' : 'c',x1,y1,x2,y2,x,y);
}
else
(void) MVGAutoWrapPrintf(wand," %.20g %.20g %.20g %.20g %.20g %.20g",x1,y1,
x2,y2,x,y);
}
WandExport void DrawPathCurveToAbsolute(DrawingWand *wand,const double x1,
const double y1,const double x2,const double y2,const double x,const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
DrawPathCurveTo(wand,AbsolutePathMode,x1,y1,x2,y2,x,y);
}
WandExport void DrawPathCurveToRelative(DrawingWand *wand,const double x1,
const double y1,const double x2,const double y2,const double x,const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
DrawPathCurveTo(wand,RelativePathMode,x1,y1,x2,y2,x,y);
}
static void DrawPathCurveToQuadraticBezier(DrawingWand *wand,
const PathMode mode,const double x1,double y1,const double x,const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->path_operation != PathCurveToQuadraticBezierOperation) ||
(wand->path_mode != mode))
{
wand->path_operation=PathCurveToQuadraticBezierOperation;
wand->path_mode=mode;
(void) MVGAutoWrapPrintf(wand, "%c%.20g %.20g %.20g %.20g",
mode == AbsolutePathMode ? 'Q' : 'q',x1,y1,x,y);
}
else
(void) MVGAutoWrapPrintf(wand," %.20g %.20g %.20g %.20g",x1,y1,x,y);
}
WandExport void DrawPathCurveToQuadraticBezierAbsolute(DrawingWand *wand,
const double x1,const double y1,const double x,const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
DrawPathCurveToQuadraticBezier(wand,AbsolutePathMode,x1,y1,x,y);
}
WandExport void DrawPathCurveToQuadraticBezierRelative(DrawingWand *wand,
const double x1,const double y1,const double x,const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
DrawPathCurveToQuadraticBezier(wand,RelativePathMode,x1,y1,x,y);
}
static void DrawPathCurveToQuadraticBezierSmooth(DrawingWand *wand,
const PathMode mode,const double x,const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->path_operation != PathCurveToQuadraticBezierSmoothOperation) ||
(wand->path_mode != mode))
{
wand->path_operation=PathCurveToQuadraticBezierSmoothOperation;
wand->path_mode=mode;
(void) MVGAutoWrapPrintf(wand,"%c%.20g %.20g",mode == AbsolutePathMode ?
'T' : 't',x,y);
}
else
(void) MVGAutoWrapPrintf(wand," %.20g %.20g",x,y);
}
WandExport void DrawPathCurveToQuadraticBezierSmoothAbsolute(DrawingWand *wand,
const double x,const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
DrawPathCurveToQuadraticBezierSmooth(wand,AbsolutePathMode,x,y);
}
WandExport void DrawPathCurveToQuadraticBezierSmoothRelative(DrawingWand *wand,
const double x,const double y)
{
DrawPathCurveToQuadraticBezierSmooth(wand,RelativePathMode,x,y);
}
static void DrawPathCurveToSmooth(DrawingWand *wand,const PathMode mode,
const double x2,const double y2,const double x,const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->path_operation != PathCurveToSmoothOperation) ||
(wand->path_mode != mode))
{
wand->path_operation=PathCurveToSmoothOperation;
wand->path_mode=mode;
(void) MVGAutoWrapPrintf(wand,"%c%.20g %.20g %.20g %.20g",
mode == AbsolutePathMode ? 'S' : 's',x2,y2,x,y);
}
else
(void) MVGAutoWrapPrintf(wand," %.20g %.20g %.20g %.20g",x2,y2,x,y);
}
WandExport void DrawPathCurveToSmoothAbsolute(DrawingWand *wand,const double x2,
const double y2,const double x,const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
DrawPathCurveToSmooth(wand,AbsolutePathMode,x2,y2,x,y);
}
WandExport void DrawPathCurveToSmoothRelative(DrawingWand *wand,const double x2,
const double y2,const double x,const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
DrawPathCurveToSmooth(wand,RelativePathMode,x2,y2,x,y);
}
static void DrawPathEllipticArc(DrawingWand *wand, const PathMode mode,
const double rx,const double ry,const double x_axis_rotation,
const MagickBooleanType large_arc_flag,const MagickBooleanType sweep_flag,
const double x,const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->path_operation != PathEllipticArcOperation) ||
(wand->path_mode != mode))
{
wand->path_operation=PathEllipticArcOperation;
wand->path_mode=mode;
(void) MVGAutoWrapPrintf(wand, "%c%.20g %.20g %.20g %u %u %.20g %.20g",
mode == AbsolutePathMode ? 'A' : 'a',rx,ry,x_axis_rotation,
large_arc_flag,sweep_flag,x,y);
}
else
(void) MVGAutoWrapPrintf(wand," %.20g %.20g %.20g %u %u %.20g %.20g",rx,ry,
x_axis_rotation,large_arc_flag,sweep_flag,x,y);
}
WandExport void DrawPathEllipticArcAbsolute(DrawingWand *wand,const double rx,
const double ry,const double x_axis_rotation,
const MagickBooleanType large_arc_flag,const MagickBooleanType sweep_flag,
const double x,const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
DrawPathEllipticArc(wand,AbsolutePathMode,rx,ry,x_axis_rotation,
large_arc_flag,sweep_flag,x,y);
}
WandExport void DrawPathEllipticArcRelative(DrawingWand *wand,const double rx,
const double ry,const double x_axis_rotation,
const MagickBooleanType large_arc_flag,const MagickBooleanType sweep_flag,
const double x,const double y)
{
DrawPathEllipticArc(wand,RelativePathMode,rx,ry,x_axis_rotation,
large_arc_flag,sweep_flag,x,y);
}
WandExport void DrawPathFinish(DrawingWand *wand)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) MVGPrintf(wand,"'\n");
wand->path_operation=PathDefaultOperation;
wand->path_mode=DefaultPathMode;
}
static void DrawPathLineTo(DrawingWand *wand,const PathMode mode,
const double x,const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->path_operation != PathLineToOperation) ||
(wand->path_mode != mode))
{
wand->path_operation=PathLineToOperation;
wand->path_mode=mode;
(void) MVGAutoWrapPrintf(wand,"%c%.20g %.20g",mode == AbsolutePathMode ?
'L' : 'l',x,y);
}
else
(void) MVGAutoWrapPrintf(wand," %.20g %.20g",x,y);
}
WandExport void DrawPathLineToAbsolute(DrawingWand *wand,const double x,
const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
DrawPathLineTo(wand,AbsolutePathMode,x,y);
}
WandExport void DrawPathLineToRelative(DrawingWand *wand,const double x,
const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
DrawPathLineTo(wand,RelativePathMode,x,y);
}
static void DrawPathLineToHorizontal(DrawingWand *wand,const PathMode mode,
const double x)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->path_operation != PathLineToHorizontalOperation) ||
(wand->path_mode != mode))
{
wand->path_operation=PathLineToHorizontalOperation;
wand->path_mode=mode;
(void) MVGAutoWrapPrintf(wand,"%c%.20g",mode == AbsolutePathMode ?
'H' : 'h',x);
}
else
(void) MVGAutoWrapPrintf(wand," %.20g",x);
}
WandExport void DrawPathLineToHorizontalAbsolute(DrawingWand *wand,
const double x)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
DrawPathLineToHorizontal(wand,AbsolutePathMode,x);
}
WandExport void DrawPathLineToHorizontalRelative(DrawingWand *wand,
const double x)
{
DrawPathLineToHorizontal(wand,RelativePathMode,x);
}
static void DrawPathLineToVertical(DrawingWand *wand,const PathMode mode,
const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->path_operation != PathLineToVerticalOperation) ||
(wand->path_mode != mode))
{
wand->path_operation=PathLineToVerticalOperation;
wand->path_mode=mode;
(void) MVGAutoWrapPrintf(wand,"%c%.20g",mode == AbsolutePathMode ?
'V' : 'v',y);
}
else
(void) MVGAutoWrapPrintf(wand," %.20g",y);
}
WandExport void DrawPathLineToVerticalAbsolute(DrawingWand *wand,const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
DrawPathLineToVertical(wand,AbsolutePathMode,y);
}
WandExport void DrawPathLineToVerticalRelative(DrawingWand *wand,const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
DrawPathLineToVertical(wand,RelativePathMode,y);
}
static void DrawPathMoveTo(DrawingWand *wand,const PathMode mode,const double x,
const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->path_operation != PathMoveToOperation) ||
(wand->path_mode != mode))
{
wand->path_operation=PathMoveToOperation;
wand->path_mode=mode;
(void) MVGAutoWrapPrintf(wand,"%c%.20g %.20g",mode == AbsolutePathMode ?
'M' : 'm',x,y);
}
else
(void) MVGAutoWrapPrintf(wand," %.20g %.20g",x,y);
}
WandExport void DrawPathMoveToAbsolute(DrawingWand *wand,const double x,
const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
DrawPathMoveTo(wand,AbsolutePathMode,x,y);
}
WandExport void DrawPathMoveToRelative(DrawingWand *wand,const double x,
const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
DrawPathMoveTo(wand,RelativePathMode,x,y);
}
WandExport void DrawPathStart(DrawingWand *wand)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) MVGPrintf(wand,"path '");
wand->path_operation=PathDefaultOperation;
wand->path_mode=DefaultPathMode;
}
WandExport void DrawPoint(DrawingWand *wand,const double x,const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) MVGPrintf(wand,"point %.20g %.20g\n",x,y);
}
WandExport void DrawPolygon(DrawingWand *wand,
const size_t number_coordinates,const PointInfo *coordinates)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
MVGAppendPointsCommand(wand,"polygon",number_coordinates,coordinates);
}
WandExport void DrawPolyline(DrawingWand *wand,
const size_t number_coordinates,const PointInfo *coordinates)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
MVGAppendPointsCommand(wand,"polyline",number_coordinates,coordinates);
}
WandExport void DrawPopClipPath(DrawingWand *wand)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if (wand->indent_depth > 0)
wand->indent_depth--;
(void) MVGPrintf(wand,"pop clip-path\n");
}
WandExport void DrawPopDefs(DrawingWand *wand)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if (wand->indent_depth > 0)
wand->indent_depth--;
(void) MVGPrintf(wand,"pop defs\n");
}
WandExport MagickBooleanType DrawPopPattern(DrawingWand *wand)
{
char
geometry[MaxTextExtent],
key[MaxTextExtent];
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if (wand->image == (Image *) NULL)
ThrowDrawException(WandError,"ContainsNoImages",wand->name);
if (wand->pattern_id == (const char *) NULL)
{
ThrowDrawException(DrawWarning,"NotCurrentlyPushingPatternDefinition",
wand->name);
return(MagickFalse);
}
(void) FormatLocaleString(key,MaxTextExtent,"%s",wand->pattern_id);
(void) SetImageArtifact(wand->image,key,wand->mvg+wand->pattern_offset);
(void) FormatLocaleString(geometry,MaxTextExtent,"%.20gx%.20g%+.20g%+.20g",
(double) wand->pattern_bounds.width,(double) wand->pattern_bounds.height,
(double) wand->pattern_bounds.x,(double) wand->pattern_bounds.y);
(void) SetImageArtifact(wand->image,key,geometry);
wand->pattern_id=DestroyString(wand->pattern_id);
wand->pattern_offset=0;
wand->pattern_bounds.x=0;
wand->pattern_bounds.y=0;
wand->pattern_bounds.width=0;
wand->pattern_bounds.height=0;
wand->filter_off=MagickTrue;
if (wand->indent_depth > 0)
wand->indent_depth--;
(void) MVGPrintf(wand,"pop pattern\n");
return(MagickTrue);
}
WandExport void DrawPushClipPath(DrawingWand *wand,const char *clip_mask_id)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
assert(clip_mask_id != (const char *) NULL);
(void) MVGPrintf(wand,"push clip-path %s\n",clip_mask_id);
wand->indent_depth++;
}
WandExport void DrawPushDefs(DrawingWand *wand)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) MVGPrintf(wand,"push defs\n");
wand->indent_depth++;
}
WandExport MagickBooleanType DrawPushPattern(DrawingWand *wand,
const char *pattern_id,const double x,const double y,const double width,
const double height)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
assert(pattern_id != (const char *) NULL);
if (wand->pattern_id != NULL)
{
ThrowDrawException(DrawError,"AlreadyPushingPatternDefinition",
wand->pattern_id);
return(MagickFalse);
}
wand->filter_off=MagickTrue;
(void) MVGPrintf(wand,"push pattern %s %.20g %.20g %.20g %.20g\n",pattern_id,
x,y,width,height);
wand->indent_depth++;
wand->pattern_id=AcquireString(pattern_id);
wand->pattern_bounds.x=(ssize_t) ceil(x-0.5);
wand->pattern_bounds.y=(ssize_t) ceil(y-0.5);
wand->pattern_bounds.width=(size_t) floor(width+0.5);
wand->pattern_bounds.height=(size_t) floor(height+0.5);
wand->pattern_offset=wand->mvg_length;
return(MagickTrue);
}
WandExport void DrawRectangle(DrawingWand *wand,const double x1,const double y1,
const double x2,const double y2)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) MVGPrintf(wand,"rectangle %.20g %.20g %.20g %.20g\n",x1,y1,x2,y2);
}
WandExport MagickBooleanType DrawRender(DrawingWand *wand)
{
MagickBooleanType
status;
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
CurrentContext->primitive=wand->mvg;
if (wand->debug != MagickFalse)
(void) LogMagickEvent(DrawEvent,GetMagickModule(),"MVG:\n'%s'\n",wand->mvg);
if (wand->image == (Image *) NULL)
ThrowDrawException(WandError,"ContainsNoImages",wand->name);
status=DrawImage(wand->image,CurrentContext);
InheritException(wand->exception,&wand->image->exception);
CurrentContext->primitive=(char *) NULL;
return(status);
}
WandExport void DrawResetVectorGraphics(DrawingWand *wand)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if (wand->mvg != (char *) NULL)
wand->mvg=DestroyString(wand->mvg);
wand->mvg_alloc=0;
wand->mvg_length=0;
wand->mvg_width=0;
}
WandExport void DrawRotate(DrawingWand *wand,const double degrees)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) MVGPrintf(wand,"rotate %.20g\n",degrees);
}
WandExport void DrawRoundRectangle(DrawingWand *wand,double x1,double y1,
double x2,double y2,double rx,double ry)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) MVGPrintf(wand,"roundrectangle %.20g %.20g %.20g %.20g %.20g %.20g\n",
x1,y1,x2,y2,rx,ry);
}
WandExport void DrawScale(DrawingWand *wand,const double x,const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) MVGPrintf(wand,"scale %.20g %.20g\n",x,y);
}
static inline MagickBooleanType IsColorEqual(const PixelPacket *p,
const PixelPacket *q)
{
if (GetPixelRed(p) != GetPixelRed(q))
return(MagickFalse);
if (GetPixelGreen(p) != GetPixelGreen(q))
return(MagickFalse);
if (GetPixelBlue(p) != GetPixelBlue(q))
return(MagickFalse);
if (GetPixelOpacity(p) != GetPixelOpacity(q))
return(MagickFalse);
return(MagickTrue);
}
WandExport void DrawSetBorderColor(DrawingWand *wand,
const PixelWand *border_wand)
{
PixelPacket
*current_border,
border_color,
new_border;
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
assert(border_wand != (const PixelWand *) NULL);
PixelGetQuantumColor(border_wand,&border_color);
new_border=border_color;
current_border=(&CurrentContext->border_color);
if ((wand->filter_off != MagickFalse) ||
(IsColorEqual(current_border,&new_border) == MagickFalse))
{
CurrentContext->border_color=new_border;
(void) MVGPrintf(wand,"border-color '");
MVGAppendColor(wand,&border_color);
(void) MVGPrintf(wand,"'\n");
}
}
WandExport MagickBooleanType DrawSetClipPath(DrawingWand *wand,
const char *clip_mask)
{
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",clip_mask);
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
assert(clip_mask != (const char *) NULL);
if ((CurrentContext->clip_mask == (const char *) NULL) ||
(wand->filter_off != MagickFalse) ||
(LocaleCompare(CurrentContext->clip_mask,clip_mask) != 0))
{
(void) CloneString(&CurrentContext->clip_mask,clip_mask);
#if DRAW_BINARY_IMPLEMENTATION
if (wand->image == (Image *) NULL)
ThrowDrawException(WandError,"ContainsNoImages",wand->name);
(void) DrawClipPath(wand->image,CurrentContext,CurrentContext->clip_mask);
#endif
(void) MVGPrintf(wand,"clip-path url(#%s)\n",clip_mask);
}
return(MagickTrue);
}
WandExport void DrawSetClipRule(DrawingWand *wand,const FillRule fill_rule)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->fill_rule != fill_rule))
{
CurrentContext->fill_rule=fill_rule;
(void) MVGPrintf(wand, "clip-rule '%s'\n",CommandOptionToMnemonic(
MagickFillRuleOptions,(ssize_t) fill_rule));
}
}
WandExport void DrawSetClipUnits(DrawingWand *wand,
const ClipPathUnits clip_units)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->clip_units != clip_units))
{
CurrentContext->clip_units=clip_units;
if (clip_units == ObjectBoundingBox)
{
AffineMatrix
affine;
GetAffineMatrix(&affine);
affine.sx=CurrentContext->bounds.x2;
affine.sy=CurrentContext->bounds.y2;
affine.tx=CurrentContext->bounds.x1;
affine.ty=CurrentContext->bounds.y1;
AdjustAffine(wand,&affine);
}
(void) MVGPrintf(wand, "clip-units '%s'\n",CommandOptionToMnemonic(
MagickClipPathOptions,(ssize_t) clip_units));
}
}
WandExport MagickBooleanType DrawSetDensity(DrawingWand *wand,
const char *density)
{
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",density);
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == MagickSignature);
assert(density != (const char *) NULL);
if ((CurrentContext->density == (const char *) NULL) ||
(wand->filter_off != MagickFalse) ||
(LocaleCompare(CurrentContext->density,density) != 0))
{
(void) CloneString(&CurrentContext->density,density);
(void) MVGPrintf(wand,"density '%s'\n",density);
}
return(MagickTrue);
}
WandExport void DrawSetFillColor(DrawingWand *wand,const PixelWand *fill_wand)
{
PixelPacket
*current_fill,
fill_color,
new_fill;
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
assert(fill_wand != (const PixelWand *) NULL);
PixelGetQuantumColor(fill_wand,&fill_color);
new_fill=fill_color;
current_fill=(&CurrentContext->fill);
if ((wand->filter_off != MagickFalse) ||
(IsColorEqual(current_fill,&new_fill) == MagickFalse))
{
CurrentContext->fill=new_fill;
(void) MVGPrintf(wand,"fill '");
MVGAppendColor(wand,&fill_color);
(void) MVGPrintf(wand,"'\n");
}
}
WandExport void DrawSetFillOpacity(DrawingWand *wand,const double fill_opacity)
{
Quantum
opacity;
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
opacity=ClampToQuantum((double) QuantumRange*(1.0-fill_opacity));
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->fill.opacity != opacity))
{
CurrentContext->fill.opacity=opacity;
(void) MVGPrintf(wand,"fill-opacity %.20g\n",fill_opacity);
}
}
WandExport MagickBooleanType DrawSetFontResolution(DrawingWand *wand,
const double x_resolution,const double y_resolution)
{
char
density[MaxTextExtent];
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) FormatLocaleString(density,MaxTextExtent,"%.20gx%.20g",x_resolution,
y_resolution);
(void) CloneString(&CurrentContext->density,density);
return(MagickTrue);
}
WandExport void DrawSetOpacity(DrawingWand *wand,const double opacity)
{
Quantum
quantum_opacity;
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
quantum_opacity=ClampToQuantum((double) QuantumRange*(1.0-opacity));
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->opacity != quantum_opacity))
{
CurrentContext->opacity=(Quantum) opacity;
(void) MVGPrintf(wand,"opacity %.20g\n",opacity);
}
}
WandExport MagickBooleanType DrawSetFillPatternURL(DrawingWand *wand,
const char *fill_url)
{
char
pattern[MaxTextExtent],
pattern_spec[MaxTextExtent];
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",fill_url);
if (wand->image == (Image *) NULL)
ThrowDrawException(WandError,"ContainsNoImages",wand->name);
assert(fill_url != (const char *) NULL);
if (*fill_url != '#')
{
ThrowDrawException(DrawError,"NotARelativeURL",fill_url);
return(MagickFalse);
}
(void) FormatLocaleString(pattern,MaxTextExtent,"%s",fill_url+1);
if (GetImageArtifact(wand->image,pattern) == (const char *) NULL)
{
ThrowDrawException(DrawError,"URLNotFound",fill_url)
return(MagickFalse);
}
(void) FormatLocaleString(pattern_spec,MaxTextExtent,"url(%s)",fill_url);
#if DRAW_BINARY_IMPLEMENTATION
DrawPatternPath(wand->image,CurrentContext,pattern_spec,
&CurrentContext->fill_pattern);
#endif
if (CurrentContext->fill.opacity != (Quantum) TransparentOpacity)
CurrentContext->fill.opacity=CurrentContext->opacity;
(void) MVGPrintf(wand,"fill %s\n",pattern_spec);
return(MagickTrue);
}
WandExport void DrawSetFillRule(DrawingWand *wand,const FillRule fill_rule)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->fill_rule != fill_rule))
{
CurrentContext->fill_rule=fill_rule;
(void) MVGPrintf(wand, "fill-rule '%s'\n",CommandOptionToMnemonic(
MagickFillRuleOptions,(ssize_t) fill_rule));
}
}
WandExport MagickBooleanType DrawSetFont(DrawingWand *wand,
const char *font_name)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
assert(font_name != (const char *) NULL);
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->font == (char *) NULL) ||
(LocaleCompare(CurrentContext->font,font_name) != 0))
{
(void) CloneString(&CurrentContext->font,font_name);
(void) MVGPrintf(wand,"font '%s'\n",font_name);
}
return(MagickTrue);
}
WandExport MagickBooleanType DrawSetFontFamily(DrawingWand *wand,
const char *font_family)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
assert(font_family != (const char *) NULL);
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->family == (const char *) NULL) ||
(LocaleCompare(CurrentContext->family,font_family) != 0))
{
(void) CloneString(&CurrentContext->family,font_family);
(void) MVGPrintf(wand,"font-family '%s'\n",font_family);
}
return(MagickTrue);
}
WandExport void DrawSetFontSize(DrawingWand *wand,const double pointsize)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) ||
(fabs(CurrentContext->pointsize-pointsize) >= MagickEpsilon))
{
CurrentContext->pointsize=pointsize;
(void) MVGPrintf(wand,"font-size %.20g\n",pointsize);
}
}
WandExport void DrawSetFontStretch(DrawingWand *wand,
const StretchType font_stretch)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->stretch != font_stretch))
{
CurrentContext->stretch=font_stretch;
(void) MVGPrintf(wand, "font-stretch '%s'\n",CommandOptionToMnemonic(
MagickStretchOptions,(ssize_t) font_stretch));
}
}
WandExport void DrawSetFontStyle(DrawingWand *wand,const StyleType style)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->style != style))
{
CurrentContext->style=style;
(void) MVGPrintf(wand, "font-style '%s'\n",CommandOptionToMnemonic(
MagickStyleOptions,(ssize_t) style));
}
}
WandExport void DrawSetFontWeight(DrawingWand *wand,
const size_t font_weight)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->weight != font_weight))
{
CurrentContext->weight=font_weight;
(void) MVGPrintf(wand,"font-weight %.20g\n",(double) font_weight);
}
}
WandExport void DrawSetGravity(DrawingWand *wand,const GravityType gravity)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->gravity != gravity) || (gravity != ForgetGravity))
{
CurrentContext->gravity=gravity;
(void) MVGPrintf(wand,"gravity '%s'\n",CommandOptionToMnemonic(
MagickGravityOptions,(ssize_t) gravity));
}
}
WandExport void DrawSetStrokeColor(DrawingWand *wand,
const PixelWand *stroke_wand)
{
PixelPacket
*current_stroke,
new_stroke,
stroke_color;
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
assert(stroke_wand != (const PixelWand *) NULL);
PixelGetQuantumColor(stroke_wand,&stroke_color);
new_stroke=stroke_color;
current_stroke=(&CurrentContext->stroke);
if ((wand->filter_off != MagickFalse) ||
(IsColorEqual(current_stroke,&new_stroke) == MagickFalse))
{
CurrentContext->stroke=new_stroke;
(void) MVGPrintf(wand,"stroke '");
MVGAppendColor(wand,&stroke_color);
(void) MVGPrintf(wand,"'\n");
}
}
WandExport MagickBooleanType DrawSetStrokePatternURL(DrawingWand *wand,
const char *stroke_url)
{
char
pattern[MaxTextExtent],
pattern_spec[MaxTextExtent];
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if (wand->image == (Image *) NULL)
ThrowDrawException(WandError,"ContainsNoImages",wand->name);
assert(stroke_url != NULL);
if (stroke_url[0] != '#')
ThrowDrawException(DrawError,"NotARelativeURL",stroke_url);
(void) FormatLocaleString(pattern,MaxTextExtent,"%s",stroke_url+1);
if (GetImageArtifact(wand->image,pattern) == (const char *) NULL)
{
ThrowDrawException(DrawError,"URLNotFound",stroke_url)
return(MagickFalse);
}
(void) FormatLocaleString(pattern_spec,MaxTextExtent,"url(%s)",stroke_url);
#if DRAW_BINARY_IMPLEMENTATION
DrawPatternPath(wand->image,CurrentContext,pattern_spec,
&CurrentContext->stroke_pattern);
#endif
if (CurrentContext->stroke.opacity != (Quantum) TransparentOpacity)
CurrentContext->stroke.opacity=CurrentContext->opacity;
(void) MVGPrintf(wand,"stroke %s\n",pattern_spec);
return(MagickTrue);
}
WandExport void DrawSetStrokeAntialias(DrawingWand *wand,
const MagickBooleanType stroke_antialias)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->stroke_antialias != stroke_antialias))
{
CurrentContext->stroke_antialias=stroke_antialias;
(void) MVGPrintf(wand,"stroke-antialias %i\n",stroke_antialias != 0 ?
1 : 0);
}
}
WandExport MagickBooleanType DrawSetStrokeDashArray(DrawingWand *wand,
const size_t number_elements,const double *dasharray)
{
MagickBooleanType
update;
register const double
*p;
register double
*q;
register ssize_t
i;
size_t
n_new,
n_old;
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
n_new=number_elements;
if (dasharray == (const double *) NULL)
n_new=0;
n_old=0;
update=MagickFalse;
q=CurrentContext->dash_pattern;
if (q != (const double *) NULL)
while (*q++ != 0.0)
n_old++;
if ((n_old == 0) && (n_new == 0))
update=MagickFalse;
else
if (n_old != n_new)
update=MagickTrue;
else
if ((CurrentContext->dash_pattern != (double *) NULL) &&
(dasharray != (double *) NULL))
{
p=dasharray;
q=CurrentContext->dash_pattern;
for (i=0; i < (ssize_t) n_new; i++)
{
if (fabs((*p)-(*q)) >= MagickEpsilon)
{
update=MagickTrue;
break;
}
p++;
q++;
}
}
if ((wand->filter_off != MagickFalse) || (update != MagickFalse))
{
if (CurrentContext->dash_pattern != (double *) NULL)
CurrentContext->dash_pattern=(double *)
RelinquishMagickMemory(CurrentContext->dash_pattern);
if (n_new != 0)
{
CurrentContext->dash_pattern=(double *) AcquireQuantumMemory((size_t)
n_new+1UL,sizeof(*CurrentContext->dash_pattern));
if (CurrentContext->dash_pattern == (double *) NULL)
{
ThrowDrawException(ResourceLimitError,"MemoryAllocationFailed",
wand->name);
return(MagickFalse);
}
for (i=0; i < (ssize_t) n_new; i++)
{
CurrentContext->dash_pattern[i]=0.0;
if (dasharray != (double *) NULL)
CurrentContext->dash_pattern[i]=dasharray[i];
}
CurrentContext->dash_pattern[n_new]=0.0;
}
(void) MVGPrintf(wand,"stroke-dasharray ");
if (n_new == 0)
(void) MVGPrintf(wand,"none\n");
else
if (dasharray != (double *) NULL)
{
for (i=0; i < (ssize_t) n_new; i++)
{
if (i != 0)
(void) MVGPrintf(wand,",");
(void) MVGPrintf(wand,"%.20g",dasharray[i]);
}
(void) MVGPrintf(wand,"\n");
}
}
return(MagickTrue);
}
WandExport void DrawSetStrokeDashOffset(DrawingWand *wand,
const double dash_offset)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) ||
(fabs(CurrentContext->dash_offset-dash_offset) >= MagickEpsilon))
{
CurrentContext->dash_offset=dash_offset;
(void) MVGPrintf(wand,"stroke-dashoffset %.20g\n",dash_offset);
}
}
WandExport void DrawSetStrokeLineCap(DrawingWand *wand,const LineCap linecap)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->linecap != linecap))
{
CurrentContext->linecap=linecap;
(void) MVGPrintf(wand,"stroke-linecap '%s'\n",CommandOptionToMnemonic(
MagickLineCapOptions,(ssize_t) linecap));
}
}
WandExport void DrawSetStrokeLineJoin(DrawingWand *wand,const LineJoin linejoin)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->linejoin != linejoin))
{
CurrentContext->linejoin=linejoin;
(void) MVGPrintf(wand, "stroke-linejoin '%s'\n",CommandOptionToMnemonic(
MagickLineJoinOptions,(ssize_t) linejoin));
}
}
WandExport void DrawSetStrokeMiterLimit(DrawingWand *wand,
const size_t miterlimit)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if (CurrentContext->miterlimit != miterlimit)
{
CurrentContext->miterlimit=miterlimit;
(void) MVGPrintf(wand,"stroke-miterlimit %.20g\n",(double) miterlimit);
}
}
WandExport void DrawSetStrokeOpacity(DrawingWand *wand,
const double stroke_opacity)
{
Quantum
opacity;
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
opacity=ClampToQuantum((double) QuantumRange*(1.0-stroke_opacity));
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->stroke.opacity != opacity))
{
CurrentContext->stroke.opacity=opacity;
(void) MVGPrintf(wand,"stroke-opacity %.20g\n",stroke_opacity);
}
}
WandExport void DrawSetStrokeWidth(DrawingWand *wand,const double stroke_width)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) ||
(fabs(CurrentContext->stroke_width-stroke_width) >= MagickEpsilon))
{
CurrentContext->stroke_width=stroke_width;
(void) MVGPrintf(wand,"stroke-width %.20g\n",stroke_width);
}
}
WandExport void DrawSetTextAlignment(DrawingWand *wand,
const AlignType alignment)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->align != alignment))
{
CurrentContext->align=alignment;
(void) MVGPrintf(wand,"text-align '%s'\n",CommandOptionToMnemonic(
MagickAlignOptions,(ssize_t) alignment));
}
}
WandExport void DrawSetTextAntialias(DrawingWand *wand,
const MagickBooleanType text_antialias)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->text_antialias != text_antialias))
{
CurrentContext->text_antialias=text_antialias;
(void) MVGPrintf(wand,"text-antialias %i\n",text_antialias != 0 ? 1 : 0);
}
}
WandExport void DrawSetTextDecoration(DrawingWand *wand,
const DecorationType decoration)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->decorate != decoration))
{
CurrentContext->decorate=decoration;
(void) MVGPrintf(wand,"decorate '%s'\n",CommandOptionToMnemonic(
MagickDecorateOptions,(ssize_t) decoration));
}
}
WandExport void DrawSetTextDirection(DrawingWand *wand,
const DirectionType direction)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->direction != direction))
{
CurrentContext->direction=direction;
(void) MVGPrintf(wand,"direction '%s'\n",CommandOptionToMnemonic(
MagickDirectionOptions,(ssize_t) direction));
}
}
WandExport void DrawSetTextEncoding(DrawingWand *wand,const char *encoding)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
assert(encoding != (char *) NULL);
if ((wand->filter_off != MagickFalse) ||
(CurrentContext->encoding == (char *) NULL) ||
(LocaleCompare(CurrentContext->encoding,encoding) != 0))
{
(void) CloneString(&CurrentContext->encoding,encoding);
(void) MVGPrintf(wand,"encoding '%s'\n",encoding);
}
}
WandExport void DrawSetTextKerning(DrawingWand *wand,const double kerning)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) &&
(CurrentContext->kerning != kerning))
{
CurrentContext->kerning=kerning;
(void) MVGPrintf(wand,"kerning %lf\n",kerning);
}
}
WandExport void DrawSetTextInterlineSpacing(DrawingWand *wand,
const double interline_spacing)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) &&
(CurrentContext->interline_spacing != interline_spacing))
{
CurrentContext->interline_spacing=interline_spacing;
(void) MVGPrintf(wand,"interline-spacing %lf\n",interline_spacing);
}
}
WandExport void DrawSetTextInterwordSpacing(DrawingWand *wand,
const double interword_spacing)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if ((wand->filter_off != MagickFalse) &&
(CurrentContext->interword_spacing != interword_spacing))
{
CurrentContext->interword_spacing=interword_spacing;
(void) MVGPrintf(wand,"interword-spacing %lf\n",interword_spacing);
}
}
WandExport void DrawSetTextUnderColor(DrawingWand *wand,
const PixelWand *under_wand)
{
PixelPacket
under_color;
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
assert(under_wand != (const PixelWand *) NULL);
PixelGetQuantumColor(under_wand,&under_color);
if ((wand->filter_off != MagickFalse) ||
(IsColorEqual(&CurrentContext->undercolor,&under_color) == MagickFalse))
{
CurrentContext->undercolor=under_color;
(void) MVGPrintf(wand,"text-undercolor '");
MVGAppendColor(wand,&under_color);
(void) MVGPrintf(wand,"'\n");
}
}
static inline MagickBooleanType IsPoint(const char *point)
{
char
*p;
long
value;
value=strtol(point,&p,10);
(void) value;
return(p != point ? MagickTrue : MagickFalse);
}
WandExport MagickBooleanType DrawSetVectorGraphics(DrawingWand *wand,
const char *xml)
{
const char
*value;
XMLTreeInfo
*child,
*xml_info;
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
CurrentContext=DestroyDrawInfo(CurrentContext);
CurrentContext=CloneDrawInfo((ImageInfo *) NULL,(DrawInfo *) NULL);
if (xml == (const char *) NULL)
return(MagickFalse);
xml_info=NewXMLTree(xml,wand->exception);
if (xml_info == (XMLTreeInfo *) NULL)
return(MagickFalse);
child=GetXMLTreeChild(xml_info,"clip-path");
if (child != (XMLTreeInfo *) NULL)
(void) CloneString(&CurrentContext->clip_mask,GetXMLTreeContent(child));
child=GetXMLTreeChild(xml_info,"clip-units");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
CurrentContext->clip_units=(ClipPathUnits) ParseCommandOption(
MagickClipPathOptions,MagickFalse,value);
}
child=GetXMLTreeChild(xml_info,"decorate");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
CurrentContext->decorate=(DecorationType) ParseCommandOption(
MagickDecorateOptions,MagickFalse,value);
}
child=GetXMLTreeChild(xml_info,"encoding");
if (child != (XMLTreeInfo *) NULL)
(void) CloneString(&CurrentContext->encoding,GetXMLTreeContent(child));
child=GetXMLTreeChild(xml_info,"fill");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
(void) QueryColorDatabase(value,&CurrentContext->fill,wand->exception);
}
child=GetXMLTreeChild(xml_info,"fill-opacity");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
CurrentContext->fill.opacity=ClampToQuantum((MagickRealType)
QuantumRange*(1.0-StringToDouble(value,(char **) NULL)));
}
child=GetXMLTreeChild(xml_info,"fill-rule");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
CurrentContext->fill_rule=(FillRule) ParseCommandOption(
MagickFillRuleOptions,MagickFalse,value);
}
child=GetXMLTreeChild(xml_info,"font");
if (child != (XMLTreeInfo *) NULL)
(void) CloneString(&CurrentContext->font,GetXMLTreeContent(child));
child=GetXMLTreeChild(xml_info,"font-family");
if (child != (XMLTreeInfo *) NULL)
(void) CloneString(&CurrentContext->family,GetXMLTreeContent(child));
child=GetXMLTreeChild(xml_info,"font-size");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
CurrentContext->pointsize=StringToDouble(value,(char **) NULL);
}
child=GetXMLTreeChild(xml_info,"font-stretch");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
CurrentContext->stretch=(StretchType) ParseCommandOption(
MagickStretchOptions,MagickFalse,value);
}
child=GetXMLTreeChild(xml_info,"font-style");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
CurrentContext->style=(StyleType) ParseCommandOption(MagickStyleOptions,
MagickFalse,value);
}
child=GetXMLTreeChild(xml_info,"font-weight");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
CurrentContext->weight=StringToUnsignedLong(value);
}
child=GetXMLTreeChild(xml_info,"gravity");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
CurrentContext->gravity=(GravityType) ParseCommandOption(
MagickGravityOptions,MagickFalse,value);
}
child=GetXMLTreeChild(xml_info,"stroke");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
(void) QueryColorDatabase(value,&CurrentContext->stroke,
wand->exception);
}
child=GetXMLTreeChild(xml_info,"stroke-antialias");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
CurrentContext->stroke_antialias=StringToLong(value) != 0 ? MagickTrue :
MagickFalse;
}
child=GetXMLTreeChild(xml_info,"stroke-dasharray");
if (child != (XMLTreeInfo *) NULL)
{
char
token[MaxTextExtent];
const char
*q;
register ssize_t
x;
ssize_t
j;
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
{
if (CurrentContext->dash_pattern != (double *) NULL)
CurrentContext->dash_pattern=(double *) RelinquishMagickMemory(
CurrentContext->dash_pattern);
q=(char *) value;
if (IsPoint(q) != MagickFalse)
{
const char
*p;
p=q;
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
for (x=0; IsPoint(token) != MagickFalse; x++)
{
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
}
CurrentContext->dash_pattern=(double *) AcquireQuantumMemory(
(size_t) (2UL*x)+1UL,sizeof(*CurrentContext->dash_pattern));
if (CurrentContext->dash_pattern == (double *) NULL)
ThrowWandFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",wand->name);
for (j=0; j < x; j++)
{
GetMagickToken(q,&q,token);
if (*token == ',')
GetMagickToken(q,&q,token);
CurrentContext->dash_pattern[j]=StringToDouble(token,
(char **) NULL);
}
if ((x & 0x01) != 0)
for ( ; j < (2*x); j++)
CurrentContext->dash_pattern[j]=
CurrentContext->dash_pattern[j-x];
CurrentContext->dash_pattern[j]=0.0;
}
}
}
child=GetXMLTreeChild(xml_info,"stroke-dashoffset");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
CurrentContext->dash_offset=StringToDouble(value,(char **) NULL);
}
child=GetXMLTreeChild(xml_info,"stroke-linecap");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
CurrentContext->linecap=(LineCap) ParseCommandOption(
MagickLineCapOptions,MagickFalse,value);
}
child=GetXMLTreeChild(xml_info,"stroke-linejoin");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
CurrentContext->linejoin=(LineJoin) ParseCommandOption(
MagickLineJoinOptions,MagickFalse,value);
}
child=GetXMLTreeChild(xml_info,"stroke-miterlimit");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
CurrentContext->miterlimit=StringToUnsignedLong(value);
}
child=GetXMLTreeChild(xml_info,"stroke-opacity");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
CurrentContext->stroke.opacity=ClampToQuantum((MagickRealType)
QuantumRange*(1.0-StringToDouble(value,(char **) NULL)));
}
child=GetXMLTreeChild(xml_info,"stroke-width");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
{
ssize_t
weight;
weight=ParseCommandOption(MagickWeightOptions,MagickFalse,value);
if (weight == -1)
weight=StringToUnsignedLong(value);
CurrentContext->stroke_width=(size_t) weight;
}
}
child=GetXMLTreeChild(xml_info,"text-align");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
CurrentContext->align=(AlignType) ParseCommandOption(MagickAlignOptions,
MagickFalse,value);
}
child=GetXMLTreeChild(xml_info,"text-antialias");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
CurrentContext->text_antialias=StringToLong(value) != 0 ? MagickTrue :
MagickFalse;
}
child=GetXMLTreeChild(xml_info,"text-undercolor");
if (child != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeContent(child);
if (value != (const char *) NULL)
(void) QueryColorDatabase(value,&CurrentContext->undercolor,
wand->exception);
}
child=GetXMLTreeChild(xml_info,"vector-graphics");
if (child != (XMLTreeInfo *) NULL)
{
(void) CloneString(&wand->mvg,GetXMLTreeContent(child));
wand->mvg_length=strlen(wand->mvg);
wand->mvg_alloc=wand->mvg_length+1;
}
xml_info=DestroyXMLTree(xml_info);
return(MagickTrue);
}
WandExport void DrawSkewX(DrawingWand *wand,const double degrees)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) MVGPrintf(wand,"skewX %.20g\n",degrees);
}
WandExport void DrawSkewY(DrawingWand *wand,const double degrees)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) MVGPrintf(wand,"skewY %.20g\n",degrees);
}
WandExport void DrawTranslate(DrawingWand *wand,const double x,const double y)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) MVGPrintf(wand,"translate %.20g %.20g\n",x,y);
}
WandExport void DrawSetViewbox(DrawingWand *wand,ssize_t x1,ssize_t y1,
ssize_t x2,ssize_t y2)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) MVGPrintf(wand,"viewbox %.20g %.20g %.20g %.20g\n",(double) x1,
(double) y1,(double) x2,(double) y2);
}
WandExport MagickBooleanType IsDrawingWand(const DrawingWand *wand)
{
if (wand == (const DrawingWand *) NULL)
return(MagickFalse);
if (wand->signature != WandSignature)
return(MagickFalse);
if (LocaleNCompare(wand->name,DrawingWandId,strlen(DrawingWandId)) != 0)
return(MagickFalse);
return(MagickTrue);
}
WandExport DrawingWand *NewDrawingWand(void)
{
const char
*quantum;
DrawingWand
*wand;
size_t
depth;
quantum=GetMagickQuantumDepth(&depth);
if (depth != MAGICKCORE_QUANTUM_DEPTH)
ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum);
wand=(DrawingWand *) AcquireMagickMemory(sizeof(*wand));
if (wand == (DrawingWand *) NULL)
ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
GetExceptionMessage(errno));
(void) ResetMagickMemory(wand,0,sizeof(*wand));
wand->id=AcquireWandId();
(void) FormatLocaleString(wand->name,MaxTextExtent,"%s-%.20g",DrawingWandId,
(double) wand->id);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
wand->mvg=(char *) NULL;
wand->mvg_alloc=0;
wand->mvg_length=0;
wand->mvg_width=0;
wand->pattern_id=(char *) NULL;
wand->pattern_offset=0;
wand->pattern_bounds.x=0;
wand->pattern_bounds.y=0;
wand->pattern_bounds.width=0;
wand->pattern_bounds.height=0;
wand->index=0;
wand->graphic_context=(DrawInfo **) AcquireMagickMemory(sizeof(
*wand->graphic_context));
if (wand->graphic_context == (DrawInfo **) NULL)
ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
GetExceptionMessage(errno));
wand->filter_off=MagickTrue;
wand->indent_depth=0;
wand->path_operation=PathDefaultOperation;
wand->path_mode=DefaultPathMode;
wand->image=AcquireImage((const ImageInfo *) NULL);
wand->exception=AcquireExceptionInfo();
wand->destroy=MagickTrue;
wand->debug=IsEventLogging();
wand->signature=WandSignature;
CurrentContext=CloneDrawInfo((ImageInfo *) NULL,(DrawInfo *) NULL);
return(wand);
}
WandExport DrawInfo *PeekDrawingWand(const DrawingWand *wand)
{
DrawInfo
*draw_info;
assert(wand != (const DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
draw_info=CloneDrawInfo((ImageInfo *) NULL,CurrentContext);
GetAffineMatrix(&draw_info->affine);
(void) CloneString(&draw_info->primitive,wand->mvg);
return(draw_info);
}
WandExport MagickBooleanType PopDrawingWand(DrawingWand *wand)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if (wand->index == 0)
{
ThrowDrawException(DrawError,"UnbalancedGraphicContextPushPop",wand->name)
return(MagickFalse);
}
#if DRAW_BINARY_IMPLEMENTATION
if (wand->image == (Image *) NULL)
ThrowDrawException(WandError,"ContainsNoImages",wand->name);
if (CurrentContext->clip_mask != (char *) NULL)
if (LocaleCompare(CurrentContext->clip_mask,
wand->graphic_context[wand->index-1]->clip_mask) != 0)
(void) SetImageClipMask(wand->image,(Image *) NULL);
#endif
CurrentContext=DestroyDrawInfo(CurrentContext);
wand->index--;
if (wand->indent_depth > 0)
wand->indent_depth--;
(void) MVGPrintf(wand,"pop graphic-context\n");
return(MagickTrue);
}
WandExport MagickBooleanType PushDrawingWand(DrawingWand *wand)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
wand->index++;
wand->graphic_context=(DrawInfo **) ResizeQuantumMemory(wand->graphic_context,
(size_t) wand->index+1UL,sizeof(*wand->graphic_context));
if (wand->graphic_context == (DrawInfo **) NULL)
{
wand->index--;
ThrowDrawException(ResourceLimitError,"MemoryAllocationFailed",
wand->name);
return(MagickFalse);
}
CurrentContext=CloneDrawInfo((ImageInfo *) NULL,
wand->graphic_context[wand->index-1]);
(void) MVGPrintf(wand,"push graphic-context\n");
wand->indent_depth++;
return(MagickTrue);
}