11 #define MAGICKCORE_IMPLEMENTATION 1
12 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
24 #define MagickPI 3.14159265358979323846264338327950288419716939937510
25 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
28 : _imageInfo(static_cast<ImageInfo*>(AcquireMagickMemory(
30 _quantizeInfo(static_cast<QuantizeInfo*>(AcquireMagickMemory(
31 sizeof(QuantizeInfo)))),
32 _drawInfo(static_cast<DrawInfo*>(AcquireMagickMemory(sizeof(DrawInfo)))),
36 GetImageInfo(_imageInfo);
39 GetQuantizeInfo(_quantizeInfo);
42 GetDrawInfo(_imageInfo,_drawInfo);
46 : _imageInfo(CloneImageInfo(options_._imageInfo)),
47 _quantizeInfo(CloneQuantizeInfo(options_._quantizeInfo)),
48 _drawInfo(CloneDrawInfo(_imageInfo,options_._drawInfo)),
56 _imageInfo=DestroyImageInfo(_imageInfo);
59 _quantizeInfo=DestroyQuantizeInfo(_quantizeInfo);
62 _drawInfo=DestroyDrawInfo(_drawInfo);
67 _drawInfo->text_antialias=
static_cast<MagickBooleanType
>(
68 flag_ ? MagickTrue : MagickFalse);
73 return(static_cast<bool>(_drawInfo->text_antialias));
78 _imageInfo->adjoin=
static_cast<MagickBooleanType
>(
79 flag_ ? MagickTrue : MagickFalse);
84 return(static_cast<bool>(_imageInfo->adjoin));
89 _imageInfo->background_color=color_;
99 if (backgroundTexture_.length() == 0)
100 _imageInfo->texture=(
char *) RelinquishMagickMemory(_imageInfo->texture);
107 if (_imageInfo->texture)
108 return(std::string(_imageInfo->texture));
110 return(std::string());
115 _imageInfo->border_color=color_;
116 _drawInfo->border_color=color_;
126 _drawInfo->undercolor=boxColor_;
136 _imageInfo->colorspace=colorspace_;
141 return(static_cast<Magick::ColorspaceType>(_imageInfo->colorspace));
146 _imageInfo->compression=compressType_;
151 return(static_cast<Magick::CompressionType>(_imageInfo->compression));
156 _imageInfo->fuzz=fuzz_;
161 return(_imageInfo->fuzz);
167 SetLogEventMask(
"All");
169 SetLogEventMask(
"None");
174 if (IsEventLogging())
183 _imageInfo->density=(
char *) RelinquishMagickMemory(_imageInfo->density);
190 if (_imageInfo->density)
191 return(
Geometry(_imageInfo->density));
198 _imageInfo->depth=depth_;
203 return(_imageInfo->depth);
208 _imageInfo->endian=endian_;
213 return(_imageInfo->endian);
218 SetImageInfoFile(_imageInfo,file_);
223 return(GetImageInfoFile(_imageInfo));
228 fileName_.copy(_imageInfo->filename,MaxTextExtent-1);
229 if (fileName_.length() > MaxTextExtent-1)
230 _imageInfo->filename[MaxTextExtent-1]=0;
232 _imageInfo->filename[fileName_.length()]=0;
237 return(std::string(_imageInfo->filename));
242 _drawInfo->fill=fillColor_;
245 setOption(
"fill",fillColor_);
250 return(_drawInfo->fill);
255 if (_drawInfo->fill_pattern)
257 DestroyImageList(_drawInfo->fill_pattern);
258 _drawInfo->fill_pattern=0;
263 _drawInfo->fill_pattern=CloneImage(const_cast<MagickCore::Image*>(
264 fillPattern_),0,0,static_cast<MagickBooleanType>(MagickTrue),
272 return(_drawInfo->fill_pattern);
277 _drawInfo->fill_rule=fillRule_;
282 return(_drawInfo->fill_rule);
287 if (font_.length() == 0)
289 _imageInfo->font=(
char *) RelinquishMagickMemory(_imageInfo->font);
290 _drawInfo->font=(
char *) RelinquishMagickMemory(_drawInfo->font);
301 if (_imageInfo->font)
302 return(std::string(_imageInfo->font));
304 return(std::string());
309 if (family_.length() == 0)
311 _drawInfo->family=(
char *) RelinquishMagickMemory(_drawInfo->font);
312 DestroyString(RemoveImageOption(imageInfo(),
"family"));
317 (void) SetImageOption(imageInfo(),
"family",family_.c_str());
323 if (_drawInfo->family)
324 return(std::string(_drawInfo->family));
326 return(std::string());
331 _imageInfo->pointsize=pointSize_;
332 _drawInfo->pointsize=pointSize_;
337 return(_imageInfo->pointsize);
342 _drawInfo->style=style_;
343 (void) SetImageOption(_imageInfo,
"style",CommandOptionToMnemonic(
344 MagickStyleOptions,(ssize_t) style_));
349 return(_drawInfo->style);
354 _drawInfo->weight=weight_;
355 setOption(
"weight",(
double) weight_);
360 return(_drawInfo->weight);
370 if (*_imageInfo->magick !=
'\0')
371 magick_info=GetMagickInfo(_imageInfo->magick,exceptionInfo);
374 if ((magick_info != 0) && (*magick_info->description !=
'\0'))
375 return(std::string(magick_info->description));
377 return(std::string());
382 _imageInfo->interlace=interlace_;
387 return(static_cast<Magick::InterlaceType>(_imageInfo->interlace));
394 _imageInfo->magick[0] =
'\0';
398 FormatLocaleString(_imageInfo->filename,MaxTextExtent,
"%.1024s:",
401 SetImageInfo(_imageInfo,1,exceptionInfo);
403 if ( _imageInfo->magick[0] ==
'\0' )
410 if ( _imageInfo->magick[0] !=
'\0' )
411 return(std::string(_imageInfo->magick));
413 return(std::string());
418 _imageInfo->matte_color=matteColor_;
428 _imageInfo->monochrome=(MagickBooleanType) monochromeFlag_;
433 return(static_cast<bool>(_imageInfo->monochrome));
439 _imageInfo->page=(
char *) RelinquishMagickMemory(_imageInfo->page);
446 if (_imageInfo->page)
454 _imageInfo->quality=quality_;
459 return(_imageInfo->quality);
464 _quantizeInfo->number_colors=colors_;
469 return(_quantizeInfo->number_colors);
474 _quantizeInfo->colorspace=colorSpace_;
479 return(static_cast<Magick::ColorspaceType>(_quantizeInfo->colorspace));
484 _imageInfo->dither=(MagickBooleanType) ditherFlag_;
485 _quantizeInfo->dither=(MagickBooleanType) ditherFlag_;
490 return(static_cast<bool>(_imageInfo->dither));
495 _quantizeInfo->dither_method=ditherMethod_;
500 return(_quantizeInfo->dither_method);
505 _quantizeInfo->tree_depth=treeDepth_;
510 return(_quantizeInfo->tree_depth);
525 _imageInfo->units=resolutionUnits_;
530 return(_imageInfo->units);
535 if (samplingFactor_.length() == 0)
536 _imageInfo->sampling_factor=(
char *) RelinquishMagickMemory(
537 _imageInfo->sampling_factor);
544 if (_imageInfo->sampling_factor)
545 return(std::string(_imageInfo->sampling_factor));
547 return(std::string());
552 _imageInfo->size=(
char *) RelinquishMagickMemory(_imageInfo->size);
560 if (_imageInfo->size)
568 flag_ ? _drawInfo->stroke_antialias=MagickTrue :
569 _drawInfo->stroke_antialias=MagickFalse;
574 return(_drawInfo->stroke_antialias != 0 ?
true :
false);
579 _drawInfo->stroke=strokeColor_;
582 setOption(
"stroke",strokeColor_);
587 return(_drawInfo->stroke);
592 _drawInfo->dash_pattern=(
double *) RelinquishMagickMemory(
593 _drawInfo->dash_pattern);
601 for (x=0; strokeDashArray_[x]; x++) ;
603 _drawInfo->dash_pattern=
static_cast<double*
>(AcquireMagickMemory((x+1)*
606 memcpy(_drawInfo->dash_pattern,strokeDashArray_,(x+1)*
sizeof(
double));
607 _drawInfo->dash_pattern[x]=0.0;
613 return(_drawInfo->dash_pattern);
618 _drawInfo->dash_offset=strokeDashOffset_;
623 return(_drawInfo->dash_offset);
628 _drawInfo->linecap=lineCap_;
633 return(_drawInfo->linecap);
638 _drawInfo->linejoin=lineJoin_;
643 return(_drawInfo->linejoin);
648 _drawInfo->miterlimit=miterLimit_;
653 return(_drawInfo->miterlimit);
658 if (_drawInfo->stroke_pattern)
659 _drawInfo->stroke_pattern=DestroyImageList(_drawInfo->stroke_pattern);
664 _drawInfo->stroke_pattern=CloneImage(const_cast<MagickCore::Image*>(
665 strokePattern_),0,0,MagickTrue,exceptionInfo);
672 return(_drawInfo->stroke_pattern);
677 _drawInfo->stroke_width=strokeWidth_;
682 return(_drawInfo->stroke_width);
687 _imageInfo->scene=subImage_;
692 return(_imageInfo->scene);
697 _imageInfo->number_scenes=subRange_;
702 return(_imageInfo->number_scenes);
707 _drawInfo->direction=direction_;
708 (void) SetImageOption(_imageInfo,
"direction",CommandOptionToMnemonic(
709 MagickDirectionOptions,(ssize_t) direction_));
714 return(_drawInfo->direction);
719 CloneString(&_drawInfo->encoding,encoding_.c_str());
720 (void) SetImageOption(imageInfo(),
"encoding",encoding_.c_str());
725 if (_drawInfo->encoding && *_drawInfo->encoding)
726 return(std::string(_drawInfo->encoding));
728 return(std::string());
733 _drawInfo->gravity=gravity_;
734 (void) SetImageOption(_imageInfo,
"gravity",CommandOptionToMnemonic(
735 MagickGravityOptions,(ssize_t) gravity_));
740 return(_drawInfo->gravity);
745 _drawInfo->interline_spacing=spacing_;
746 setOption(
"interline-spacing",spacing_);
751 return(_drawInfo->interline_spacing);
756 _drawInfo->interword_spacing=spacing_;
757 setOption(
"interword-spacing",spacing_);
762 return(_drawInfo->interword_spacing);
767 _drawInfo->kerning=kerning_;
768 setOption(
"kerning",kerning_);
773 return(_drawInfo->kerning);
778 _drawInfo->undercolor=undercolor_;
779 setOption(
"undercolor",undercolor_);
784 return(_drawInfo->undercolor);
790 if (tileName_.length() == 0)
791 _imageInfo->tile=(
char *) RelinquishMagickMemory(_imageInfo->tile);
798 if (_imageInfo->tile)
799 return(std::string(_imageInfo->tile));
800 return(std::string());
807 current=_drawInfo->affine;
819 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
820 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
821 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
822 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
823 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
824 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
829 _drawInfo->affine.sx=1.0;
830 _drawInfo->affine.rx=0.0;
831 _drawInfo->affine.ry=0.0;
832 _drawInfo->affine.sy=1.0;
833 _drawInfo->affine.tx=0.0;
834 _drawInfo->affine.ty=0.0;
841 current=_drawInfo->affine;
855 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
856 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
857 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
858 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
859 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
860 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
867 current=_drawInfo->affine;
879 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
880 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
881 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
882 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
883 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
884 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
891 current=_drawInfo->affine;
904 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
905 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
906 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
907 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
908 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
909 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
916 current=_drawInfo->affine;
929 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
930 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
931 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
932 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
933 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
934 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
939 _imageInfo->type=type_;
944 return(_imageInfo->type);
949 _imageInfo->verbose=(MagickBooleanType) verboseFlag_;
954 return(static_cast<bool>(_imageInfo->verbose));
958 VirtualPixelMethod virtual_pixel_method_)
960 _imageInfo->virtual_pixel_method=virtual_pixel_method_;
965 return(static_cast<Magick::VirtualPixelMethod>(
966 _imageInfo->virtual_pixel_method));
971 if (view_.length() == 0)
972 _imageInfo->view=(
char *) RelinquishMagickMemory(_imageInfo->view);
979 if (_imageInfo->view)
980 return(std::string(_imageInfo->view));
982 return(std::string());
987 if (display_.length() == 0)
988 _imageInfo->server_name=(
char *) RelinquishMagickMemory(
989 _imageInfo->server_name);
996 if (_imageInfo->server_name)
997 return(std::string(_imageInfo->server_name));
999 return(std::string());
1014 return(_quantizeInfo);
1018 const MagickCore::QuantizeInfo *quantizeInfo_,
1019 const MagickCore::DrawInfo *drawInfo_)
1020 : _imageInfo((
MagickCore::ImageInfo* ) NULL),
1021 _quantizeInfo((
MagickCore::QuantizeInfo* ) NULL),
1025 _imageInfo=CloneImageInfo(imageInfo_);
1026 _quantizeInfo=CloneQuantizeInfo(quantizeInfo_);
1027 _drawInfo=CloneDrawInfo(imageInfo_,drawInfo_);
1030 void Magick::Options::setOption(
const char *name,
const Color &value_)
1036 (void) SetImageOption(imageInfo(),name,option.c_str());
1039 void Magick::Options::setOption(
const char *name,
const double value_)
1042 option[MaxTextExtent];
1044 (void) FormatLocaleString(option,MaxTextExtent,
"%.20g",value_);
1045 (void) SetImageOption(_imageInfo,name,option);
std::string view(void) const
LineJoin strokeLineJoin(void) const
Geometry size(void) const
EndianType endian(void) const
#define DegreesToRadians(x)
MagickCore::QuantizeInfo * quantizeInfo(void)
GravityType textGravity() const
Color fillColor(void) const
CompressionType compressType(void) const
std::string fileName(void) const
std::string samplingFactor(void) const
std::string format(void) const
const double * strokeDashArray(void) const
ResolutionType resolutionUnits(void) const
size_t fontWeight(void) const
MagickCore::ImageInfo * imageInfo(void)
bool antiAlias(void) const
double strokeDashOffset(void) const
std::string textEncoding(void) const
void transformSkewX(double skewx_)
void transformReset(void)
const MagickCore::Image * fillPattern(void) const
Color strokeColor(void) const
Geometry page(void) const
ColorspaceType quantizeColorSpace(void) const
double fontPointsize(void) const
ColorspaceType colorspaceType(void) const
size_t subImage(void) const
size_t quality(void) const
bool strokeAntiAlias(void) const
void transformScale(double sx_, double sy_)
std::string magick(void) const
size_t subRange(void) const
double strokeWidth(void) const
bool monochrome(void) const
VirtualPixelMethod virtualPixelMethod(void) const
InterlaceType interlaceType(void) const
class MagickPPExport Geometry
Geometry density(void) const
void transformRotation(double angle_)
std::string x11Display(void) const
Color matteColor(void) const
double colorFuzz(void) const
std::string tileName(void) const
size_t quantizeColors(void) const
MagickPPExport void throwExceptionExplicit(const MagickCore::ExceptionType severity_, const char *reason_, const char *description_=(char *) NULL)
bool quantizeDither(void) const
std::string font(void) const
void transformSkewY(double skewy_)
Color boxColor(void) const
Color borderColor(void) const
ImageType type(void) const
#define ThrowPPException(quiet)
double textInterlineSpacing(void) const
FillRule fillRule(void) const
Color backgroundColor(void) const
DirectionType textDirection() const
size_t strokeMiterLimit(void) const
Color textUnderColor(void) const
MagickCore::DrawInfo * drawInfo(void)
std::string fontFamily(void) const
LineCap strokeLineCap(void) const
MagickPPExport void CloneString(char **destination_, const std::string &source_)
class MagickPPExport Image
DitherMethod quantizeDitherMethod(void) const
const MagickCore::Image * strokePattern(void) const
std::string backgroundTexture(void) const
void transformOrigin(double tx_, double ty_)
void isValid(bool isValid_)
double textKerning(void) const
StyleType fontStyle(void) const
double textInterwordSpacing(void) const
size_t quantizeTreeDepth(void) const