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)),
49 _quiet(options_._quiet)
56 _imageInfo=DestroyImageInfo(_imageInfo);
59 _quantizeInfo=DestroyQuantizeInfo(_quantizeInfo);
62 _drawInfo=DestroyDrawInfo(_drawInfo);
67 _imageInfo->adjoin=
static_cast<MagickBooleanType
>(
68 flag_ ? MagickTrue : MagickFalse);
73 return(static_cast<bool>(_imageInfo->adjoin));
78 _imageInfo->matte_color=matteColor_;
88 _imageInfo->background_color=color_;
93 return(
Color(_imageInfo->background_color));
98 if (backgroundTexture_.length() == 0)
99 _imageInfo->texture=(
char *) RelinquishMagickMemory(_imageInfo->texture);
106 if (_imageInfo->texture)
107 return(std::string(_imageInfo->texture));
109 return(std::string());
114 _imageInfo->border_color=color_;
115 _drawInfo->border_color=color_;
120 return(
Color(_imageInfo->border_color));
125 _drawInfo->undercolor=boxColor_;
130 return(
Color(_drawInfo->undercolor));
135 _imageInfo->colorspace=colorspace_;
140 return(static_cast<Magick::ColorspaceType>(_imageInfo->colorspace));
145 _imageInfo->compression=compressType_;
150 return(static_cast<Magick::CompressionType>(_imageInfo->compression));
155 _imageInfo->fuzz=fuzz_;
160 return(_imageInfo->fuzz);
166 SetLogEventMask(
"All");
168 SetLogEventMask(
"None");
173 if (IsEventLogging())
181 _imageInfo->density=(
char *) RelinquishMagickMemory(_imageInfo->density);
188 if (_imageInfo->density)
189 return(
Point(_imageInfo->density));
196 _imageInfo->depth=depth_;
201 return(_imageInfo->depth);
206 _imageInfo->endian=endian_;
211 return(_imageInfo->endian);
216 SetImageInfoFile(_imageInfo,file_);
221 return(GetImageInfoFile(_imageInfo));
229 max_length=
sizeof(_imageInfo->filename)-1;
230 fileName_.copy(_imageInfo->filename,max_length);
231 if ((ssize_t) fileName_.length() > max_length)
232 _imageInfo->filename[max_length]=0;
234 _imageInfo->filename[fileName_.length()]=0;
239 return(std::string(_imageInfo->filename));
244 _drawInfo->fill=fillColor_;
245 if (fillColor_ ==
Color())
247 setOption(
"fill",fillColor_);
252 return(_drawInfo->fill);
257 if (_drawInfo->fill_pattern)
258 _drawInfo->fill_pattern=DestroyImageList(_drawInfo->fill_pattern);
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);
369 if (*_imageInfo->magick !=
'\0' )
370 magick_info = GetMagickInfo(_imageInfo->magick,exceptionInfo);
373 if ((magick_info != 0) && (*magick_info->description !=
'\0'))
374 return(std::string( magick_info->description));
376 return(std::string());
381 _imageInfo->interlace=interlace_;
386 return(static_cast<Magick::InterlaceType>(_imageInfo->interlace));
393 _imageInfo->magick[0] =
'\0';
397 FormatLocaleString(_imageInfo->filename,MagickPathExtent,
"%.1024s:",
400 SetImageInfo(_imageInfo,1,exceptionInfo);
402 if ( _imageInfo->magick[0] ==
'\0' )
409 if ( _imageInfo->magick[0] !=
'\0' )
410 return(std::string(_imageInfo->magick));
412 return(std::string());
417 _imageInfo->monochrome=(MagickBooleanType) monochromeFlag_;
422 return(static_cast<bool>(_imageInfo->monochrome));
428 _imageInfo->page=(
char *) RelinquishMagickMemory(_imageInfo->page);
435 if (_imageInfo->page)
443 _imageInfo->quality=quality_;
448 return(_imageInfo->quality);
453 _quantizeInfo->number_colors=colors_;
458 return(_quantizeInfo->number_colors);
463 _quantizeInfo->colorspace=colorSpace_;
468 return(static_cast<Magick::ColorspaceType>(_quantizeInfo->colorspace));
473 _imageInfo->dither=(MagickBooleanType) ditherFlag_;
474 _quantizeInfo->dither_method=ditherFlag_ ? RiemersmaDitherMethod :
480 return(static_cast<bool>(_imageInfo->dither));
485 _quantizeInfo->dither_method=ditherMethod_;
490 return(_quantizeInfo->dither_method);
495 _quantizeInfo->tree_depth=treeDepth_;
500 return(_quantizeInfo->tree_depth);
515 _imageInfo->units=resolutionUnits_;
520 return(_imageInfo->units);
525 if (samplingFactor_.length() == 0)
526 _imageInfo->sampling_factor=(
char *) RelinquishMagickMemory(
527 _imageInfo->sampling_factor);
534 if (_imageInfo->sampling_factor)
535 return(std::string(_imageInfo->sampling_factor));
537 return(std::string());
542 _imageInfo->size=(
char *) RelinquishMagickMemory(_imageInfo->size);
550 if (_imageInfo->size)
558 flag_ ? _drawInfo->stroke_antialias=MagickTrue :
559 _drawInfo->stroke_antialias=MagickFalse;
564 return(_drawInfo->stroke_antialias != 0 ?
true :
false);
569 _drawInfo->stroke=strokeColor_;
570 if (strokeColor_ ==
Color())
572 setOption(
"stroke",strokeColor_);
577 return(_drawInfo->stroke);
582 _drawInfo->dash_pattern=(
double *) RelinquishMagickMemory(
583 _drawInfo->dash_pattern);
590 for (x=0; strokeDashArray_[x]; x++) ;
592 _drawInfo->dash_pattern=
static_cast<double*
>(AcquireMagickMemory((x+1)*
594 if (!_drawInfo->dash_pattern)
596 "Unable to allocate dash-pattern memory");
598 memcpy(_drawInfo->dash_pattern,strokeDashArray_,(x+1)*
sizeof(
double));
599 _drawInfo->dash_pattern[x]=0.0;
605 return(_drawInfo->dash_pattern);
610 _drawInfo->dash_offset=strokeDashOffset_;
615 return(_drawInfo->dash_offset);
620 _drawInfo->linecap=lineCap_;
625 return(_drawInfo->linecap);
630 _drawInfo->linejoin=lineJoin_;
635 return(_drawInfo->linejoin);
640 _drawInfo->miterlimit=miterLimit_;
645 return(_drawInfo->miterlimit);
650 if (_drawInfo->stroke_pattern)
651 _drawInfo->stroke_pattern=DestroyImageList(_drawInfo->stroke_pattern);
656 _drawInfo->stroke_pattern=CloneImage(const_cast<MagickCore::Image*>(
657 strokePattern_),0,0,MagickTrue,exceptionInfo);
664 return(_drawInfo->stroke_pattern);
669 _drawInfo->stroke_width=strokeWidth_;
670 setOption(
"strokewidth",strokeWidth_);
675 return(_drawInfo->stroke_width);
680 _imageInfo->scene=subImage_;
685 return(_imageInfo->scene);
690 _imageInfo->number_scenes=subRange_;
695 return(_imageInfo->number_scenes);
700 _drawInfo->text_antialias=
static_cast<MagickBooleanType
>(
701 flag_ ? MagickTrue : MagickFalse);
706 return(static_cast<bool>(_drawInfo->text_antialias));
711 _drawInfo->direction=direction_;
712 (void) SetImageOption(_imageInfo,
"direction",CommandOptionToMnemonic(
713 MagickDirectionOptions,(ssize_t) direction_));
718 return(_drawInfo->direction);
723 CloneString(&_drawInfo->encoding,encoding_.c_str());
724 (void) SetImageOption(imageInfo(),
"encoding",encoding_.c_str());
729 if (_drawInfo->encoding && *_drawInfo->encoding)
730 return(std::string(_drawInfo->encoding));
732 return(std::string());
737 _drawInfo->gravity=gravity_;
738 (void) SetImageOption(_imageInfo,
"gravity",CommandOptionToMnemonic(
739 MagickGravityOptions,(ssize_t) gravity_));
744 return(_drawInfo->gravity);
749 _drawInfo->interline_spacing=spacing_;
750 setOption(
"interline-spacing",spacing_);
755 return(_drawInfo->interline_spacing);
760 _drawInfo->interword_spacing=spacing_;
761 setOption(
"interword-spacing",spacing_);
766 return(_drawInfo->interword_spacing);
771 _drawInfo->kerning=kerning_;
772 setOption(
"kerning",kerning_);
777 return(_drawInfo->kerning);
782 _drawInfo->undercolor=undercolor_;
783 setOption(
"undercolor",undercolor_);
788 return(_drawInfo->undercolor);
795 current=_drawInfo->affine;
804 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
805 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
806 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
807 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
808 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
809 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
814 _drawInfo->affine.sx=1.0;
815 _drawInfo->affine.rx=0.0;
816 _drawInfo->affine.ry=0.0;
817 _drawInfo->affine.sy=1.0;
818 _drawInfo->affine.tx=0.0;
819 _drawInfo->affine.ty=0.0;
826 current=_drawInfo->affine;
835 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
836 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
837 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
838 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
839 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
840 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
847 current=_drawInfo->affine;
856 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
857 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
858 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
859 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
860 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
861 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
868 current=_drawInfo->affine;
877 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
878 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
879 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
880 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
881 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
882 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
889 current=_drawInfo->affine;
898 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
899 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
900 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
901 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
902 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
903 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
908 _imageInfo->type=type_;
913 return(_imageInfo->type);
918 _imageInfo->verbose=(MagickBooleanType) verboseFlag_;
923 return(static_cast<bool>(_imageInfo->verbose));
928 if (display_.length() == 0)
929 _imageInfo->server_name=(
char *) RelinquishMagickMemory(
930 _imageInfo->server_name);
937 if (_imageInfo->server_name)
938 return(std::string( _imageInfo->server_name));
940 return(std::string());
955 return(_quantizeInfo);
959 const MagickCore::QuantizeInfo* quantizeInfo_,
960 const MagickCore::DrawInfo* drawInfo_)
962 _quantizeInfo((
MagickCore::QuantizeInfo* ) NULL),
966 _imageInfo=CloneImageInfo(imageInfo_);
967 _quantizeInfo=CloneQuantizeInfo(quantizeInfo_);
968 _drawInfo=CloneDrawInfo(imageInfo_,drawInfo_);
971 void Magick::Options::setOption(
const char *name,
const Color &value_)
977 (void) SetImageOption(imageInfo(),name,option.c_str());
980 void Magick::Options::setOption(
const char *name,
const double value_)
983 option[MagickPathExtent];
985 (void) FormatLocaleString(option,MagickPathExtent,
"%.20g",value_);
986 (void) SetImageOption(_imageInfo,name,option);
class MagickPPExport Color
size_t fontWeight(void) const
double strokeDashOffset(void) const
double textKerning(void) const
EndianType endian(void) const
Color borderColor(void) const
#define DegreesToRadians(x)
MagickCore::QuantizeInfo * quantizeInfo(void)
size_t quality(void) const
std::string font(void) const
Geometry page(void) const
bool quantizeDither(void) const
MagickCore::ImageInfo * imageInfo(void)
Point density(void) const
void transformReset(void)
void transformRotation(const double angle_)
double colorFuzz(void) const
DirectionType textDirection() const
size_t subRange(void) const
size_t strokeMiterLimit(void) const
std::string fileName(void) const
Color backgroundColor(void) const
std::string fontFamily(void) const
std::string format(void) const
std::string textEncoding(void) const
void transformScale(const double sx_, const double sy_)
const MagickCore::Image * fillPattern(void) const
Color strokeColor(void) const
class MagickPPExport Geometry
const double * strokeDashArray(void) const
size_t subImage(void) const
Color matteColor(void) const
Color fillColor(void) const
size_t quantizeTreeDepth(void) const
ColorspaceType colorspaceType(void) const
size_t quantizeColors(void) const
FillRule fillRule(void) const
LineCap strokeLineCap(void) const
MagickPPExport void throwExceptionExplicit(const MagickCore::ExceptionType severity_, const char *reason_, const char *description_=(char *) NULL)
std::string magick(void) const
double textInterlineSpacing(void) const
bool strokeAntiAlias(void) const
CompressionType compressType(void) const
ImageType type(void) const
#define ThrowPPException(quiet)
Color textUnderColor(void) const
std::string x11Display(void) const
double textInterwordSpacing(void) const
GravityType textGravity() const
std::string samplingFactor(void) const
DitherMethod quantizeDitherMethod(void) const
std::string backgroundTexture(void) const
const MagickCore::Image * strokePattern(void) const
LineJoin strokeLineJoin(void) const
void transformOrigin(const double tx_, const double ty_)
void transformSkewY(const double skewy_)
void transformSkewX(const double skewx_)
bool monochrome(void) const
MagickCore::DrawInfo * drawInfo(void)
Geometry size(void) const
MagickPPExport void CloneString(char **destination_, const std::string &source_)
class MagickPPExport Point
class MagickPPExport Image
InterlaceType interlaceType(void) const
double strokeWidth(void) const
StyleType fontStyle(void) const
void isValid(bool isValid_)
double fontPointsize(void) const
Color boxColor(void) const
ColorspaceType quantizeColorSpace(void) const
bool textAntiAlias(void) const
ResolutionType resolutionUnits(void) const