1 // This may look like C code, but it is really -*- C++ -*-
3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
4 // Copyright Dirk Lemstra 2013-2014
6 // Implementation of Image
9 #define MAGICKCORE_IMPLEMENTATION 1
10 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
12 #include "Magick++/Include.h"
21 #include "Magick++/Image.h"
22 #include "Magick++/Functions.h"
23 #include "Magick++/Pixels.h"
24 #include "Magick++/Options.h"
25 #include "Magick++/ImageRef.h"
27 #define AbsoluteValue(x) ((x) < 0 ? -(x) : (x))
28 #define MagickPI 3.14159265358979323846264338327950288419716939937510
29 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
31 MagickPPExport const char *Magick::borderGeometryDefault="6x6+0+0";
32 MagickPPExport const char *Magick::frameGeometryDefault="25x25+6+6";
33 MagickPPExport const char *Magick::raiseGeometryDefault="6x6+0+0";
35 MagickPPExport int Magick::operator == (const Magick::Image &left_,
36 const Magick::Image &right_)
38 // If image pixels and signature are the same, then the image is identical
39 return((left_.rows() == right_.rows()) &&
40 (left_.columns() == right_.columns()) &&
41 (left_.signature() == right_.signature()));
44 MagickPPExport int Magick::operator != (const Magick::Image &left_,
45 const Magick::Image &right_)
47 return(!(left_ == right_));
50 MagickPPExport int Magick::operator > (const Magick::Image &left_,
51 const Magick::Image &right_)
53 return(!(left_ < right_) && (left_ != right_));
56 MagickPPExport int Magick::operator < (const Magick::Image &left_,
57 const Magick::Image &right_)
59 // If image pixels are less, then image is smaller
60 return((left_.rows() * left_.columns()) <
61 (right_.rows() * right_.columns()));
64 MagickPPExport int Magick::operator >= (const Magick::Image &left_,
65 const Magick::Image &right_)
67 return((left_ > right_) || (left_ == right_));
70 MagickPPExport int Magick::operator <= (const Magick::Image &left_,
71 const Magick::Image &right_)
73 return((left_ < right_) || ( left_ == right_));
76 Magick::Image::Image(void)
77 : _imgRef(new ImageRef)
81 Magick::Image::Image(const Blob &blob_)
82 : _imgRef(new ImageRef)
86 // Initialize, Allocate and Read images
89 catch(const Warning &/*warning_*/)
91 // FIXME: need a way to report warnings in constructor
93 catch (const Error &/*error_*/)
101 Magick::Image::Image(const Blob &blob_,const Geometry &size_)
102 : _imgRef(new ImageRef)
109 catch(const Warning &/*warning_*/)
111 // FIXME: need a way to report warnings in constructor
113 catch(const Error &/*error_*/)
121 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
123 : _imgRef(new ImageRef)
128 read(blob_,size_,depth_);
130 catch(const Warning &/*warning_*/)
132 // FIXME: need a way to report warnings in constructor
134 catch(const Error &/*error_*/)
142 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
143 const size_t depth_,const std::string &magick_)
144 : _imgRef(new ImageRef)
149 read(blob_,size_,depth_,magick_);
151 catch(const Warning &/*warning_*/)
153 // FIXME: need a way to report warnings in constructor
155 catch(const Error &/*error_*/)
163 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
164 const std::string &magick_)
165 : _imgRef(new ImageRef)
170 read(blob_,size_,magick_);
172 catch(const Warning &/*warning_*/)
174 // FIXME: need a way to report warnings in constructor
176 catch(const Error &/*error_*/)
184 Magick::Image::Image(const Geometry &size_,const Color &color_)
185 : _imgRef(new ImageRef)
187 // xc: prefix specifies an X11 color string
188 std::string imageSpec("xc:");
196 // Initialize, Allocate and Read images
199 catch(const Warning &/*warning_*/)
201 // FIXME: need a way to report warnings in constructor
203 catch(const Error & /*error_*/)
211 Magick::Image::Image(const Image &image_)
212 : _imgRef(image_._imgRef)
217 Magick::Image::Image(const size_t width_,const size_t height_,
218 const std::string &map_,const StorageType type_,const void *pixels_)
219 : _imgRef(new ImageRef)
223 read(width_,height_,map_.c_str(),type_,pixels_);
225 catch(const Warning &/*warning_*/)
227 // FIXME: need a way to report warnings in constructor
229 catch(const Error &/*error_*/)
237 Magick::Image::Image(const std::string &imageSpec_)
238 : _imgRef(new ImageRef)
242 // Initialize, Allocate and Read images
245 catch(const Warning &/*warning_*/)
247 // FIXME: need a way to report warnings in constructor
249 catch(const Error &/*error_*/)
257 Magick::Image::~Image()
259 if (_imgRef->decrease() == 0)
262 _imgRef=(Magick::ImageRef *) NULL;
265 Magick::Image& Magick::Image::operator=(const Magick::Image &image_)
269 image_._imgRef->increase();
270 if (_imgRef->decrease() == 0)
273 // Use new image reference
274 _imgRef=image_._imgRef;
279 void Magick::Image::adjoin(const bool flag_)
282 options()->adjoin(flag_);
285 bool Magick::Image::adjoin(void) const
287 return(constOptions()->adjoin());
290 void Magick::Image::alpha(const bool matteFlag_)
294 // If matte channel is requested, but image doesn't already have a
295 // matte channel, then create an opaque matte channel. Likewise, if
296 // the image already has a matte channel but a matte channel is not
297 // desired, then set the matte channel to opaque.
299 if ((matteFlag_ && !constImage()->alpha_trait) ||
300 (constImage()->alpha_trait && !matteFlag_))
301 SetImageAlpha(image(),OpaqueAlpha,exceptionInfo);
304 image()->alpha_trait=matteFlag_ ? BlendPixelTrait : UndefinedPixelTrait;
307 bool Magick::Image::alpha(void) const
309 if (constImage()->alpha_trait == BlendPixelTrait)
315 void Magick::Image::alphaColor(const Color &alphaColor_)
319 if (alphaColor_.isValid())
321 image()->matte_color=alphaColor_;
322 options()->matteColor(alphaColor_);
326 // Set to default matte color
327 Color tmpColor("#BDBDBD");
328 image()->matte_color=tmpColor;
329 options()->matteColor(tmpColor);
333 Magick::Color Magick::Image::alphaColor(void) const
335 return(Color(constImage()->matte_color));
338 void Magick::Image::antiAlias(const bool flag_)
341 options()->antiAlias(static_cast<size_t>(flag_));
344 bool Magick::Image::antiAlias(void)
346 return(static_cast<bool>(options()->antiAlias()));
349 void Magick::Image::animationDelay(const size_t delay_)
352 image()->delay=delay_;
355 size_t Magick::Image::animationDelay(void) const
357 return(constImage()->delay);
360 void Magick::Image::animationIterations(const size_t iterations_)
363 image()->iterations=iterations_;
366 size_t Magick::Image::animationIterations(void) const
368 return(constImage()->iterations);
371 void Magick::Image::attenuate(const double attenuate_)
374 value[MaxTextExtent];
377 FormatLocaleString(value,MaxTextExtent,"%.20g",attenuate_);
378 (void) SetImageArtifact(image(),"attenuate",value);
381 void Magick::Image::backgroundColor(const Color &backgroundColor_)
385 if (backgroundColor_.isValid())
386 image()->background_color=backgroundColor_;
388 image()->background_color=Color();
390 options()->backgroundColor(backgroundColor_);
393 Magick::Color Magick::Image::backgroundColor(void) const
395 return(constOptions()->backgroundColor());
398 void Magick::Image::backgroundTexture(const std::string &backgroundTexture_)
401 options()->backgroundTexture(backgroundTexture_);
404 std::string Magick::Image::backgroundTexture(void) const
406 return(constOptions()->backgroundTexture());
409 size_t Magick::Image::baseColumns(void) const
411 return(constImage()->magick_columns);
414 std::string Magick::Image::baseFilename(void) const
416 return(std::string(constImage()->magick_filename));
419 size_t Magick::Image::baseRows(void) const
421 return(constImage()->magick_rows);
424 void Magick::Image::blackPointCompensation(const bool flag_)
426 image()->black_point_compensation=(MagickBooleanType) flag_;
429 bool Magick::Image::blackPointCompensation(void) const
431 return(static_cast<bool>(constImage()->black_point_compensation));
434 void Magick::Image::borderColor(const Color &borderColor_)
438 if (borderColor_.isValid())
439 image()->border_color=borderColor_;
441 image()->border_color=Color();
443 options()->borderColor(borderColor_);
446 Magick::Color Magick::Image::borderColor(void) const
448 return(constOptions()->borderColor());
451 Magick::Geometry Magick::Image::boundingBox(void) const
457 bbox=GetImageBoundingBox(constImage(),exceptionInfo);
459 return(Geometry(bbox));
462 void Magick::Image::boxColor(const Color &boxColor_)
465 options()->boxColor(boxColor_);
468 Magick::Color Magick::Image::boxColor(void) const
470 return(constOptions()->boxColor());
473 void Magick::Image::channelDepth(const ChannelType channel_,
478 SetPPChannelMask(channel_);
479 SetImageDepth(image(),depth_,exceptionInfo);
480 RestorePPChannelMask;
484 size_t Magick::Image::channelDepth(const ChannelType channel_)
490 SetPPChannelMask(channel_);
491 channel_depth=GetImageDepth(constImage(),exceptionInfo);
492 RestorePPChannelMask;
494 return(channel_depth);
497 size_t Magick::Image::channels() const
499 return(constImage()->number_channels);
502 void Magick::Image::classType(const ClassType class_)
504 if (classType() == PseudoClass && class_ == DirectClass)
506 // Use SyncImage to synchronize the DirectClass pixels with the
507 // color map and then set to DirectClass type.
510 SyncImage(image(),exceptionInfo);
512 image()->colormap=(PixelInfo *)RelinquishMagickMemory(image()->colormap);
513 image()->storage_class=static_cast<MagickCore::ClassType>(DirectClass);
517 if (classType() == DirectClass && class_ == PseudoClass)
519 // Quantize to create PseudoClass color map
521 quantizeColors(MaxColormapSize);
523 image()->storage_class=static_cast<MagickCore::ClassType>(PseudoClass);
527 Magick::ClassType Magick::Image::classType(void) const
529 return static_cast<Magick::ClassType>(constImage()->storage_class);
532 void Magick::Image::colorFuzz(const double fuzz_)
536 options()->colorFuzz(fuzz_);
539 double Magick::Image::colorFuzz(void) const
541 return(constOptions()->colorFuzz());
544 void Magick::Image::colorMapSize(const size_t entries_)
546 if (entries_ >MaxColormapSize)
547 throwExceptionExplicit(OptionError,
548 "Colormap entries must not exceed MaxColormapSize");
552 (void) AcquireImageColormap(image(),entries_,exceptionInfo);
556 size_t Magick::Image::colorMapSize(void) const
558 if (!constImage()->colormap)
559 throwExceptionExplicit(OptionError,"Image does not contain a colormap");
561 return(constImage()->colors);
564 void Magick::Image::colorSpace(const ColorspaceType colorSpace_)
566 if (image()->colorspace == colorSpace_)
571 TransformImageColorspace(image(),colorSpace_,exceptionInfo);
575 Magick::ColorspaceType Magick::Image::colorSpace(void) const
577 return (constImage()->colorspace);
580 void Magick::Image::colorSpaceType(const ColorspaceType colorSpace_)
584 SetImageColorspace(image(),colorSpace_,exceptionInfo);
586 options()->colorspaceType(colorSpace_);
589 Magick::ColorspaceType Magick::Image::colorSpaceType(void) const
591 return(constOptions()->colorspaceType());
594 size_t Magick::Image::columns(void) const
596 return(constImage()->columns);
599 void Magick::Image::comment(const std::string &comment_)
603 SetImageProperty(image(),"Comment",NULL,exceptionInfo);
604 if (comment_.length() > 0)
605 SetImageProperty(image(),"Comment",comment_.c_str(),exceptionInfo);
609 std::string Magick::Image::comment(void) const
615 value=GetImageProperty(constImage(),"Comment",exceptionInfo);
619 return(std::string(value));
621 return(std::string()); // Intentionally no exception
624 void Magick::Image::compose(const CompositeOperator compose_)
626 image()->compose=compose_;
629 Magick::CompositeOperator Magick::Image::compose(void) const
631 return(constImage()->compose);
634 void Magick::Image::compressType(const CompressionType compressType_)
637 image()->compression=compressType_;
638 options()->compressType(compressType_);
641 Magick::CompressionType Magick::Image::compressType(void) const
643 return(constImage()->compression);
646 void Magick::Image::debug(const bool flag_)
649 options()->debug(flag_);
652 bool Magick::Image::debug(void) const
654 return(constOptions()->debug());
657 void Magick::Image::density(const Point &density_)
660 options()->density(density_);
661 if (density_.isValid())
663 image()->resolution.x=density_.x();
664 if (density_.y() != 0.0)
665 image()->resolution.y=density_.y();
667 image()->resolution.y=density_.x();
672 image()->resolution.x=0.0;
673 image()->resolution.y=0.0;
677 Magick::Point Magick::Image::density(void) const
685 if (constImage()->resolution.x > 0.0)
686 x_resolution=constImage()->resolution.x;
688 if (constImage()->resolution.y > 0.0)
689 y_resolution=constImage()->resolution.y;
691 return(Point(x_resolution,y_resolution));
694 return(constOptions()->density());
697 void Magick::Image::depth(const size_t depth_)
702 if (depth > MAGICKCORE_QUANTUM_DEPTH)
703 depth=MAGICKCORE_QUANTUM_DEPTH;
706 image()->depth=depth;
707 options()->depth(depth);
710 size_t Magick::Image::depth(void) const
712 return(constImage()->depth);
715 std::string Magick::Image::directory(void) const
717 if (constImage()->directory)
718 return(std::string(constImage()->directory));
720 throwExceptionExplicit(CorruptImageWarning,
721 "Image does not contain a directory");
723 return(std::string());
726 void Magick::Image::endian(const Magick::EndianType endian_)
729 options()->endian(endian_);
730 image()->endian=endian_;
733 Magick::EndianType Magick::Image::endian(void) const
735 return(constImage()->endian);
738 void Magick::Image::exifProfile(const Magick::Blob &exifProfile_)
742 if (exifProfile_.data() != 0)
747 exif_profile=AcquireStringInfo(exifProfile_.length());
748 SetStringInfoDatum(exif_profile,(unsigned char *) exifProfile_.data());
750 (void) SetImageProfile(image(),"exif",exif_profile,exceptionInfo);
751 exif_profile=DestroyStringInfo(exif_profile);
756 Magick::Blob Magick::Image::exifProfile(void) const
761 exif_profile=GetImageProfile(constImage(),"exif");
762 if (exif_profile == (StringInfo *) NULL)
764 return(Blob(GetStringInfoDatum(exif_profile),
765 GetStringInfoLength(exif_profile)));
768 void Magick::Image::fileName(const std::string &fileName_)
772 fileName_.copy(image()->filename,sizeof(image()->filename)-1);
773 image()->filename[fileName_.length()]=0; // Null terminate
775 options()->fileName(fileName_);
778 std::string Magick::Image::fileName(void) const
780 return(constOptions()->fileName());
783 MagickCore::MagickSizeType Magick::Image::fileSize(void) const
785 return(GetBlobSize(constImage()));
788 void Magick::Image::fillColor(const Magick::Color &fillColor_)
794 options()->fillColor(fillColor_);
796 artifact("fill",value);
799 Magick::Color Magick::Image::fillColor(void) const
801 return(constOptions()->fillColor());
804 void Magick::Image::fillRule(const Magick::FillRule &fillRule_)
807 options()->fillRule(fillRule_);
810 Magick::FillRule Magick::Image::fillRule(void) const
812 return constOptions()->fillRule();
815 void Magick::Image::fillPattern(const Image &fillPattern_)
818 if (fillPattern_.isValid())
819 options()->fillPattern(fillPattern_.constImage());
821 options()->fillPattern(static_cast<MagickCore::Image*>(NULL));
824 Magick::Image Magick::Image::fillPattern(void) const
826 // FIXME: This is inordinately innefficient
827 const MagickCore::Image
833 tmpTexture=constOptions()->fillPattern();
841 image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
842 texture.replaceImage(image);
848 void Magick::Image::filterType(const Magick::FilterTypes filterType_)
851 image()->filter=filterType_;
854 Magick::FilterTypes Magick::Image::filterType(void) const
856 return(constImage()->filter);
859 void Magick::Image::font(const std::string &font_)
862 options()->font(font_);
865 std::string Magick::Image::font(void) const
867 return(constOptions()->font());
870 void Magick::Image::fontPointsize(const double pointSize_)
873 options()->fontPointsize(pointSize_);
876 double Magick::Image::fontPointsize(void) const
878 return(constOptions()->fontPointsize());
881 std::string Magick::Image::format(void) const
887 magick_info=GetMagickInfo(constImage()->magick,exceptionInfo);
890 if ((magick_info != 0) && (*magick_info->description != '\0'))
891 return(std::string(magick_info->description));
893 throwExceptionExplicit(CorruptImageWarning,"Unrecognized image magick type");
894 return(std::string());
897 std::string Magick::Image::formatExpression(const std::string expression)
907 text=InterpretImageProperties(imageInfo(),image(),expression.c_str(),
909 if (text != (char *) NULL)
911 text_string=std::string(text);
912 text=DestroyString(text);
918 double Magick::Image::gamma(void) const
920 return(constImage()->gamma);
923 Magick::Geometry Magick::Image::geometry(void) const
925 if (constImage()->geometry)
926 return Geometry(constImage()->geometry);
928 throwExceptionExplicit(OptionWarning,"Image does not contain a geometry");
933 void Magick::Image::gifDisposeMethod(
934 const MagickCore::DisposeType disposeMethod_)
937 image()->dispose=disposeMethod_;
940 MagickCore::DisposeType Magick::Image::gifDisposeMethod(void) const
942 return(constImage()->dispose);
945 void Magick::Image::highlightColor(const Color color_)
951 artifact("highlight-color",value);
954 void Magick::Image::iccColorProfile(const Magick::Blob &colorProfile_)
956 profile("icm",colorProfile_);
959 Magick::Blob Magick::Image::iccColorProfile(void) const
964 color_profile=GetImageProfile(constImage(),"icc");
965 if (color_profile == (StringInfo *) NULL)
967 return(Blob(GetStringInfoDatum(color_profile),GetStringInfoLength(
971 void Magick::Image::interlaceType(const Magick::InterlaceType interlace_)
974 image()->interlace=interlace_;
975 options()->interlaceType(interlace_);
978 Magick::InterlaceType Magick::Image::interlaceType(void) const
980 return(constImage()->interlace);
983 void Magick::Image::interpolate(const PixelInterpolateMethod interpolate_)
986 image()->interpolate=interpolate_;
989 Magick::PixelInterpolateMethod Magick::Image::interpolate(void) const
991 return constImage()->interpolate;
994 void Magick::Image::iptcProfile(const Magick::Blob &iptcProfile_)
997 if (iptcProfile_.data() != 0)
1002 iptc_profile=AcquireStringInfo(iptcProfile_.length());
1003 SetStringInfoDatum(iptc_profile,(unsigned char *) iptcProfile_.data());
1005 (void) SetImageProfile(image(),"iptc",iptc_profile,exceptionInfo);
1006 iptc_profile=DestroyStringInfo(iptc_profile);
1011 Magick::Blob Magick::Image::iptcProfile(void) const
1016 iptc_profile=GetImageProfile(constImage(),"iptc");
1017 if (iptc_profile == (StringInfo *) NULL)
1019 return(Blob(GetStringInfoDatum(iptc_profile),GetStringInfoLength(
1023 void Magick::Image::isValid(const bool isValid_)
1028 _imgRef=new ImageRef;
1030 else if (!isValid())
1032 // Construct with single-pixel black image to make
1033 // image valid. This is an obvious hack.
1034 size(Geometry(1,1));
1039 bool Magick::Image::isValid(void) const
1041 return rows() && columns();
1044 void Magick::Image::label(const std::string &label_)
1048 (void) SetImageProperty(image(),"Label",NULL,exceptionInfo);
1049 if (label_.length() > 0)
1050 (void) SetImageProperty(image(),"Label",label_.c_str(),exceptionInfo);
1054 std::string Magick::Image::label(void) const
1060 value=GetImageProperty(constImage(),"Label",exceptionInfo);
1064 return(std::string(value));
1066 return(std::string());
1069 void Magick::Image::lowlightColor(const Color color_)
1075 artifact("lowlight-color",value);
1078 void Magick::Image::mask(const Magick::Image &mask_)
1083 if (mask_.isValid())
1084 SetImageMask(image(),mask_.constImage(),exceptionInfo);
1086 SetImageMask(image(),(MagickCore::Image *) NULL,exceptionInfo);
1090 Magick::Image Magick::Image::mask(void) const
1096 image=GetImageMask(constImage(),exceptionInfo);
1099 if (image == (MagickCore::Image *) NULL)
1100 return(Magick::Image());
1102 return(Magick::Image(image));
1105 void Magick::Image::magick(const std::string &magick_)
1109 magick_.copy(image()->magick,sizeof(image()->magick)-1);
1110 image()->magick[magick_.length()]=0;
1112 options()->magick(magick_);
1115 std::string Magick::Image::magick(void) const
1117 if (*(constImage()->magick) != '\0')
1118 return(std::string(constImage()->magick));
1120 return(constOptions()->magick());
1123 double Magick::Image::meanErrorPerPixel(void) const
1125 return(constImage()->error.mean_error_per_pixel);
1128 void Magick::Image::modulusDepth(const size_t depth_)
1132 SetImageDepth(image(),depth_,exceptionInfo);
1134 options()->depth(depth_);
1137 size_t Magick::Image::modulusDepth(void) const
1143 depth=GetImageDepth(constImage(),exceptionInfo);
1148 void Magick::Image::monochrome(const bool monochromeFlag_)
1151 options()->monochrome(monochromeFlag_);
1154 bool Magick::Image::monochrome(void) const
1156 return(constOptions()->monochrome());
1159 Magick::Geometry Magick::Image::montageGeometry(void) const
1161 if (constImage()->montage)
1162 return Magick::Geometry(constImage()->montage);
1164 throwExceptionExplicit(CorruptImageWarning,
1165 "Image does not contain a montage");
1167 return(Magick::Geometry());
1170 double Magick::Image::normalizedMaxError(void) const
1172 return(constImage()->error.normalized_maximum_error);
1175 double Magick::Image::normalizedMeanError(void) const
1177 return(constImage()->error.normalized_mean_error);
1180 void Magick::Image::orientation(const Magick::OrientationType orientation_)
1183 image()->orientation=orientation_;
1186 Magick::OrientationType Magick::Image::orientation(void) const
1188 return(constImage()->orientation);
1191 void Magick::Image::page(const Magick::Geometry &pageSize_)
1194 options()->page(pageSize_);
1195 image()->page=pageSize_;
1198 Magick::Geometry Magick::Image::page(void) const
1200 return(Geometry(constImage()->page.width,constImage()->page.height,
1201 AbsoluteValue(constImage()->page.x),AbsoluteValue(constImage()->page.y)));
1204 void Magick::Image::quality(const size_t quality_)
1207 image()->quality=quality_;
1208 options()->quality(quality_);
1211 size_t Magick::Image::quality(void) const
1213 return(constImage()->quality);
1216 void Magick::Image::quantizeColors(const size_t colors_)
1219 options()->quantizeColors(colors_);
1222 size_t Magick::Image::quantizeColors(void) const
1224 return(constOptions()->quantizeColors());
1227 void Magick::Image::quantizeColorSpace(
1228 const Magick::ColorspaceType colorSpace_)
1231 options()->quantizeColorSpace(colorSpace_);
1234 Magick::ColorspaceType Magick::Image::quantizeColorSpace(void) const
1236 return(constOptions()->quantizeColorSpace());
1239 void Magick::Image::quantizeDither(const bool ditherFlag_)
1242 options()->quantizeDither(ditherFlag_);
1245 bool Magick::Image::quantizeDither(void) const
1247 return(constOptions()->quantizeDither());
1250 void Magick::Image::quantizeDitherMethod(const DitherMethod ditherMethod_)
1253 options()->quantizeDitherMethod(ditherMethod_);
1256 MagickCore::DitherMethod Magick::Image::quantizeDitherMethod(void) const
1258 return(constOptions()->quantizeDitherMethod());
1261 void Magick::Image::quantizeTreeDepth(const size_t treeDepth_)
1264 options()->quantizeTreeDepth(treeDepth_);
1267 size_t Magick::Image::quantizeTreeDepth() const
1269 return(constOptions()->quantizeTreeDepth());
1272 void Magick::Image::renderingIntent(
1273 const Magick::RenderingIntent renderingIntent_)
1276 image()->rendering_intent=renderingIntent_;
1279 Magick::RenderingIntent Magick::Image::renderingIntent(void) const
1281 return(static_cast<Magick::RenderingIntent>(constImage()->rendering_intent));
1284 void Magick::Image::resolutionUnits(
1285 const Magick::ResolutionType resolutionUnits_)
1288 image()->units=resolutionUnits_;
1289 options()->resolutionUnits(resolutionUnits_);
1292 Magick::ResolutionType Magick::Image::resolutionUnits(void) const
1294 return(static_cast<Magick::ResolutionType>(constImage()->units));
1297 size_t Magick::Image::rows(void) const
1299 return(constImage()->rows);
1302 void Magick::Image::scene(const size_t scene_)
1305 image()->scene=scene_;
1308 size_t Magick::Image::scene(void) const
1310 return(constImage()->scene);
1313 void Magick::Image::size(const Geometry &geometry_)
1316 options()->size(geometry_);
1317 image()->rows=geometry_.height();
1318 image()->columns=geometry_.width();
1321 Magick::Geometry Magick::Image::size(void) const
1323 return(Magick::Geometry(constImage()->columns,constImage()->rows));
1326 void Magick::Image::strokeAntiAlias(const bool flag_)
1329 options()->strokeAntiAlias(flag_);
1332 bool Magick::Image::strokeAntiAlias(void) const
1334 return(constOptions()->strokeAntiAlias());
1337 void Magick::Image::strokeColor(const Magick::Color &strokeColor_)
1343 options()->strokeColor(strokeColor_);
1345 artifact("stroke",value);
1348 Magick::Color Magick::Image::strokeColor(void) const
1350 return(constOptions()->strokeColor());
1353 void Magick::Image::strokeDashArray(const double *strokeDashArray_)
1356 options()->strokeDashArray(strokeDashArray_);
1359 const double* Magick::Image::strokeDashArray(void) const
1361 return(constOptions()->strokeDashArray());
1364 void Magick::Image::strokeDashOffset(const double strokeDashOffset_)
1367 options()->strokeDashOffset(strokeDashOffset_);
1370 double Magick::Image::strokeDashOffset(void) const
1372 return(constOptions()->strokeDashOffset());
1375 void Magick::Image::strokeLineCap(const Magick::LineCap lineCap_)
1378 options()->strokeLineCap(lineCap_);
1381 Magick::LineCap Magick::Image::strokeLineCap(void) const
1383 return(constOptions()->strokeLineCap());
1386 void Magick::Image::strokeLineJoin(const Magick::LineJoin lineJoin_)
1389 options()->strokeLineJoin(lineJoin_);
1392 Magick::LineJoin Magick::Image::strokeLineJoin(void) const
1394 return(constOptions()->strokeLineJoin());
1397 void Magick::Image::strokeMiterLimit(const size_t strokeMiterLimit_)
1400 options()->strokeMiterLimit(strokeMiterLimit_);
1403 size_t Magick::Image::strokeMiterLimit(void) const
1405 return(constOptions()->strokeMiterLimit());
1408 void Magick::Image::strokePattern(const Image &strokePattern_)
1411 if(strokePattern_.isValid())
1412 options()->strokePattern(strokePattern_.constImage());
1414 options()->strokePattern(static_cast<MagickCore::Image*>(NULL));
1417 Magick::Image Magick::Image::strokePattern(void) const
1419 // FIXME: This is inordinately innefficient
1420 const MagickCore::Image
1426 tmpTexture=constOptions()->strokePattern();
1434 image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
1435 texture.replaceImage(image);
1441 void Magick::Image::strokeWidth(const double strokeWidth_)
1444 value[MaxTextExtent];
1447 options()->strokeWidth(strokeWidth_);
1448 FormatLocaleString(value,MaxTextExtent,"%.20g",strokeWidth_);
1449 (void) SetImageArtifact(image(),"strokewidth",value);
1452 double Magick::Image::strokeWidth(void) const
1454 return(constOptions()->strokeWidth());
1457 void Magick::Image::subImage(const size_t subImage_)
1460 options()->subImage(subImage_);
1463 size_t Magick::Image::subImage(void) const
1465 return(constOptions()->subImage());
1468 void Magick::Image::subRange(const size_t subRange_)
1471 options()->subRange(subRange_);
1474 size_t Magick::Image::subRange(void) const
1476 return(constOptions()->subRange());
1479 void Magick::Image::textDirection(DirectionType direction_)
1482 options()->textDirection(direction_);
1485 Magick::DirectionType Magick::Image::textDirection(void) const
1487 return(constOptions()->textDirection());
1490 void Magick::Image::textEncoding(const std::string &encoding_)
1493 options()->textEncoding(encoding_);
1496 std::string Magick::Image::textEncoding(void) const
1498 return(constOptions()->textEncoding());
1501 void Magick::Image::textGravity(GravityType gravity_)
1504 options()->textGravity(gravity_);
1507 Magick::GravityType Magick::Image::textGravity(void) const
1509 return(constOptions()->textGravity());
1512 void Magick::Image::textInterlineSpacing(double spacing_)
1515 options()->textInterlineSpacing(spacing_);
1518 double Magick::Image::textInterlineSpacing(void) const
1520 return(constOptions()->textInterlineSpacing());
1523 void Magick::Image::textInterwordSpacing(double spacing_)
1526 options()->textInterwordSpacing(spacing_);
1529 double Magick::Image::textInterwordSpacing(void) const
1531 return(constOptions()->textInterwordSpacing());
1534 void Magick::Image::textKerning(double kerning_)
1537 options()->textKerning(kerning_);
1540 double Magick::Image::textKerning(void) const
1542 return(constOptions()->textKerning());
1545 size_t Magick::Image::totalColors(void) const
1551 colors=GetNumberColors(constImage(),0,exceptionInfo);
1556 void Magick::Image::transformRotation(const double angle_)
1559 options()->transformRotation(angle_);
1562 void Magick::Image::transformSkewX(const double skewx_)
1565 options()->transformSkewX(skewx_);
1568 void Magick::Image::transformSkewY(const double skewy_)
1571 options()->transformSkewY(skewy_);
1574 Magick::ImageType Magick::Image::type(void) const
1576 if (constOptions()->type() != UndefinedType)
1577 return(constOptions()->type());
1578 else if (constImage()->type != UndefinedType)
1579 return(constImage()->type);
1581 return(determineType());
1584 void Magick::Image::type(const Magick::ImageType type_)
1587 options()->type(type_);
1589 SetImageType(image(),type_,exceptionInfo);
1593 void Magick::Image::verbose(const bool verboseFlag_)
1596 options()->verbose(verboseFlag_);
1599 bool Magick::Image::verbose(void) const
1601 return(constOptions()->verbose());
1604 void Magick::Image::view(const std::string &view_)
1607 options()->view(view_);
1610 std::string Magick::Image::view(void) const
1612 return(constOptions()->view());
1615 void Magick::Image::virtualPixelMethod(
1616 const VirtualPixelMethod virtualPixelMethod_)
1620 SetImageVirtualPixelMethod(image(),virtualPixelMethod_,exceptionInfo);
1624 Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod(void) const
1626 return(GetImageVirtualPixelMethod(constImage()));
1629 void Magick::Image::x11Display(const std::string &display_)
1632 options()->x11Display(display_);
1635 std::string Magick::Image::x11Display(void) const
1637 return(constOptions()->x11Display());
1640 double Magick::Image::xResolution(void) const
1642 return(constImage()->resolution.x);
1645 double Magick::Image::yResolution(void) const
1647 return(constImage()->resolution.y);
1650 void Magick::Image::adaptiveBlur(const double radius_,const double sigma_)
1656 newImage=AdaptiveBlurImage(constImage(),radius_,sigma_,exceptionInfo);
1657 replaceImage(newImage);
1661 void Magick::Image::adaptiveResize(const Geometry &geometry_)
1674 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
1678 newImage=AdaptiveResizeImage(constImage(),width,height,exceptionInfo);
1679 replaceImage(newImage);
1683 void Magick::Image::adaptiveSharpen(const double radius_,const double sigma_)
1689 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1690 replaceImage(newImage);
1694 void Magick::Image::adaptiveSharpenChannel(const ChannelType channel_,
1695 const double radius_,const double sigma_ )
1701 SetPPChannelMask(channel_);
1702 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1703 RestorePPChannelMask;
1704 replaceImage(newImage);
1708 void Magick::Image::adaptiveThreshold(const size_t width_,const size_t height_,
1716 newImage=AdaptiveThresholdImage(constImage(),width_,height_,bias_,
1718 replaceImage(newImage);
1722 void Magick::Image::addNoise(const NoiseType noiseType_)
1728 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1729 replaceImage(newImage);
1733 void Magick::Image::addNoiseChannel(const ChannelType channel_,
1734 const NoiseType noiseType_)
1740 SetPPChannelMask(channel_);
1741 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1742 RestorePPChannelMask;
1743 replaceImage(newImage);
1747 void Magick::Image::affineTransform(const DrawableAffine &affine_)
1755 _affine.sx=affine_.sx();
1756 _affine.sy=affine_.sy();
1757 _affine.rx=affine_.rx();
1758 _affine.ry=affine_.ry();
1759 _affine.tx=affine_.tx();
1760 _affine.ty=affine_.ty();
1763 newImage=AffineTransformImage(constImage(),&_affine,exceptionInfo);
1764 replaceImage(newImage);
1768 void Magick::Image::alpha(const unsigned int alpha_)
1772 SetImageAlpha(image(),alpha_,exceptionInfo);
1776 void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
1780 SetImageAlphaChannel(image(),alphaOption_,exceptionInfo);
1784 void Magick::Image::annotate(const std::string &text_,
1785 const Geometry &location_)
1787 annotate(text_,location_,NorthWestGravity,0.0);
1790 void Magick::Image::annotate(const std::string &text_,
1791 const Geometry &boundingArea_,const GravityType gravity_)
1793 annotate(text_,boundingArea_,gravity_,0.0);
1796 void Magick::Image::annotate(const std::string &text_,
1797 const Geometry &boundingArea_,const GravityType gravity_,
1798 const double degrees_)
1804 boundingArea[MaxTextExtent];
1811 drawInfo=options()->drawInfo();
1812 drawInfo->text=const_cast<char *>(text_.c_str());
1813 drawInfo->geometry=0;
1815 if (boundingArea_.isValid())
1817 if (boundingArea_.width() == 0 || boundingArea_.height() == 0)
1819 FormatLocaleString(boundingArea,MaxTextExtent,"%+.20g%+.20g",
1820 (double) boundingArea_.xOff(),(double) boundingArea_.yOff());
1824 (void) CopyMagickString(boundingArea,string(boundingArea_).c_str(),
1827 drawInfo->geometry=boundingArea;
1830 drawInfo->gravity=gravity_;
1832 oaffine=drawInfo->affine;
1833 if (degrees_ != 0.0)
1846 current=drawInfo->affine;
1847 affine.sx=cos(DegreesToRadians(fmod(degrees_,360.0)));
1848 affine.rx=sin(DegreesToRadians(fmod(degrees_,360.0)));
1849 affine.ry=(-sin(DegreesToRadians(fmod(degrees_,360.0))));
1850 affine.sy=cos(DegreesToRadians(fmod(degrees_,360.0)));
1852 drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
1853 drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
1854 drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
1855 drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
1856 drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty
1861 AnnotateImage(image(),drawInfo,exceptionInfo);
1863 // Restore original values
1864 drawInfo->affine=oaffine;
1866 drawInfo->geometry=0;
1871 void Magick::Image::annotate(const std::string &text_,
1872 const GravityType gravity_)
1879 drawInfo=options()->drawInfo();
1880 drawInfo->text=const_cast<char *>(text_.c_str());
1881 drawInfo->gravity=gravity_;
1884 AnnotateImage(image(),drawInfo,exceptionInfo);
1886 drawInfo->gravity=NorthWestGravity;
1892 void Magick::Image::artifact(const std::string &name_,const std::string &value_)
1895 (void) SetImageArtifact(image(),name_.c_str(),value_.c_str());
1898 std::string Magick::Image::artifact(const std::string &name_)
1903 value=GetImageArtifact(constImage(),name_.c_str());
1905 return(std::string(value));
1906 return(std::string());
1909 void Magick::Image::attribute(const std::string name_,const std::string value_)
1913 SetImageProperty(image(),name_.c_str(),value_.c_str(),exceptionInfo);
1917 std::string Magick::Image::attribute(const std::string name_)
1923 value=GetImageProperty(constImage(),name_.c_str(),exceptionInfo);
1927 return(std::string(value));
1929 return(std::string()); // Intentionally no exception
1932 void Magick::Image::autoGamma(void)
1936 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1937 (void) AutoGammaImage(image(),exceptionInfo);
1941 void Magick::Image::autoGammaChannel(const ChannelType channel_)
1945 SetPPChannelMask(channel_);
1946 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1947 (void) AutoGammaImage(image(),exceptionInfo);
1948 RestorePPChannelMask;
1952 void Magick::Image::autoLevel(void)
1956 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1957 (void) AutoLevelImage(image(),exceptionInfo);
1961 void Magick::Image::autoLevelChannel(const ChannelType channel_)
1965 SetPPChannelMask(channel_);
1966 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1967 (void) AutoLevelImage(image(),exceptionInfo);
1968 RestorePPChannelMask;
1972 void Magick::Image::autoOrient(void)
1977 if (image()->orientation == UndefinedOrientation ||
1978 image()->orientation == TopLeftOrientation)
1982 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1983 newImage=AutoOrientImage(constImage(),image()->orientation,exceptionInfo);
1984 replaceImage(newImage);
1988 void Magick::Image::blackThreshold(const std::string &threshold_)
1992 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
1996 void Magick::Image::blackThresholdChannel(const ChannelType channel_,
1997 const std::string &threshold_)
2001 SetPPChannelMask(channel_);
2002 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2003 RestorePPChannelMask;
2007 void Magick::Image::blueShift(const double factor_)
2013 newImage=BlueShiftImage(constImage(),factor_,exceptionInfo);
2014 replaceImage(newImage);
2018 void Magick::Image::blur(const double radius_,const double sigma_)
2024 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2025 replaceImage(newImage);
2029 void Magick::Image::blurChannel(const ChannelType channel_,
2030 const double radius_,const double sigma_)
2036 SetPPChannelMask(channel_);
2037 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2038 RestorePPChannelMask;
2039 replaceImage(newImage);
2043 void Magick::Image::border(const Geometry &geometry_)
2049 borderInfo=geometry_;
2052 newImage=BorderImage(constImage(),&borderInfo,image()->compose,
2054 replaceImage(newImage);
2058 void Magick::Image::brightnessContrast(const double brightness_,
2059 const double contrast_)
2063 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2067 void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
2068 const double brightness_,const double contrast_)
2072 SetPPChannelMask(channel_);
2073 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2074 RestorePPChannelMask;
2078 void Magick::Image::cannyEdge(const double radius_,const double sigma_,
2079 const double lowerPercent_,const double upperPercent_)
2086 newImage=CannyEdgeImage(constImage(),radius_,sigma_,lowerPercent_,
2087 upperPercent_,exceptionInfo);
2088 replaceImage(newImage);
2092 void Magick::Image::channel(const ChannelType channel_)
2098 newImage=SeparateImage(image(),channel_,exceptionInfo);
2099 replaceImage(newImage);
2103 void Magick::Image::charcoal(const double radius_,const double sigma_)
2109 newImage=CharcoalImage(image(),radius_,sigma_,exceptionInfo);
2110 replaceImage(newImage);
2114 void Magick::Image::chop(const Geometry &geometry_)
2123 newImage=ChopImage(image(),&chopInfo,exceptionInfo);
2124 replaceImage(newImage);
2128 void Magick::Image::chromaBluePrimary(const double x_,const double y_)
2131 image()->chromaticity.blue_primary.x=x_;
2132 image()->chromaticity.blue_primary.y=y_;
2135 void Magick::Image::chromaBluePrimary(double *x_,double *y_) const
2137 *x_=constImage()->chromaticity.blue_primary.x;
2138 *y_=constImage()->chromaticity.blue_primary.y;
2141 void Magick::Image::chromaGreenPrimary(const double x_,const double y_)
2144 image()->chromaticity.green_primary.x=x_;
2145 image()->chromaticity.green_primary.y=y_;
2148 void Magick::Image::chromaGreenPrimary(double *x_,double *y_) const
2150 *x_=constImage()->chromaticity.green_primary.x;
2151 *y_=constImage()->chromaticity.green_primary.y;
2154 void Magick::Image::chromaRedPrimary(const double x_,const double y_)
2157 image()->chromaticity.red_primary.x=x_;
2158 image()->chromaticity.red_primary.y=y_;
2161 void Magick::Image::chromaRedPrimary(double *x_,double *y_) const
2163 *x_=constImage()->chromaticity.red_primary.x;
2164 *y_=constImage()->chromaticity.red_primary.y;
2167 void Magick::Image::chromaWhitePoint(const double x_,const double y_)
2170 image()->chromaticity.white_point.x=x_;
2171 image()->chromaticity.white_point.y=y_;
2174 void Magick::Image::chromaWhitePoint(double *x_,double *y_) const
2176 *x_=constImage()->chromaticity.white_point.x;
2177 *y_=constImage()->chromaticity.white_point.y;
2180 void Magick::Image::cdl(const std::string &cdl_)
2184 (void) ColorDecisionListImage(image(),cdl_.c_str(),exceptionInfo);
2188 void Magick::Image::clamp(void)
2192 ClampImage(image(),exceptionInfo);
2196 void Magick::Image::clampChannel(const ChannelType channel_)
2200 SetPPChannelMask(channel_);
2201 ClampImage(image(),exceptionInfo);
2202 RestorePPChannelMask;
2206 void Magick::Image::clip(void)
2210 ClipImage(image(),exceptionInfo);
2214 void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
2218 ClipImagePath(image(),pathname_.c_str(),(MagickBooleanType) inside_,
2223 void Magick::Image::clut(const Image &clutImage_,
2224 const PixelInterpolateMethod method)
2228 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2232 void Magick::Image::clutChannel(const ChannelType channel_,
2233 const Image &clutImage_,const PixelInterpolateMethod method)
2237 SetPPChannelMask(channel_);
2238 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2239 RestorePPChannelMask;
2243 void Magick::Image::colorize(const unsigned int alpha_,const Color &penColor_)
2245 colorize(alpha_,alpha_,alpha_,penColor_);
2248 void Magick::Image::colorize(const unsigned int alphaRed_,
2249 const unsigned int alphaGreen_,const unsigned int alphaBlue_,
2250 const Color &penColor_)
2253 blend[MaxTextExtent];
2261 if (!penColor_.isValid())
2262 throwExceptionExplicit(OptionError,"Pen color argument is invalid");
2264 FormatLocaleString(blend,MaxTextExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
2267 target=static_cast<PixelInfo>(penColor_);
2269 newImage=ColorizeImage(image(),blend,&target,exceptionInfo);
2270 replaceImage(newImage);
2274 void Magick::Image::colorMap(const size_t index_,const Color &color_)
2281 if (index_ > (MaxColormapSize-1))
2282 throwExceptionExplicit(OptionError,
2283 "Colormap index must be less than MaxColormapSize");
2285 if (!color_.isValid())
2286 throwExceptionExplicit(OptionError,"Color argument is invalid");
2290 // Ensure that colormap size is large enough
2291 if (colorMapSize() < (index_+1))
2292 colorMapSize(index_+1);
2294 // Set color at index in colormap
2295 (imageptr->colormap)[index_]=color_;
2298 Magick::Color Magick::Image::colorMap(const size_t index_) const
2300 if (!constImage()->colormap)
2302 throwExceptionExplicit(OptionError,"Image does not contain a colormap");
2306 if (index_ > constImage()->colors-1)
2307 throwExceptionExplicit(OptionError,"Index out of range");
2309 return(Magick::Color((constImage()->colormap)[index_]));
2312 void Magick::Image::colorMatrix(const size_t order_,
2313 const double *color_matrix_)
2319 kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2320 if (kernel_info != (KernelInfo *) NULL)
2322 kernel_info->width=order_;
2323 kernel_info->height=order_;
2324 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2325 order_*sizeof(*kernel_info->values));
2326 if (kernel_info->values != (MagickRealType *) NULL)
2331 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2332 kernel_info->values[i]=color_matrix_[i];
2333 newImage=ColorMatrixImage(image(),kernel_info,exceptionInfo);
2334 replaceImage(newImage);
2336 kernel_info=DestroyKernelInfo(kernel_info);
2341 bool Magick::Image::compare(const Image &reference_)
2352 status=static_cast<bool>(IsImagesEqual(image(),ref.image(),exceptionInfo));
2357 double Magick::Image::compare(const Image &reference_,const MetricType metric_)
2363 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2369 double Magick::Image::compareChannel(const ChannelType channel_,
2370 const Image &reference_,const MetricType metric_)
2376 SetPPChannelMask(channel_);
2377 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2379 RestorePPChannelMask;
2384 Magick::Image Magick::Image::compare(const Image &reference_,
2385 const MetricType metric_,double *distortion)
2391 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2394 if (newImage == (MagickCore::Image *) NULL)
2395 return(Magick::Image());
2397 return(Magick::Image(newImage));
2400 Magick::Image Magick::Image::compareChannel(const ChannelType channel_,
2401 const Image &reference_,const MetricType metric_,double *distortion)
2407 SetPPChannelMask(channel_);
2408 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2410 RestorePPChannelMask;
2412 if (newImage == (MagickCore::Image *) NULL)
2413 return(Magick::Image());
2415 return(Magick::Image(newImage));
2418 void Magick::Image::composite(const Image &compositeImage_,
2419 const Geometry &offset_,const CompositeOperator compose_)
2429 ParseMetaGeometry(static_cast<std::string>(offset_).c_str(),&x,&y,&width,
2434 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2439 void Magick::Image::composite(const Image &compositeImage_,
2440 const GravityType gravity_,const CompositeOperator compose_)
2446 SetGeometry(compositeImage_.constImage(),&geometry);
2447 GravityAdjustGeometry(columns(),rows(),gravity_,&geometry);
2450 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2451 geometry.x,geometry.y,exceptionInfo);
2455 void Magick::Image::composite(const Image &compositeImage_,
2456 const ssize_t xOffset_,const ssize_t yOffset_,
2457 const CompositeOperator compose_)
2459 // Image supplied as compositeImage is composited with current image and
2460 // results in updating current image.
2463 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2464 xOffset_,yOffset_,exceptionInfo);
2468 void Magick::Image::connectedComponents(const size_t connectivity_)
2474 newImage=ConnectedComponentsImage(constImage(),connectivity_,exceptionInfo);
2475 replaceImage(newImage);
2479 void Magick::Image::contrast(const size_t sharpen_)
2483 ContrastImage(image(),(MagickBooleanType) sharpen_,exceptionInfo);
2487 void Magick::Image::contrastStretch(const double blackPoint_,
2488 const double whitePoint_)
2492 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2496 void Magick::Image::contrastStretchChannel(const ChannelType channel_,
2497 const double blackPoint_,const double whitePoint_)
2501 SetPPChannelMask(channel_);
2502 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2503 RestorePPChannelMask;
2507 void Magick::Image::convolve(const size_t order_,const double *kernel_)
2513 kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2514 kernel_info->width=order_;
2515 kernel_info->height=order_;
2516 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2517 order_*sizeof(*kernel_info->values));
2518 if (kernel_info->values != (MagickRealType *) NULL)
2523 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2524 kernel_info->values[i]=kernel_[i];
2525 newImage=ConvolveImage(image(),kernel_info,exceptionInfo);
2526 replaceImage(newImage);
2528 kernel_info=DestroyKernelInfo(kernel_info);
2532 void Magick::Image::crop(const Geometry &geometry_)
2541 newImage=CropImage(constImage(),&cropInfo,exceptionInfo);
2542 replaceImage(newImage);
2546 void Magick::Image::cycleColormap(const ssize_t amount_)
2550 CycleColormapImage(image(),amount_,exceptionInfo);
2554 void Magick::Image::decipher(const std::string &passphrase_)
2558 DecipherImage(image(),passphrase_.c_str(),exceptionInfo);
2562 void Magick::Image::defineSet(const std::string &magick_,
2563 const std::string &key_,bool flag_)
2569 definition=magick_ + ":" + key_;
2571 (void) SetImageOption(imageInfo(),definition.c_str(),"");
2573 DeleteImageOption(imageInfo(),definition.c_str());
2576 bool Magick::Image::defineSet(const std::string &magick_,
2577 const std::string &key_ ) const
2585 key=magick_ + ":" + key_;
2586 option=GetImageOption(constImageInfo(),key.c_str());
2592 void Magick::Image::defineValue(const std::string &magick_,
2593 const std::string &key_,const std::string &value_)
2600 format=magick_ + ":" + key_;
2602 (void) SetImageOption(imageInfo(),format.c_str(),option.c_str());
2605 std::string Magick::Image::defineValue(const std::string &magick_,
2606 const std::string &key_) const
2614 definition=magick_ + ":" + key_;
2615 option=GetImageOption(constImageInfo(),definition.c_str());
2617 return(std::string(option));
2618 return(std::string());
2621 void Magick::Image::deskew(const double threshold_)
2627 newImage=DeskewImage(constImage(),threshold_,exceptionInfo);
2628 replaceImage(newImage);
2632 void Magick::Image::despeckle(void)
2638 newImage=DespeckleImage(constImage(),exceptionInfo);
2639 replaceImage(newImage);
2643 Magick::ImageType Magick::Image::determineType(void) const
2649 image_type=GetImageType(constImage(),exceptionInfo);
2654 void Magick::Image::display(void)
2657 DisplayImages(imageInfo(),image(),exceptionInfo);
2661 void Magick::Image::distort(const DistortImageMethod method_,
2662 const size_t numberArguments_,const double *arguments_,const bool bestfit_)
2668 newImage=DistortImage(constImage(), method_,numberArguments_,arguments_,
2669 bestfit_ == true ? MagickTrue : MagickFalse,exceptionInfo);
2670 replaceImage(newImage);
2674 void Magick::Image::draw(const Magick::Drawable &drawable_)
2681 wand=DrawAllocateWand(options()->drawInfo(),image());
2685 drawable_.operator()(wand);
2689 ClonePPDrawException(wand);
2690 wand=DestroyDrawingWand(wand);
2691 ThrowPPDrawException;
2695 void Magick::Image::draw(const std::vector<Magick::Drawable> &drawable_)
2702 wand=DrawAllocateWand(options()->drawInfo(),image());
2706 for (std::vector<Magick::Drawable>::const_iterator p = drawable_.begin();
2707 p != drawable_.end(); p++ )
2709 p->operator()(wand);
2710 if (DrawGetExceptionType(wand) != UndefinedException)
2714 if (DrawGetExceptionType(wand) == UndefinedException)
2717 ClonePPDrawException(wand);
2718 wand=DestroyDrawingWand(wand);
2719 ThrowPPDrawException;
2723 void Magick::Image::edge(const double radius_)
2729 newImage=EdgeImage(constImage(),radius_,exceptionInfo);
2730 replaceImage(newImage);
2734 void Magick::Image::emboss(const double radius_,const double sigma_)
2740 newImage=EmbossImage(constImage(),radius_,sigma_,exceptionInfo);
2741 replaceImage(newImage);
2745 void Magick::Image::encipher(const std::string &passphrase_)
2749 EncipherImage(image(),passphrase_.c_str(),exceptionInfo);
2753 void Magick::Image::enhance(void)
2759 newImage=EnhanceImage(constImage(),exceptionInfo);
2760 replaceImage(newImage);
2764 void Magick::Image::equalize(void)
2768 EqualizeImage(image(),exceptionInfo);
2772 void Magick::Image::erase(void)
2776 (void) SetImageBackgroundColor(image(),exceptionInfo);
2780 void Magick::Image::extent(const Geometry &geometry_ )
2786 extentInfo=geometry_;
2789 extentInfo.x=geometry_.xOff();
2790 extentInfo.y=geometry_.yOff();
2792 newImage=ExtentImage(image(),&extentInfo,exceptionInfo);
2793 replaceImage(newImage);
2797 void Magick::Image::extent(const Geometry &geometry_,
2798 const Color &backgroundColor_)
2800 backgroundColor(backgroundColor_);
2804 void Magick::Image::extent(const Geometry &geometry_,
2805 const Color &backgroundColor_,const GravityType gravity_)
2807 backgroundColor(backgroundColor_);
2808 extent(geometry_,gravity_);
2811 void Magick::Image::extent(const Geometry &geometry_,
2812 const GravityType gravity_)
2817 SetGeometry(image(),&geometry);
2818 geometry.width=geometry_.width();
2819 geometry.height=geometry_.height();
2820 GravityAdjustGeometry(image()->columns,image()->rows,gravity_,&geometry);
2824 void Magick::Image::flip(void)
2830 newImage=FlipImage(constImage(),exceptionInfo);
2831 replaceImage(newImage);
2835 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2836 const unsigned int alpha_,const bool invert_)
2843 target=static_cast<PixelInfo>(pixelColor(x_,y_));
2844 target.alpha=alpha_;
2846 SetPPChannelMask(AlphaChannel);
2847 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2848 (MagickBooleanType)invert_,exceptionInfo);
2849 RestorePPChannelMask;
2853 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2854 const unsigned int alpha_,const Color &target_,const bool invert_)
2861 target=static_cast<PixelInfo>(target_);
2862 target.alpha=alpha_;
2864 SetPPChannelMask(AlphaChannel);
2865 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2866 (MagickBooleanType)invert_,exceptionInfo);
2867 RestorePPChannelMask;
2871 void Magick::Image::floodFillColor(const Geometry &point_,
2872 const Magick::Color &fillColor_,const bool invert_)
2874 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,invert_);
2877 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2878 const Magick::Color &fillColor_,const bool invert_)
2885 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2886 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2889 void Magick::Image::floodFillColor(const Geometry &point_,
2890 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2893 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,borderColor_,invert_);
2896 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2897 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2905 pixel=static_cast<PixelInfo>(borderColor_);
2906 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2909 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2910 const Magick::Image &texture_,const bool invert_)
2912 floodFillTexture(point_.xOff(),point_.yOff(),texture_,invert_);
2915 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2916 const Magick::Image &texture_,const bool invert_)
2923 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2924 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
2927 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2928 const Magick::Image &texture_,const Magick::Color &borderColor_,
2931 floodFillTexture(point_.xOff(),point_.yOff(),texture_,borderColor_,invert_);
2934 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2935 const Magick::Image &texture_,const Magick::Color &borderColor_,
2943 pixel=static_cast<PixelInfo>(borderColor_);
2944 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
2947 void Magick::Image::flop(void)
2953 newImage=FlopImage(constImage(),exceptionInfo);
2954 replaceImage(newImage);
2958 void Magick::Image::fontTypeMetrics(const std::string &text_,
2959 TypeMetric *metrics)
2964 drawInfo=options()->drawInfo();
2965 drawInfo->text=const_cast<char *>(text_.c_str());
2967 GetTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
2972 void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
2973 TypeMetric *metrics)
2978 drawInfo=options()->drawInfo();
2979 drawInfo->text=const_cast<char *>(text_.c_str());
2981 GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
2986 void Magick::Image::frame(const Geometry &geometry_)
2994 info.x=static_cast<ssize_t>(geometry_.width());
2995 info.y=static_cast<ssize_t>(geometry_.height());
2996 info.width=columns() + (static_cast<size_t>(info.x) << 1);
2997 info.height=rows() + (static_cast<size_t>(info.y) << 1);
2998 info.outer_bevel=geometry_.xOff();
2999 info.inner_bevel=geometry_.yOff();
3002 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3003 replaceImage(newImage);
3007 void Magick::Image::frame(const size_t width_,const size_t height_,
3008 const ssize_t outerBevel_,const ssize_t innerBevel_)
3016 info.x=static_cast<ssize_t>(width_);
3017 info.y=static_cast<ssize_t>(height_);
3018 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3019 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3020 info.outer_bevel=static_cast<ssize_t>(outerBevel_);
3021 info.inner_bevel=static_cast<ssize_t>(innerBevel_);
3024 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3025 replaceImage(newImage);
3029 void Magick::Image::fx(const std::string expression_)
3035 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3036 replaceImage(newImage);
3040 void Magick::Image::fx(const std::string expression_,
3041 const Magick::ChannelType channel_)
3047 SetPPChannelMask(channel_);
3048 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3049 RestorePPChannelMask;
3050 replaceImage(newImage);
3054 void Magick::Image::gamma(const double gamma_)
3058 GammaImage(image(),gamma_,exceptionInfo);
3062 void Magick::Image::gamma(const double gammaRed_,const double gammaGreen_,
3063 const double gammaBlue_)
3066 gamma[MaxTextExtent + 1];
3068 FormatLocaleString(gamma,MaxTextExtent,"%3.6f/%3.6f/%3.6f/",gammaRed_,
3069 gammaGreen_,gammaBlue_);
3073 GammaImage(image(),atof(gamma),exceptionInfo);
3077 void Magick::Image::gaussianBlur(const double width_,const double sigma_)
3083 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3084 replaceImage(newImage);
3088 void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
3089 const double width_,const double sigma_)
3095 SetPPChannelMask(channel_);
3096 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3097 RestorePPChannelMask;
3098 replaceImage(newImage);
3102 const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
3103 const ssize_t y_,const size_t columns_,const size_t rows_) const
3109 p=(*GetVirtualPixels)(constImage(),x_, y_,columns_, rows_,exceptionInfo);
3114 const void *Magick::Image::getConstMetacontent(void) const
3119 result=GetVirtualMetacontent(constImage());
3122 throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
3127 void *Magick::Image::getMetacontent(void )
3132 result=GetAuthenticMetacontent(image());
3135 throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
3140 Magick::Quantum *Magick::Image::getPixels(const ssize_t x_,const ssize_t y_,
3141 const size_t columns_,const size_t rows_)
3148 result=(*GetAuthenticPixels)(image(),x_, y_,columns_,rows_,exceptionInfo);
3154 void Magick::Image::grayscale(const PixelIntensityMethod method_)
3158 (void) GrayscaleImage(image(),method_,exceptionInfo);
3162 void Magick::Image::haldClut(const Image &clutImage_)
3166 (void) HaldClutImage(image(),clutImage_.constImage(),exceptionInfo);
3170 void Magick::Image::houghLine(const size_t width_,const size_t height_,
3171 const size_t threshold_)
3177 newImage=HoughLineImage(constImage(),width_,height_,threshold_,
3179 replaceImage(newImage);
3183 void Magick::Image::implode(const double factor_)
3189 newImage=ImplodeImage(constImage(),factor_,image()->interpolate,
3191 replaceImage(newImage);
3195 void Magick::Image::inverseFourierTransform(const Image &phase_)
3197 inverseFourierTransform(phase_,true);
3200 void Magick::Image::inverseFourierTransform(const Image &phase_,
3201 const bool magnitude_)
3207 newImage=InverseFourierTransformImage(constImage(),phase_.constImage(),
3208 magnitude_ == true ? MagickTrue : MagickFalse,exceptionInfo);
3209 replaceImage(newImage);
3213 void Magick::Image::kuwahara(const double radius_,const double sigma_)
3219 newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3220 replaceImage(newImage);
3224 void Magick::Image::kuwaharaChannel(const ChannelType channel_,
3225 const double radius_,const double sigma_)
3231 SetPPChannelMask(channel_);
3232 newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3233 replaceImage(newImage);
3234 RestorePPChannelMask;
3238 void Magick::Image::level(const double blackPoint_,const double whitePoint_,
3239 const double gamma_)
3243 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3247 void Magick::Image::levelChannel(const ChannelType channel_,
3248 const double blackPoint_,const double whitePoint_,const double gamma_)
3252 SetPPChannelMask(channel_);
3253 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3254 RestorePPChannelMask;
3258 void Magick::Image::levelColors(const Color &blackColor_,
3259 const Color &whiteColor_,const bool invert_)
3267 black=static_cast<PixelInfo>(blackColor_);
3268 white=static_cast<PixelInfo>(whiteColor_);
3270 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3271 MagickTrue : MagickFalse,exceptionInfo);
3275 void Magick::Image::levelColorsChannel(const ChannelType channel_,
3276 const Color &blackColor_,const Color &whiteColor_,const bool invert_)
3284 black=static_cast<PixelInfo>(blackColor_);
3285 white=static_cast<PixelInfo>(whiteColor_);
3287 SetPPChannelMask(channel_);
3288 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3289 MagickTrue : MagickFalse,exceptionInfo);
3290 RestorePPChannelMask;
3294 void Magick::Image::linearStretch(const double blackPoint_,
3295 const double whitePoint_)
3299 LinearStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
3303 void Magick::Image::liquidRescale(const Geometry &geometry_)
3316 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3320 newImage=LiquidRescaleImage(image(),width,height,x,y,exceptionInfo);
3321 replaceImage(newImage);
3325 void Magick::Image::magnify(void)
3331 newImage=MagnifyImage(constImage(),exceptionInfo);
3332 replaceImage(newImage);
3336 void Magick::Image::map(const Image &mapImage_,const bool dither_)
3340 options()->quantizeDither(dither_);
3341 RemapImage(options()->quantizeInfo(),image(),mapImage_.constImage(),
3346 void Magick::Image::medianFilter(const double radius_)
3352 newImage=StatisticImage(image(),MedianStatistic,(size_t) radius_,
3353 (size_t) radius_,exceptionInfo);
3354 replaceImage(newImage);
3358 void Magick::Image::minify(void)
3364 newImage=MinifyImage(constImage(),exceptionInfo);
3365 replaceImage(newImage);
3369 void Magick::Image::modulate(const double brightness_,const double saturation_,
3373 modulate[MaxTextExtent + 1];
3375 FormatLocaleString(modulate,MaxTextExtent,"%3.6f,%3.6f,%3.6f",brightness_,
3380 ModulateImage(image(),modulate,exceptionInfo);
3384 Magick::ImageMoments Magick::Image::moments(void)
3386 return(ImageMoments(constImage()));
3389 void Magick::Image::morphology(const MorphologyMethod method_,
3390 const std::string kernel_,const ssize_t iterations_)
3399 kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3400 if (kernel == (KernelInfo *) NULL)
3401 throwExceptionExplicit(OptionError,"Unable to parse kernel.");
3402 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3404 replaceImage(newImage);
3405 kernel=DestroyKernelInfo(kernel);
3409 void Magick::Image::morphology(const MorphologyMethod method_,
3410 const KernelInfoType kernel_,const std::string arguments_,
3411 const ssize_t iterations_)
3419 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3420 if (option == (const char *)NULL)
3421 throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
3423 kernel=std::string(option);
3424 if (!arguments_.empty())
3425 kernel+=":"+arguments_;
3427 morphology(method_,kernel,iterations_);
3430 void Magick::Image::morphologyChannel(const ChannelType channel_,
3431 const MorphologyMethod method_,const std::string kernel_,
3432 const ssize_t iterations_)
3442 kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3443 if (kernel == (KernelInfo *)NULL)
3444 throwExceptionExplicit(OptionError,"Unable to parse kernel.");
3445 SetPPChannelMask(channel_);
3446 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3448 RestorePPChannelMask;
3449 replaceImage(newImage);
3450 kernel=DestroyKernelInfo(kernel);
3454 void Magick::Image::morphologyChannel(const ChannelType channel_,
3455 const MorphologyMethod method_,const KernelInfoType kernel_,
3456 const std::string arguments_,const ssize_t iterations_)
3464 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3465 if (option == (const char *)NULL)
3466 throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
3468 kernel=std::string(option);
3469 if (!arguments_.empty())
3470 kernel+=":"+arguments_;
3472 morphologyChannel(channel_,method_,kernel,iterations_);
3475 void Magick::Image::motionBlur(const double radius_,const double sigma_,
3476 const double angle_)
3482 newImage=MotionBlurImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
3483 replaceImage(newImage);
3487 void Magick::Image::negate(const bool grayscale_)
3491 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3495 void Magick::Image::negateChannel(const ChannelType channel_,
3496 const bool grayscale_)
3500 SetPPChannelMask(channel_);
3501 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3502 RestorePPChannelMask;
3506 void Magick::Image::normalize(void)
3510 NormalizeImage(image(),exceptionInfo);
3514 void Magick::Image::oilPaint(const double radius_,const double sigma_)
3520 newImage=OilPaintImage(constImage(),radius_,sigma_,exceptionInfo);
3521 replaceImage(newImage);
3525 void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_,
3536 if (!opaqueColor_.isValid())
3537 throwExceptionExplicit(OptionError,"Opaque color argument is invalid");
3539 if (!penColor_.isValid())
3540 throwExceptionExplicit(OptionError,"Pen color argument is invalid");
3543 opaqueColor=opaqueColor_;
3547 (void) QueryColorCompliance(opaqueColor.c_str(),AllCompliance,&opaque,
3549 (void) QueryColorCompliance(penColor.c_str(),AllCompliance,&pen,
3551 OpaquePaintImage(image(),&opaque,&pen,invert_ ? MagickTrue : MagickFalse,
3556 void Magick::Image::orderedDither(std::string thresholdMap_)
3560 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3564 void Magick::Image::orderedDitherChannel(const ChannelType channel_,
3565 std::string thresholdMap_)
3569 SetPPChannelMask(channel_);
3570 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3571 RestorePPChannelMask;
3575 void Magick::Image::perceptible(const double epsilon_)
3579 PerceptibleImage(image(),epsilon_,exceptionInfo);
3583 void Magick::Image::perceptibleChannel(const ChannelType channel_,
3584 const double epsilon_)
3588 SetPPChannelMask(channel_);
3589 PerceptibleImage(image(),epsilon_,exceptionInfo);
3590 RestorePPChannelMask;
3594 Magick::ImagePerceptualHash Magick::Image::perceptualHash()
3596 return(ImagePerceptualHash(constImage()));
3599 void Magick::Image::ping(const std::string &imageSpec_)
3605 options()->fileName(imageSpec_);
3606 newImage=PingImage(imageInfo(),exceptionInfo);
3607 read(newImage,exceptionInfo);
3610 void Magick::Image::ping(const Blob& blob_)
3616 newImage=PingBlob(imageInfo(),blob_.data(),blob_.length(),exceptionInfo);
3617 read(newImage,exceptionInfo);
3620 void Magick::Image::pixelColor(const ssize_t x_,const ssize_t y_,
3621 const Color &color_)
3629 // Test arguments to ensure they are within the image.
3630 if (y_ > (ssize_t) rows() || x_ > (ssize_t) columns())
3631 throwExceptionExplicit(OptionError,"Access outside of image boundary");
3635 // Set image to DirectClass
3636 classType(DirectClass );
3639 Pixels pixels(*this);
3641 pixel=pixels.get(x_, y_, 1, 1 );
3643 MagickCore::SetPixelViaPixelInfo(constImage(),&packet,pixel);
3644 // Tell ImageMagick that pixels have been updated
3648 Magick::Color Magick::Image::pixelColor(const ssize_t x_,
3649 const ssize_t y_) const
3654 pixel=getConstPixels(x_,y_,1,1);
3660 MagickCore::GetPixelInfoPixel(constImage(),pixel,&packet);
3661 return(Color(packet));
3664 return(Color()); // invalid
3667 void Magick::Image::polaroid(const std::string &caption_,const double angle_,
3668 const PixelInterpolateMethod method_)
3674 newImage=PolaroidImage(constImage(),options()->drawInfo(),caption_.c_str(),
3675 angle_,method_,exceptionInfo);
3676 replaceImage(newImage);
3680 void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
3684 PosterizeImage(image(),levels_,method_,exceptionInfo);
3688 void Magick::Image::posterizeChannel(const ChannelType channel_,
3689 const size_t levels_,const DitherMethod method_)
3693 SetPPChannelMask(channel_);
3694 PosterizeImage(image(),levels_,method_,exceptionInfo);
3695 RestorePPChannelMask;
3699 void Magick::Image::process(std::string name_,const ssize_t argc,
3705 (void) InvokeDynamicImageFilter(name_.c_str(),&image(),argc,argv,
3710 void Magick::Image::profile(const std::string name_,
3711 const Magick::Blob &profile_)
3715 (void) ProfileImage(image(),name_.c_str(),(unsigned char *)profile_.data(),
3716 profile_.length(),exceptionInfo);
3720 Magick::Blob Magick::Image::profile(const std::string name_) const
3725 profile=GetImageProfile(constImage(),name_.c_str());
3727 if (profile == (StringInfo *) NULL)
3729 return(Blob((void*) GetStringInfoDatum(profile),GetStringInfoLength(
3733 void Magick::Image::quantize(const bool measureError_)
3738 options()->quantizeInfo()->measure_error=MagickTrue;
3740 options()->quantizeInfo()->measure_error=MagickFalse;
3743 QuantizeImage(options()->quantizeInfo(),image(),exceptionInfo);
3747 void Magick::Image::quantumOperator(const ChannelType channel_,
3748 const MagickEvaluateOperator operator_,double rvalue_)
3751 SetPPChannelMask(channel_);
3752 EvaluateImage(image(),operator_,rvalue_,exceptionInfo);
3753 RestorePPChannelMask;
3757 void Magick::Image::quantumOperator(const ssize_t x_,const ssize_t y_,
3758 const size_t columns_,const size_t rows_,const ChannelType channel_,
3759 const MagickEvaluateOperator operator_,const double rvalue_)
3767 geometry.width = columns_;
3768 geometry.height = rows_;
3773 cropImage=CropImage(image(),&geometry,exceptionInfo);
3774 SetPPChannelMask(channel_);
3775 EvaluateImage(cropImage,operator_,rvalue_,exceptionInfo);
3776 RestorePPChannelMask;
3777 (void) CompositeImage(image(),cropImage,image()->alpha_trait ==
3778 BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
3779 geometry.x,geometry.y,exceptionInfo );
3780 cropImage=DestroyImageList(cropImage);
3784 void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
3787 raiseInfo=geometry_;
3791 RaiseImage(image(),&raiseInfo,raisedFlag_ == true ? MagickTrue : MagickFalse,
3796 void Magick::Image::randomThreshold(const Geometry &thresholds_)
3799 (void) RandomThresholdImage(image(),static_cast<std::string>(
3800 thresholds_).c_str(),exceptionInfo);
3804 void Magick::Image::randomThresholdChannel(const ChannelType channel_,
3805 const Geometry &thresholds_)
3809 SetPPChannelMask(channel_);
3810 (void) RandomThresholdImage(image(),static_cast<std::string>(
3811 thresholds_).c_str(),exceptionInfo);
3812 RestorePPChannelMask;
3816 void Magick::Image::read(const Blob &blob_)
3822 newImage=BlobToImage(imageInfo(),static_cast<const void *>(blob_.data()),
3823 blob_.length(),exceptionInfo);
3824 read(newImage,exceptionInfo);
3827 void Magick::Image::read(const Blob &blob_,const Geometry &size_)
3833 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3834 const size_t depth_)
3841 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3842 const size_t depth_,const std::string &magick_)
3847 // Set explicit image format
3848 fileName(magick_ + ':');
3852 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3853 const std::string &magick_)
3857 // Set explicit image format
3858 fileName(magick_ + ':');
3862 void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_)
3868 void Magick::Image::read(const size_t width_,const size_t height_,
3869 const std::string &map_,const StorageType type_,const void *pixels_)
3875 newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
3877 replaceImage(newImage);
3881 void Magick::Image::read(const std::string &imageSpec_)
3887 options()->fileName(imageSpec_);
3888 newImage=ReadImage(imageInfo(),exceptionInfo);
3889 read(newImage,exceptionInfo);
3892 void Magick::Image::readPixels(const Magick::QuantumType quantum_,
3893 const unsigned char *source_)
3898 quantum_info=AcquireQuantumInfo(imageInfo(),image());
3900 ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
3901 quantum_,source_,exceptionInfo);
3902 quantum_info=DestroyQuantumInfo(quantum_info);
3906 void Magick::Image::reduceNoise(void)
3911 void Magick::Image::reduceNoise(const double order_)
3917 newImage=StatisticImage(constImage(),NonpeakStatistic,(size_t) order_,
3918 (size_t) order_,exceptionInfo);
3919 replaceImage(newImage);
3923 void Magick::Image::resample(const Point &density_)
3929 newImage=ResampleImage(constImage(),density_.x(),density_.y(),
3930 image()->filter,exceptionInfo);
3931 replaceImage(newImage);
3935 void Magick::Image::resize(const Geometry &geometry_)
3948 // Calculate new size. This code should be supported using binary arguments
3949 // in the ImageMagick library.
3950 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3954 newImage=ResizeImage(constImage(),width,height,image()->filter,
3956 replaceImage(newImage);
3960 void Magick::Image::roll(const Geometry &roll_)
3966 newImage=RollImage(constImage(),roll_.xOff(),roll_.yOff(),exceptionInfo);
3967 replaceImage(newImage);
3971 void Magick::Image::roll(const size_t columns_,const size_t rows_)
3977 newImage=RollImage(constImage(),static_cast<ssize_t>(columns_),
3978 static_cast<ssize_t>(rows_),exceptionInfo);
3979 replaceImage(newImage);
3983 void Magick::Image::rotate(const double degrees_)
3989 newImage=RotateImage(constImage(),degrees_,exceptionInfo);
3990 replaceImage(newImage);
3994 void Magick::Image::rotationalBlur(const double angle_)
4000 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4001 replaceImage(newImage);
4005 void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
4006 const double angle_)
4012 SetPPChannelMask(channel_);
4013 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4014 RestorePPChannelMask;
4015 replaceImage(newImage);
4019 void Magick::Image::sample(const Geometry &geometry_)
4032 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4036 newImage=SampleImage(constImage(),width,height,exceptionInfo);
4037 replaceImage(newImage);
4041 void Magick::Image::scale(const Geometry &geometry_)
4054 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4058 newImage=ScaleImage(constImage(),width,height,exceptionInfo);
4059 replaceImage(newImage);
4063 void Magick::Image::segment(const double clusterThreshold_,
4064 const double smoothingThreshold_)
4068 SegmentImage(image(),options()->quantizeColorSpace(),
4069 (MagickBooleanType) options()->verbose(),clusterThreshold_,
4070 smoothingThreshold_,exceptionInfo);
4071 SyncImage(image(),exceptionInfo);
4075 void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
4076 const double threshold_)
4082 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4084 replaceImage(newImage);
4088 void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
4089 const double radius_,const double sigma_,const double threshold_)
4095 SetPPChannelMask(channel_);
4096 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4098 RestorePPChannelMask;
4099 replaceImage(newImage);
4103 Magick::Image Magick::Image::separate(const ChannelType channel_)
4109 image=SeparateImage(constImage(),channel_,exceptionInfo);
4111 if (image == (MagickCore::Image *) NULL)
4112 return(Magick::Image());
4114 return(Magick::Image(image));
4117 void Magick::Image::sepiaTone(const double threshold_)
4123 newImage=SepiaToneImage(constImage(),threshold_,exceptionInfo);
4124 replaceImage(newImage);
4128 Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
4129 const size_t columns_,const size_t rows_)
4136 result=(*QueueAuthenticPixels)(image(),x_,y_,columns_,rows_,exceptionInfo);
4141 void Magick::Image::shade(const double azimuth_,const double elevation_,
4142 const bool colorShading_)
4148 newImage=ShadeImage(constImage(),colorShading_ == true ?
4149 MagickTrue : MagickFalse,azimuth_,elevation_,exceptionInfo);
4150 replaceImage(newImage);
4154 void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
4155 const ssize_t x_,const ssize_t y_)
4161 newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
4163 replaceImage(newImage);
4167 void Magick::Image::sharpen(const double radius_,const double sigma_)
4173 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4174 replaceImage(newImage);
4178 void Magick::Image::sharpenChannel(const ChannelType channel_,
4179 const double radius_,const double sigma_)
4185 SetPPChannelMask(channel_);
4186 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4187 RestorePPChannelMask;
4188 replaceImage(newImage);
4192 void Magick::Image::shave(const Geometry &geometry_)
4198 shaveInfo=geometry_;
4201 newImage=ShaveImage(constImage(),&shaveInfo,exceptionInfo);
4202 replaceImage(newImage);
4206 void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
4212 newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,exceptionInfo);
4213 replaceImage(newImage);
4217 void Magick::Image::sigmoidalContrast(const size_t sharpen_,
4218 const double contrast,const double midpoint)
4222 (void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
4223 midpoint,exceptionInfo);
4227 std::string Magick::Image::signature(const bool force_) const
4229 return(_imgRef->signature());
4232 void Magick::Image::sketch(const double radius_,const double sigma_,
4233 const double angle_)
4239 newImage=SketchImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
4240 replaceImage(newImage);
4244 void Magick::Image::solarize(const double factor_)
4248 SolarizeImage(image(),factor_,exceptionInfo);
4252 void Magick::Image::sparseColor(const ChannelType channel_,
4253 const SparseColorMethod method_,const size_t numberArguments_,
4254 const double *arguments_)
4260 SetPPChannelMask(channel_);
4261 newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
4263 RestorePPChannelMask;
4264 replaceImage(newImage);
4268 void Magick::Image::splice(const Geometry &geometry_)
4274 spliceInfo=geometry_;
4277 newImage=SpliceImage(constImage(),&spliceInfo,exceptionInfo);
4278 replaceImage(newImage);
4282 void Magick::Image::spread(const size_t amount_)
4288 newImage=SpreadImage(constImage(),amount_,image()->interpolate,
4290 replaceImage(newImage);
4294 Magick::ImageStatistics Magick::Image::statistics()
4296 return(ImageStatistics(constImage()));
4299 void Magick::Image::stegano(const Image &watermark_)
4305 newImage=SteganoImage(constImage(),watermark_.constImage(),exceptionInfo);
4306 replaceImage(newImage);
4310 void Magick::Image::stereo(const Image &rightImage_)
4316 newImage=StereoImage(constImage(),rightImage_.constImage(),exceptionInfo);
4317 replaceImage(newImage);
4321 void Magick::Image::strip(void)
4325 StripImage(image(),exceptionInfo);
4329 Magick::Image Magick::Image::subImageSearch(const Image &reference_,
4330 const MetricType metric_,Geometry *offset_,double *similarityMetric_,
4331 const double similarityThreshold)
4340 newImage=SimilarityImage(image(),reference_.constImage(),metric_,
4341 similarityThreshold,&offset,similarityMetric_,exceptionInfo);
4343 if (offset_ != (Geometry *) NULL)
4345 if (newImage == (MagickCore::Image *) NULL)
4346 return(Magick::Image());
4348 return(Magick::Image(newImage));
4351 void Magick::Image::swirl(const double degrees_)
4357 newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
4359 replaceImage(newImage);
4363 void Magick::Image::syncPixels(void)
4366 (void) (*SyncAuthenticPixels)(image(),exceptionInfo);
4370 void Magick::Image::texture(const Image &texture_)
4374 TextureImage(image(),texture_.constImage(),exceptionInfo);
4378 void Magick::Image::threshold(const double threshold_)
4382 BilevelImage(image(),threshold_,exceptionInfo);
4386 void Magick::Image::thumbnail(const Geometry &geometry_)
4399 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4403 newImage=ThumbnailImage(constImage(),width,height,exceptionInfo);
4404 replaceImage(newImage);
4408 void Magick::Image::tint(const std::string opacity_)
4417 color=static_cast<PixelInfo>(constOptions()->fillColor());
4418 newImage=TintImage(constImage(),opacity_.c_str(),&color,exceptionInfo);
4419 replaceImage(newImage);
4423 void Magick::Image::transform(const Geometry &imageGeometry_)
4427 TransformImage(&(image()),0,std::string(imageGeometry_).c_str(),
4432 void Magick::Image::transform(const Geometry &imageGeometry_,
4433 const Geometry &cropGeometry_)
4437 TransformImage(&(image()),std::string(cropGeometry_).c_str(),std::string(
4438 imageGeometry_).c_str(), exceptionInfo);
4442 void Magick::Image::transformOrigin(const double x_,const double y_)
4445 options()->transformOrigin(x_,y_);
4448 void Magick::Image::transformReset(void)
4451 options()->transformReset();
4454 void Magick::Image::transformScale(const double sx_,const double sy_)
4457 options()->transformScale(sx_,sy_);
4460 void Magick::Image::transparent(const Color &color_)
4468 if (!color_.isValid())
4469 throwExceptionExplicit(OptionError,"Color argument is invalid");
4473 (void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
4476 TransparentPaintImage(image(),&target,TransparentAlpha,MagickFalse,
4481 void Magick::Image::transparentChroma(const Color &colorLow_,
4482 const Color &colorHigh_)
4492 if (!colorLow_.isValid() || !colorHigh_.isValid())
4493 throwExceptionExplicit(OptionError,"Color argument is invalid");
4496 colorHigh=colorHigh_;
4499 (void) QueryColorCompliance(colorLow.c_str(),AllCompliance,&targetLow,
4501 (void) QueryColorCompliance(colorHigh.c_str(),AllCompliance,&targetHigh,
4504 TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
4505 MagickFalse,exceptionInfo);
4509 void Magick::Image::transpose(void)
4515 newImage=TransposeImage(constImage(),exceptionInfo);
4516 replaceImage(newImage);
4520 void Magick::Image::transverse(void)
4526 newImage=TransverseImage(constImage(),exceptionInfo);
4527 replaceImage(newImage);
4531 void Magick::Image::trim(void)
4537 newImage=TrimImage(constImage(),exceptionInfo);
4538 replaceImage(newImage);
4542 Magick::Image Magick::Image::uniqueColors(void)
4548 image=UniqueImageColors(constImage(),exceptionInfo);
4550 if (image == (MagickCore::Image *) NULL)
4551 return(Magick::Image());
4553 return(Magick::Image(image));
4556 void Magick::Image::unsharpmask(const double radius_,const double sigma_,
4557 const double amount_,const double threshold_)
4563 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4565 replaceImage(newImage);
4569 void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
4570 const double radius_,const double sigma_,const double amount_,
4571 const double threshold_)
4577 SetPPChannelMask(channel_);
4578 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4580 RestorePPChannelMask;
4581 replaceImage(newImage);
4585 void Magick::Image::vignette(const double radius_,const double sigma_,
4586 const ssize_t x_,const ssize_t y_)
4592 newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,exceptionInfo);
4593 replaceImage(newImage);
4597 void Magick::Image::wave(const double amplitude_,const double wavelength_)
4603 newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
4605 replaceImage(newImage);
4609 void Magick::Image::whiteThreshold(const std::string &threshold_)
4613 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4617 void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
4618 const std::string &threshold_)
4622 SetPPChannelMask(channel_);
4623 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4624 RestorePPChannelMask;
4628 void Magick::Image::write(Blob *blob_)
4638 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4640 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4644 void Magick::Image::write(Blob *blob_,const std::string &magick_)
4655 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4657 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4661 void Magick::Image::write(Blob *blob_,const std::string &magick_,
4662 const size_t depth_)
4674 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4676 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4680 void Magick::Image::write(const ssize_t x_,const ssize_t y_,
4681 const size_t columns_,const size_t rows_,const std::string &map_,
4682 const StorageType type_,void *pixels_)
4685 ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
4690 void Magick::Image::write(const std::string &imageSpec_)
4693 fileName(imageSpec_);
4695 WriteImage(constImageInfo(),image(),exceptionInfo);
4699 void Magick::Image::writePixels(const Magick::QuantumType quantum_,
4700 unsigned char *destination_)
4705 quantum_info=AcquireQuantumInfo(imageInfo(),image());
4707 ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4708 quantum_,destination_, exceptionInfo);
4709 quantum_info=DestroyQuantumInfo(quantum_info);
4713 void Magick::Image::zoom(const Geometry &geometry_)
4726 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4730 newImage=ResizeImage(constImage(),width,height,image()->filter,exceptionInfo);
4731 replaceImage(newImage);
4735 Magick::Image::Image(MagickCore::Image *image_)
4736 : _imgRef(new ImageRef(image_))
4740 MagickCore::Image *&Magick::Image::image(void)
4742 return(_imgRef->image());
4745 const MagickCore::Image *Magick::Image::constImage(void) const
4747 return(_imgRef->image());
4750 MagickCore::ImageInfo *Magick::Image::imageInfo(void)
4752 return(_imgRef->options()->imageInfo());
4755 const MagickCore::ImageInfo *Magick::Image::constImageInfo(void) const
4757 return(_imgRef->options()->imageInfo());
4760 Magick::Options *Magick::Image::options(void)
4762 return(_imgRef->options());
4765 const Magick::Options *Magick::Image::constOptions(void) const
4767 return(_imgRef->options());
4770 MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)
4772 return(_imgRef->options()->quantizeInfo());
4775 const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
4777 return(_imgRef->options()->quantizeInfo());
4780 void Magick::Image::modifyImage(void)
4782 if (_imgRef->isOwner())
4786 replaceImage(CloneImage(image(),0,0,MagickTrue,exceptionInfo));
4790 MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
4800 image=AcquireImage(constImageInfo(),exceptionInfo);
4804 // We can replace the image if we own it.
4805 if (!_imgRef->replaceImage(image))
4807 // We don't own the image, dereference and replace with new reference
4808 if (_imgRef->decrease() == 0)
4811 _imgRef=new ImageRef(image,constOptions());
4817 void Magick::Image::read(MagickCore::Image *image,
4818 MagickCore::ExceptionInfo *exceptionInfo)
4820 // Ensure that multiple image frames were not read.
4821 if (image != (MagickCore::Image *) NULL &&
4822 image->next != (MagickCore::Image *) NULL)
4827 // Destroy any extra image frames
4829 image->next=(MagickCore::Image *) NULL;
4830 next->previous=(MagickCore::Image *) NULL;
4831 DestroyImageList(next);
4833 replaceImage(image);
4834 if (exceptionInfo->severity == MagickCore::UndefinedException &&
4835 image == (MagickCore::Image *) NULL)
4837 (void) MagickCore::DestroyExceptionInfo(exceptionInfo);
4838 throwExceptionExplicit(ImageWarning,"No image was loaded.");
4843 void Magick::Image::floodFill(const ssize_t x_,const ssize_t y_,
4844 const Magick::Image *fillPattern_,const Magick::Color &fill_,
4845 const MagickCore::PixelInfo *target_,const bool invert_)
4853 // Set drawing fill pattern or fill color
4854 fillColor=options()->fillColor();
4855 fillPattern=(MagickCore::Image *)NULL;
4856 if (options()->fillPattern() != (MagickCore::Image *)NULL)
4859 fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
4864 if (fillPattern_ == (Magick::Image *)NULL)
4866 options()->fillPattern((MagickCore::Image *)NULL);
4867 options()->fillColor(fill_);
4870 options()->fillPattern(fillPattern_->constImage());
4873 (void) FloodfillPaintImage(image(),options()->drawInfo(),
4874 target_,static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),
4875 (MagickBooleanType) invert_,exceptionInfo);
4877 options()->fillColor(fillColor);
4878 options()->fillPattern(fillPattern);