1 // This may look like C code, but it is really -*- C++ -*-
3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
5 // Implementation of Image
8 #define MAGICKCORE_IMPLEMENTATION 1
9 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
11 #include "Magick++/Include.h"
20 #include "Magick++/Image.h"
21 #include "Magick++/Functions.h"
22 #include "Magick++/Pixels.h"
23 #include "Magick++/Options.h"
24 #include "Magick++/ImageRef.h"
26 #define AbsoluteValue(x) ((x) < 0 ? -(x) : (x))
27 #define MagickPI 3.14159265358979323846264338327950288419716939937510
28 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
30 MagickPPExport const char *Magick::borderGeometryDefault="6x6+0+0";
31 MagickPPExport const char *Magick::frameGeometryDefault="25x25+6+6";
32 MagickPPExport const char *Magick::raiseGeometryDefault="6x6+0+0";
34 MagickPPExport int Magick::operator == (const Magick::Image &left_,
35 const Magick::Image &right_)
37 // If image pixels and signature are the same, then the image is identical
38 return((left_.rows() == right_.rows()) &&
39 (left_.columns() == right_.columns()) &&
40 (left_.signature() == right_.signature()));
43 MagickPPExport int Magick::operator != (const Magick::Image &left_,
44 const Magick::Image &right_)
46 return(!(left_ == right_));
49 MagickPPExport int Magick::operator > (const Magick::Image &left_,
50 const Magick::Image &right_)
52 return(!(left_ < right_) && (left_ != right_));
55 MagickPPExport int Magick::operator < (const Magick::Image &left_,
56 const Magick::Image &right_)
58 // If image pixels are less, then image is smaller
59 return((left_.rows() * left_.columns()) <
60 (right_.rows() * right_.columns()));
63 MagickPPExport int Magick::operator >= (const Magick::Image &left_,
64 const Magick::Image &right_)
66 return((left_ > right_) || (left_ == right_));
69 MagickPPExport int Magick::operator <= (const Magick::Image &left_,
70 const Magick::Image &right_)
72 return((left_ < right_) || ( left_ == right_));
75 Magick::Image::Image(void)
76 : _imgRef(new ImageRef)
80 Magick::Image::Image(const Blob &blob_)
81 : _imgRef(new ImageRef)
85 // Initialize, Allocate and Read images
88 catch(const Warning &/*warning_*/)
90 // FIXME: need a way to report warnings in constructor
92 catch (const Error &/*error_*/)
100 Magick::Image::Image(const Blob &blob_,const Geometry &size_)
101 : _imgRef(new ImageRef)
108 catch(const Warning &/*warning_*/)
110 // FIXME: need a way to report warnings in constructor
112 catch(const Error &/*error_*/)
120 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
122 : _imgRef(new ImageRef)
127 read(blob_,size_,depth_);
129 catch(const Warning &/*warning_*/)
131 // FIXME: need a way to report warnings in constructor
133 catch(const Error &/*error_*/)
141 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
142 const size_t depth_,const std::string &magick_)
143 : _imgRef(new ImageRef)
148 read(blob_,size_,depth_,magick_);
150 catch(const Warning &/*warning_*/)
152 // FIXME: need a way to report warnings in constructor
154 catch(const Error &/*error_*/)
162 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
163 const std::string &magick_)
164 : _imgRef(new ImageRef)
169 read(blob_,size_,magick_);
171 catch(const Warning &/*warning_*/)
173 // FIXME: need a way to report warnings in constructor
175 catch(const Error &/*error_*/)
183 Magick::Image::Image(const Geometry &size_,const Color &color_)
184 : _imgRef(new ImageRef)
186 // xc: prefix specifies an X11 color string
187 std::string imageSpec("xc:");
195 // Initialize, Allocate and Read images
198 catch(const Warning &/*warning_*/)
200 // FIXME: need a way to report warnings in constructor
202 catch(const Error & /*error_*/)
210 Magick::Image::Image(const Image &image_)
211 : _imgRef(image_._imgRef)
213 Lock(&_imgRef->_mutexLock);
215 // Increase reference count
216 ++_imgRef->_refCount;
219 Magick::Image::Image(const size_t width_,const size_t height_,
220 const std::string &map_,const StorageType type_,const void *pixels_)
221 : _imgRef(new ImageRef)
225 read(width_,height_,map_.c_str(),type_,pixels_);
227 catch(const Warning &/*warning_*/)
229 // FIXME: need a way to report warnings in constructor
231 catch(const Error &/*error_*/)
239 Magick::Image::Image(const std::string &imageSpec_)
240 : _imgRef(new ImageRef)
244 // Initialize, Allocate and Read images
247 catch(const Warning &/*warning_*/)
249 // FIXME: need a way to report warnings in constructor
251 catch(const Error &/*error_*/)
259 Magick::Image::~Image()
265 Lock(&_imgRef->_mutexLock);
266 if (--_imgRef->_refCount == 0)
276 Magick::Image& Magick::Image::operator=(const Magick::Image &image_)
284 Lock(&image_._imgRef->_mutexLock);
285 ++image_._imgRef->_refCount;
289 Lock(&_imgRef->_mutexLock);
290 if (--_imgRef->_refCount == 0)
296 // Delete old image reference with associated image and options.
300 // Use new image reference
301 _imgRef=image_._imgRef;
307 void Magick::Image::adjoin(const bool flag_)
310 options()->adjoin(flag_);
313 bool Magick::Image::adjoin(void) const
315 return(constOptions()->adjoin());
318 void Magick::Image::alpha(const bool matteFlag_)
322 // If matte channel is requested, but image doesn't already have a
323 // matte channel, then create an opaque matte channel. Likewise, if
324 // the image already has a matte channel but a matte channel is not
325 // desired, then set the matte channel to opaque.
327 if ((matteFlag_ && !constImage()->alpha_trait) ||
328 (constImage()->alpha_trait && !matteFlag_))
329 SetImageAlpha(image(),OpaqueAlpha,exceptionInfo);
332 image()->alpha_trait=matteFlag_ ? BlendPixelTrait : UndefinedPixelTrait;
335 bool Magick::Image::alpha(void) const
337 if (constImage()->alpha_trait == BlendPixelTrait)
343 void Magick::Image::alphaColor(const Color &alphaColor_)
347 if (alphaColor_.isValid())
349 image()->matte_color=alphaColor_;
350 options()->matteColor(alphaColor_);
354 // Set to default matte color
355 Color tmpColor("#BDBDBD");
356 image()->matte_color=tmpColor;
357 options()->matteColor(tmpColor);
361 Magick::Color Magick::Image::alphaColor(void) const
363 return(Color(ClampToQuantum(constImage()->matte_color.red),
364 ClampToQuantum(constImage()->matte_color.green),
365 ClampToQuantum(constImage()->matte_color.blue)));
368 void Magick::Image::antiAlias(const bool flag_)
371 options()->antiAlias(static_cast<size_t>(flag_));
374 bool Magick::Image::antiAlias(void)
376 return(static_cast<bool>(options()->antiAlias()));
379 void Magick::Image::animationDelay(const size_t delay_)
382 image()->delay=delay_;
385 size_t Magick::Image::animationDelay(void) const
387 return(constImage()->delay);
390 void Magick::Image::animationIterations(const size_t iterations_)
393 image()->iterations=iterations_;
396 size_t Magick::Image::animationIterations(void) const
398 return(constImage()->iterations);
401 void Magick::Image::attenuate(const double attenuate_)
404 value[MaxTextExtent];
407 FormatLocaleString(value,MaxTextExtent,"%.20g",attenuate_);
408 (void) SetImageArtifact(image(),"attenuate",value);
411 void Magick::Image::backgroundColor(const Color &backgroundColor_)
415 if (backgroundColor_.isValid())
416 image()->background_color=backgroundColor_;
418 image()->background_color=Color();
420 options()->backgroundColor(backgroundColor_);
423 Magick::Color Magick::Image::backgroundColor(void) const
425 return(constOptions()->backgroundColor());
428 void Magick::Image::backgroundTexture(const std::string &backgroundTexture_)
431 options()->backgroundTexture(backgroundTexture_);
434 std::string Magick::Image::backgroundTexture(void) const
436 return(constOptions()->backgroundTexture());
439 size_t Magick::Image::baseColumns(void) const
441 return(constImage()->magick_columns);
444 std::string Magick::Image::baseFilename(void) const
446 return(std::string(constImage()->magick_filename));
449 size_t Magick::Image::baseRows(void) const
451 return(constImage()->magick_rows);
454 void Magick::Image::blackPointCompensation(const bool flag_)
456 image()->black_point_compensation=(MagickBooleanType) flag_;
459 bool Magick::Image::blackPointCompensation(void) const
461 return(static_cast<bool>(constImage()->black_point_compensation));
464 void Magick::Image::borderColor(const Color &borderColor_)
468 if (borderColor_.isValid())
469 image()->border_color=borderColor_;
471 image()->border_color=Color();
473 options()->borderColor(borderColor_);
476 Magick::Color Magick::Image::borderColor(void) const
478 return(constOptions()->borderColor());
481 Magick::Geometry Magick::Image::boundingBox(void) const
487 bbox=GetImageBoundingBox(constImage(),exceptionInfo);
489 return(Geometry(bbox));
492 void Magick::Image::boxColor(const Color &boxColor_)
495 options()->boxColor(boxColor_);
498 Magick::Color Magick::Image::boxColor(void) const
500 return(constOptions()->boxColor());
503 void Magick::Image::channelDepth(const ChannelType channel_,
508 SetPPChannelMask(channel_);
509 SetImageDepth(image(),depth_,exceptionInfo);
510 RestorePPChannelMask;
514 size_t Magick::Image::channelDepth(const ChannelType channel_)
520 SetPPChannelMask(channel_);
521 channel_depth=GetImageDepth(constImage(),exceptionInfo);
522 RestorePPChannelMask;
524 return(channel_depth);
527 size_t Magick::Image::channels() const
529 return(constImage()->number_channels);
532 void Magick::Image::classType(const ClassType class_)
534 if (classType() == PseudoClass && class_ == DirectClass)
536 // Use SyncImage to synchronize the DirectClass pixels with the
537 // color map and then set to DirectClass type.
540 SyncImage(image(),exceptionInfo);
542 image()->colormap=(PixelInfo *)RelinquishMagickMemory(image()->colormap);
543 image()->storage_class=static_cast<MagickCore::ClassType>(DirectClass);
547 if (classType() == DirectClass && class_ == PseudoClass)
549 // Quantize to create PseudoClass color map
551 quantizeColors(MaxColormapSize);
553 image()->storage_class=static_cast<MagickCore::ClassType>(PseudoClass);
557 Magick::ClassType Magick::Image::classType(void) const
559 return static_cast<Magick::ClassType>(constImage()->storage_class);
562 void Magick::Image::colorFuzz(const double fuzz_)
566 options()->colorFuzz(fuzz_);
569 double Magick::Image::colorFuzz(void) const
571 return(constOptions()->colorFuzz());
574 void Magick::Image::colorMapSize(const size_t entries_)
576 if (entries_ >MaxColormapSize)
577 throwExceptionExplicit(OptionError,
578 "Colormap entries must not exceed MaxColormapSize");
582 (void) AcquireImageColormap(image(),entries_,exceptionInfo);
586 size_t Magick::Image::colorMapSize(void) const
588 if (!constImage()->colormap)
589 throwExceptionExplicit(OptionError,"Image does not contain a colormap");
591 return(constImage()->colors);
594 void Magick::Image::colorSpace(const ColorspaceType colorSpace_)
596 if (image()->colorspace == colorSpace_)
601 TransformImageColorspace(image(),colorSpace_,exceptionInfo);
605 Magick::ColorspaceType Magick::Image::colorSpace(void) const
607 return (constImage()->colorspace);
610 void Magick::Image::colorSpaceType(const ColorspaceType colorSpace_)
614 SetImageColorspace(image(),colorSpace_,exceptionInfo);
616 options()->colorspaceType(colorSpace_);
619 Magick::ColorspaceType Magick::Image::colorSpaceType(void) const
621 return(constOptions()->colorspaceType());
624 size_t Magick::Image::columns(void) const
626 return(constImage()->columns);
629 void Magick::Image::comment(const std::string &comment_)
633 SetImageProperty(image(),"Comment",NULL,exceptionInfo);
634 if (comment_.length() > 0)
635 SetImageProperty(image(),"Comment",comment_.c_str(),exceptionInfo);
639 std::string Magick::Image::comment(void) const
645 value=GetImageProperty(constImage(),"Comment",exceptionInfo);
649 return(std::string(value));
651 return(std::string()); // Intentionally no exception
654 void Magick::Image::compose(const CompositeOperator compose_)
656 image()->compose=compose_;
659 Magick::CompositeOperator Magick::Image::compose(void) const
661 return(constImage()->compose);
664 void Magick::Image::compressType(const CompressionType compressType_)
667 image()->compression=compressType_;
668 options()->compressType(compressType_);
671 Magick::CompressionType Magick::Image::compressType(void) const
673 return(constImage()->compression);
676 void Magick::Image::debug(const bool flag_)
679 options()->debug(flag_);
682 bool Magick::Image::debug(void) const
684 return(constOptions()->debug());
687 void Magick::Image::density(const Geometry &density_)
690 options()->density(density_);
691 if (density_.isValid())
693 image()->resolution.x=density_.width();
694 if (density_.height() != 0)
695 image()->resolution.y=density_.height();
697 image()->resolution.y=density_.width();
702 image()->resolution.x=0;
703 image()->resolution.y=0;
707 Magick::Geometry Magick::Image::density(void) const
715 if (constImage()->resolution.x > 0.0)
716 x_resolution=static_cast<ssize_t>(constImage()->resolution.x + 0.5);
718 if (constImage()->resolution.y > 0.0)
719 y_resolution=static_cast<ssize_t>(constImage()->resolution.y + 0.5);
721 return(Geometry(x_resolution,y_resolution));
724 return(constOptions()->density());
727 void Magick::Image::depth(const size_t depth_)
732 if (depth > MAGICKCORE_QUANTUM_DEPTH)
733 depth=MAGICKCORE_QUANTUM_DEPTH;
736 image()->depth=depth;
737 options()->depth(depth);
740 size_t Magick::Image::depth(void) const
742 return(constImage()->depth);
745 std::string Magick::Image::directory(void) const
747 if (constImage()->directory)
748 return(std::string(constImage()->directory));
750 throwExceptionExplicit(CorruptImageWarning,
751 "Image does not contain a directory");
753 return(std::string());
756 void Magick::Image::endian(const Magick::EndianType endian_)
759 options()->endian(endian_);
760 image()->endian=endian_;
763 Magick::EndianType Magick::Image::endian(void) const
765 return(constImage()->endian);
768 void Magick::Image::exifProfile(const Magick::Blob &exifProfile_)
772 if (exifProfile_.data() != 0)
777 exif_profile=AcquireStringInfo(exifProfile_.length());
778 SetStringInfoDatum(exif_profile,(unsigned char *) exifProfile_.data());
780 (void) SetImageProfile(image(),"exif",exif_profile,exceptionInfo);
781 exif_profile=DestroyStringInfo(exif_profile);
786 Magick::Blob Magick::Image::exifProfile(void) const
791 exif_profile=GetImageProfile(constImage(),"exif");
792 if (exif_profile == (StringInfo *) NULL)
794 return(Blob(GetStringInfoDatum(exif_profile),
795 GetStringInfoLength(exif_profile)));
798 void Magick::Image::fileName(const std::string &fileName_)
802 fileName_.copy(image()->filename,sizeof(image()->filename)-1);
803 image()->filename[fileName_.length()]=0; // Null terminate
805 options()->fileName(fileName_);
808 std::string Magick::Image::fileName(void) const
810 return(constOptions()->fileName());
813 MagickCore::MagickSizeType Magick::Image::fileSize(void) const
815 return(GetBlobSize(constImage()));
818 void Magick::Image::fillColor(const Magick::Color &fillColor_)
824 options()->fillColor(fillColor_);
826 artifact("fill",value);
829 Magick::Color Magick::Image::fillColor(void) const
831 return(constOptions()->fillColor());
834 void Magick::Image::fillRule(const Magick::FillRule &fillRule_)
837 options()->fillRule(fillRule_);
840 Magick::FillRule Magick::Image::fillRule(void) const
842 return constOptions()->fillRule();
845 void Magick::Image::fillPattern(const Image &fillPattern_)
848 if (fillPattern_.isValid())
849 options()->fillPattern(fillPattern_.constImage());
851 options()->fillPattern(static_cast<MagickCore::Image*>(NULL));
854 Magick::Image Magick::Image::fillPattern(void) const
856 // FIXME: This is inordinately innefficient
857 const MagickCore::Image
863 tmpTexture=constOptions()->fillPattern();
871 image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
872 texture.replaceImage(image);
878 void Magick::Image::filterType(const Magick::FilterTypes filterType_)
881 image()->filter=filterType_;
884 Magick::FilterTypes Magick::Image::filterType(void) const
886 return(constImage()->filter);
889 void Magick::Image::font(const std::string &font_)
892 options()->font(font_);
895 std::string Magick::Image::font(void) const
897 return(constOptions()->font());
900 void Magick::Image::fontPointsize(const double pointSize_)
903 options()->fontPointsize(pointSize_);
906 double Magick::Image::fontPointsize(void) const
908 return(constOptions()->fontPointsize());
911 std::string Magick::Image::format(void) const
917 magick_info=GetMagickInfo(constImage()->magick,exceptionInfo);
920 if ((magick_info != 0) && (*magick_info->description != '\0'))
921 return(std::string(magick_info->description));
923 throwExceptionExplicit(CorruptImageWarning,"Unrecognized image magick type");
924 return(std::string());
927 std::string Magick::Image::formatExpression(const std::string expression)
937 text=InterpretImageProperties(imageInfo(),image(),expression.c_str(),
939 if (text != (char *) NULL)
941 text_string=std::string(text);
942 text=DestroyString(text);
948 double Magick::Image::gamma(void) const
950 return(constImage()->gamma);
953 Magick::Geometry Magick::Image::geometry(void) const
955 if (constImage()->geometry)
956 return Geometry(constImage()->geometry);
958 throwExceptionExplicit(OptionWarning,"Image does not contain a geometry");
963 void Magick::Image::gifDisposeMethod(
964 const MagickCore::DisposeType disposeMethod_)
967 image()->dispose=disposeMethod_;
970 MagickCore::DisposeType Magick::Image::gifDisposeMethod(void) const
972 return(constImage()->dispose);
975 void Magick::Image::highlightColor(const Color color_)
981 artifact("highlight-color",value);
984 void Magick::Image::iccColorProfile(const Magick::Blob &colorProfile_)
986 profile("icm",colorProfile_);
989 Magick::Blob Magick::Image::iccColorProfile(void) const
994 color_profile=GetImageProfile(constImage(),"icc");
995 if (color_profile == (StringInfo *) NULL)
997 return(Blob(GetStringInfoDatum(color_profile),GetStringInfoLength(
1001 void Magick::Image::interlaceType(const Magick::InterlaceType interlace_)
1004 image()->interlace=interlace_;
1005 options()->interlaceType(interlace_);
1008 Magick::InterlaceType Magick::Image::interlaceType(void) const
1010 return(constImage()->interlace);
1013 void Magick::Image::interpolate(const PixelInterpolateMethod interpolate_)
1016 image()->interpolate=interpolate_;
1019 Magick::PixelInterpolateMethod Magick::Image::interpolate(void) const
1021 return constImage()->interpolate;
1024 void Magick::Image::iptcProfile(const Magick::Blob &iptcProfile_)
1027 if (iptcProfile_.data() != 0)
1032 iptc_profile=AcquireStringInfo(iptcProfile_.length());
1033 SetStringInfoDatum(iptc_profile,(unsigned char *) iptcProfile_.data());
1035 (void) SetImageProfile(image(),"iptc",iptc_profile,exceptionInfo);
1036 iptc_profile=DestroyStringInfo(iptc_profile);
1041 Magick::Blob Magick::Image::iptcProfile(void) const
1046 iptc_profile=GetImageProfile(constImage(),"iptc");
1047 if (iptc_profile == (StringInfo *) NULL)
1049 return(Blob(GetStringInfoDatum(iptc_profile),GetStringInfoLength(
1053 void Magick::Image::isValid(const bool isValid_)
1058 _imgRef=new ImageRef;
1060 else if (!isValid())
1062 // Construct with single-pixel black image to make
1063 // image valid. This is an obvious hack.
1064 size(Geometry(1,1));
1069 bool Magick::Image::isValid(void) const
1071 return rows() && columns();
1074 void Magick::Image::label(const std::string &label_)
1078 (void) SetImageProperty(image(),"Label",NULL,exceptionInfo);
1079 if (label_.length() > 0)
1080 (void) SetImageProperty(image(),"Label",label_.c_str(),exceptionInfo);
1084 std::string Magick::Image::label(void) const
1090 value=GetImageProperty(constImage(),"Label",exceptionInfo);
1094 return(std::string(value));
1096 return(std::string());
1099 void Magick::Image::lowlightColor(const Color color_)
1105 artifact("lowlight-color",value);
1108 void Magick::Image::mask(const Magick::Image &mask_)
1113 if (mask_.isValid())
1114 SetImageMask(image(),mask_.constImage(),exceptionInfo);
1116 SetImageMask(image(),(MagickCore::Image *) NULL,exceptionInfo);
1120 Magick::Image Magick::Image::mask(void) const
1126 image=GetImageMask(constImage(),exceptionInfo);
1129 if (image == (MagickCore::Image *) NULL)
1130 return(Magick::Image());
1132 return(Magick::Image(image));
1135 void Magick::Image::magick(const std::string &magick_)
1139 magick_.copy(image()->magick,sizeof(image()->magick)-1);
1140 image()->magick[magick_.length()]=0;
1142 options()->magick(magick_);
1145 std::string Magick::Image::magick(void) const
1147 if (*(constImage()->magick) != '\0')
1148 return(std::string(constImage()->magick));
1150 return(constOptions()->magick());
1153 double Magick::Image::meanErrorPerPixel(void) const
1155 return(constImage()->error.mean_error_per_pixel);
1158 void Magick::Image::modulusDepth(const size_t depth_)
1162 SetImageDepth(image(),depth_,exceptionInfo);
1164 options()->depth(depth_);
1167 size_t Magick::Image::modulusDepth(void) const
1173 depth=GetImageDepth(constImage(),exceptionInfo);
1178 void Magick::Image::monochrome(const bool monochromeFlag_)
1181 options()->monochrome(monochromeFlag_);
1184 bool Magick::Image::monochrome(void) const
1186 return(constOptions()->monochrome());
1189 Magick::Geometry Magick::Image::montageGeometry(void) const
1191 if (constImage()->montage)
1192 return Magick::Geometry(constImage()->montage);
1194 throwExceptionExplicit(CorruptImageWarning,
1195 "Image does not contain a montage");
1197 return(Magick::Geometry());
1200 double Magick::Image::normalizedMaxError(void) const
1202 return(constImage()->error.normalized_maximum_error);
1205 double Magick::Image::normalizedMeanError(void) const
1207 return(constImage()->error.normalized_mean_error);
1210 void Magick::Image::orientation(const Magick::OrientationType orientation_)
1213 image()->orientation=orientation_;
1216 Magick::OrientationType Magick::Image::orientation(void) const
1218 return(constImage()->orientation);
1221 void Magick::Image::page(const Magick::Geometry &pageSize_)
1224 options()->page(pageSize_);
1225 image()->page=pageSize_;
1228 Magick::Geometry Magick::Image::page(void) const
1230 return(Geometry(constImage()->page.width,constImage()->page.height,
1231 AbsoluteValue(constImage()->page.x),AbsoluteValue(constImage()->page.y)));
1234 void Magick::Image::quality(const size_t quality_)
1237 image()->quality=quality_;
1238 options()->quality(quality_);
1241 size_t Magick::Image::quality(void) const
1243 return(constImage()->quality);
1246 void Magick::Image::quantizeColors(const size_t colors_)
1249 options()->quantizeColors(colors_);
1252 size_t Magick::Image::quantizeColors(void) const
1254 return(constOptions()->quantizeColors());
1257 void Magick::Image::quantizeColorSpace(
1258 const Magick::ColorspaceType colorSpace_)
1261 options()->quantizeColorSpace(colorSpace_);
1264 Magick::ColorspaceType Magick::Image::quantizeColorSpace(void) const
1266 return(constOptions()->quantizeColorSpace());
1269 void Magick::Image::quantizeDither(const bool ditherFlag_)
1272 options()->quantizeDither(ditherFlag_);
1275 bool Magick::Image::quantizeDither(void) const
1277 return(constOptions()->quantizeDither());
1280 void Magick::Image::quantizeDitherMethod(const DitherMethod ditherMethod_)
1283 options()->quantizeDitherMethod(ditherMethod_);
1286 MagickCore::DitherMethod Magick::Image::quantizeDitherMethod(void) const
1288 return(constOptions()->quantizeDitherMethod());
1291 void Magick::Image::quantizeTreeDepth(const size_t treeDepth_)
1294 options()->quantizeTreeDepth(treeDepth_);
1297 size_t Magick::Image::quantizeTreeDepth() const
1299 return(constOptions()->quantizeTreeDepth());
1302 void Magick::Image::renderingIntent(
1303 const Magick::RenderingIntent renderingIntent_)
1306 image()->rendering_intent=renderingIntent_;
1309 Magick::RenderingIntent Magick::Image::renderingIntent(void) const
1311 return(static_cast<Magick::RenderingIntent>(constImage()->rendering_intent));
1314 void Magick::Image::resolutionUnits(
1315 const Magick::ResolutionType resolutionUnits_)
1318 image()->units=resolutionUnits_;
1319 options()->resolutionUnits(resolutionUnits_);
1322 Magick::ResolutionType Magick::Image::resolutionUnits(void) const
1324 return(static_cast<Magick::ResolutionType>(constImage()->units));
1327 size_t Magick::Image::rows(void) const
1329 return(constImage()->rows);
1332 void Magick::Image::scene(const size_t scene_)
1335 image()->scene=scene_;
1338 size_t Magick::Image::scene(void) const
1340 return(constImage()->scene);
1343 void Magick::Image::size(const Geometry &geometry_)
1346 options()->size(geometry_);
1347 image()->rows=geometry_.height();
1348 image()->columns=geometry_.width();
1351 Magick::Geometry Magick::Image::size(void) const
1353 return(Magick::Geometry(constImage()->columns,constImage()->rows));
1356 void Magick::Image::strokeAntiAlias(const bool flag_)
1359 options()->strokeAntiAlias(flag_);
1362 bool Magick::Image::strokeAntiAlias(void) const
1364 return(constOptions()->strokeAntiAlias());
1367 void Magick::Image::strokeColor(const Magick::Color &strokeColor_)
1373 options()->strokeColor(strokeColor_);
1375 artifact("stroke",value);
1378 Magick::Color Magick::Image::strokeColor(void) const
1380 return(constOptions()->strokeColor());
1383 void Magick::Image::strokeDashArray(const double *strokeDashArray_)
1386 options()->strokeDashArray(strokeDashArray_);
1389 const double* Magick::Image::strokeDashArray(void) const
1391 return(constOptions()->strokeDashArray());
1394 void Magick::Image::strokeDashOffset(const double strokeDashOffset_)
1397 options()->strokeDashOffset(strokeDashOffset_);
1400 double Magick::Image::strokeDashOffset(void) const
1402 return(constOptions()->strokeDashOffset());
1405 void Magick::Image::strokeLineCap(const Magick::LineCap lineCap_)
1408 options()->strokeLineCap(lineCap_);
1411 Magick::LineCap Magick::Image::strokeLineCap(void) const
1413 return(constOptions()->strokeLineCap());
1416 void Magick::Image::strokeLineJoin(const Magick::LineJoin lineJoin_)
1419 options()->strokeLineJoin(lineJoin_);
1422 Magick::LineJoin Magick::Image::strokeLineJoin(void) const
1424 return(constOptions()->strokeLineJoin());
1427 void Magick::Image::strokeMiterLimit(const size_t strokeMiterLimit_)
1430 options()->strokeMiterLimit(strokeMiterLimit_);
1433 size_t Magick::Image::strokeMiterLimit(void) const
1435 return(constOptions()->strokeMiterLimit());
1438 void Magick::Image::strokePattern(const Image &strokePattern_)
1441 if(strokePattern_.isValid())
1442 options()->strokePattern(strokePattern_.constImage());
1444 options()->strokePattern(static_cast<MagickCore::Image*>(NULL));
1447 Magick::Image Magick::Image::strokePattern(void) const
1449 // FIXME: This is inordinately innefficient
1450 const MagickCore::Image
1456 tmpTexture=constOptions()->strokePattern();
1464 image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
1465 texture.replaceImage(image);
1471 void Magick::Image::strokeWidth(const double strokeWidth_)
1474 value[MaxTextExtent];
1477 options()->strokeWidth(strokeWidth_);
1478 FormatLocaleString(value,MaxTextExtent,"%.20g",strokeWidth_);
1479 (void) SetImageArtifact(image(),"strokewidth",value);
1482 double Magick::Image::strokeWidth(void) const
1484 return(constOptions()->strokeWidth());
1487 void Magick::Image::subImage(const size_t subImage_)
1490 options()->subImage(subImage_);
1493 size_t Magick::Image::subImage(void) const
1495 return(constOptions()->subImage());
1498 void Magick::Image::subRange(const size_t subRange_)
1501 options()->subRange(subRange_);
1504 size_t Magick::Image::subRange(void) const
1506 return(constOptions()->subRange());
1509 void Magick::Image::textDirection(DirectionType direction_)
1512 options()->textDirection(direction_);
1515 Magick::DirectionType Magick::Image::textDirection(void) const
1517 return(constOptions()->textDirection());
1520 void Magick::Image::textEncoding(const std::string &encoding_)
1523 options()->textEncoding(encoding_);
1526 std::string Magick::Image::textEncoding(void) const
1528 return(constOptions()->textEncoding());
1531 void Magick::Image::textGravity(GravityType gravity_)
1534 options()->textGravity(gravity_);
1537 Magick::GravityType Magick::Image::textGravity(void) const
1539 return(constOptions()->textGravity());
1542 void Magick::Image::textInterlineSpacing(double spacing_)
1545 options()->textInterlineSpacing(spacing_);
1548 double Magick::Image::textInterlineSpacing(void) const
1550 return(constOptions()->textInterlineSpacing());
1553 void Magick::Image::textInterwordSpacing(double spacing_)
1556 options()->textInterwordSpacing(spacing_);
1559 double Magick::Image::textInterwordSpacing(void) const
1561 return(constOptions()->textInterwordSpacing());
1564 void Magick::Image::textKerning(double kerning_)
1567 options()->textKerning(kerning_);
1570 double Magick::Image::textKerning(void) const
1572 return(constOptions()->textKerning());
1575 size_t Magick::Image::totalColors(void) const
1581 colors=GetNumberColors(constImage(),0,exceptionInfo);
1586 void Magick::Image::transformRotation(const double angle_)
1589 options()->transformRotation(angle_);
1592 void Magick::Image::transformSkewX(const double skewx_)
1595 options()->transformSkewX(skewx_);
1598 void Magick::Image::transformSkewY(const double skewy_)
1601 options()->transformSkewY(skewy_);
1604 Magick::ImageType Magick::Image::type(void) const
1606 if (constOptions()->type() != UndefinedType)
1607 return(constOptions()->type());
1608 else if (constImage()->type != UndefinedType)
1609 return(constImage()->type);
1611 return(determineType());
1614 void Magick::Image::type(const Magick::ImageType type_)
1617 options()->type(type_);
1619 SetImageType(image(),type_,exceptionInfo);
1623 void Magick::Image::verbose(const bool verboseFlag_)
1626 options()->verbose(verboseFlag_);
1629 bool Magick::Image::verbose(void) const
1631 return(constOptions()->verbose());
1634 void Magick::Image::view(const std::string &view_)
1637 options()->view(view_);
1640 std::string Magick::Image::view(void) const
1642 return(constOptions()->view());
1645 void Magick::Image::virtualPixelMethod(
1646 const VirtualPixelMethod virtualPixelMethod_)
1650 SetImageVirtualPixelMethod(image(),virtualPixelMethod_,exceptionInfo);
1654 Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod(void) const
1656 return(GetImageVirtualPixelMethod(constImage()));
1659 void Magick::Image::x11Display(const std::string &display_)
1662 options()->x11Display(display_);
1665 std::string Magick::Image::x11Display(void) const
1667 return(constOptions()->x11Display());
1670 double Magick::Image::xResolution(void) const
1672 return(constImage()->resolution.x);
1675 double Magick::Image::yResolution(void) const
1677 return(constImage()->resolution.y);
1680 void Magick::Image::adaptiveBlur(const double radius_,const double sigma_)
1686 newImage=AdaptiveBlurImage(constImage(),radius_,sigma_,exceptionInfo);
1687 replaceImage(newImage);
1691 void Magick::Image::adaptiveResize(const Geometry &geometry_)
1704 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
1708 newImage=AdaptiveResizeImage(constImage(),width,height,exceptionInfo);
1709 replaceImage(newImage);
1713 void Magick::Image::adaptiveSharpen(const double radius_,const double sigma_)
1719 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1720 replaceImage(newImage);
1724 void Magick::Image::adaptiveSharpenChannel(const ChannelType channel_,
1725 const double radius_,const double sigma_ )
1731 SetPPChannelMask(channel_);
1732 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1733 RestorePPChannelMask;
1734 replaceImage(newImage);
1738 void Magick::Image::adaptiveThreshold(const size_t width_,const size_t height_,
1739 const ssize_t offset_)
1746 newImage=AdaptiveThresholdImage(constImage(),width_,height_,offset_,
1748 replaceImage(newImage);
1752 void Magick::Image::addNoise(const NoiseType noiseType_)
1758 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1759 replaceImage(newImage);
1763 void Magick::Image::addNoiseChannel(const ChannelType channel_,
1764 const NoiseType noiseType_)
1770 SetPPChannelMask(channel_);
1771 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1772 RestorePPChannelMask;
1773 replaceImage(newImage);
1777 void Magick::Image::affineTransform(const DrawableAffine &affine_)
1785 _affine.sx=affine_.sx();
1786 _affine.sy=affine_.sy();
1787 _affine.rx=affine_.rx();
1788 _affine.ry=affine_.ry();
1789 _affine.tx=affine_.tx();
1790 _affine.ty=affine_.ty();
1793 newImage=AffineTransformImage(constImage(),&_affine,exceptionInfo);
1794 replaceImage(newImage);
1798 void Magick::Image::alpha(const unsigned int alpha_)
1802 SetImageAlpha(image(),alpha_,exceptionInfo);
1806 void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
1810 SetImageAlphaChannel(image(),alphaOption_,exceptionInfo);
1814 void Magick::Image::annotate(const std::string &text_,
1815 const Geometry &location_)
1817 annotate(text_,location_,NorthWestGravity,0.0);
1820 void Magick::Image::annotate(const std::string &text_,
1821 const Geometry &boundingArea_,const GravityType gravity_)
1823 annotate(text_,boundingArea_,gravity_,0.0);
1826 void Magick::Image::annotate(const std::string &text_,
1827 const Geometry &boundingArea_,const GravityType gravity_,
1828 const double degrees_)
1834 boundingArea[MaxTextExtent];
1841 drawInfo=options()->drawInfo();
1842 drawInfo->text=const_cast<char *>(text_.c_str());
1843 drawInfo->geometry=0;
1845 if (boundingArea_.isValid())
1847 if (boundingArea_.width() == 0 || boundingArea_.height() == 0)
1849 FormatLocaleString(boundingArea,MaxTextExtent,"%+.20g%+.20g",
1850 (double) boundingArea_.xOff(),(double) boundingArea_.yOff());
1854 (void) CopyMagickString(boundingArea,string(boundingArea_).c_str(),
1857 drawInfo->geometry=boundingArea;
1860 drawInfo->gravity=gravity_;
1862 oaffine=drawInfo->affine;
1863 if (degrees_ != 0.0)
1876 current=drawInfo->affine;
1877 affine.sx=cos(DegreesToRadians(fmod(degrees_,360.0)));
1878 affine.rx=sin(DegreesToRadians(fmod(degrees_,360.0)));
1879 affine.ry=(-sin(DegreesToRadians(fmod(degrees_,360.0))));
1880 affine.sy=cos(DegreesToRadians(fmod(degrees_,360.0)));
1882 drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
1883 drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
1884 drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
1885 drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
1886 drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty
1891 AnnotateImage(image(),drawInfo,exceptionInfo);
1893 // Restore original values
1894 drawInfo->affine=oaffine;
1896 drawInfo->geometry=0;
1901 void Magick::Image::annotate(const std::string &text_,
1902 const GravityType gravity_)
1909 drawInfo=options()->drawInfo();
1910 drawInfo->text=const_cast<char *>(text_.c_str());
1911 drawInfo->gravity=gravity_;
1914 AnnotateImage(image(),drawInfo,exceptionInfo);
1916 drawInfo->gravity=NorthWestGravity;
1922 void Magick::Image::artifact(const std::string &name_,const std::string &value_)
1925 (void) SetImageArtifact(image(),name_.c_str(),value_.c_str());
1928 std::string Magick::Image::artifact(const std::string &name_)
1933 value=GetImageArtifact(constImage(),name_.c_str());
1935 return(std::string(value));
1936 return(std::string());
1939 void Magick::Image::attribute(const std::string name_,const std::string value_)
1943 SetImageProperty(image(),name_.c_str(),value_.c_str(),exceptionInfo);
1947 std::string Magick::Image::attribute(const std::string name_)
1953 value=GetImageProperty(constImage(),name_.c_str(),exceptionInfo);
1957 return(std::string(value));
1959 return(std::string()); // Intentionally no exception
1962 void Magick::Image::autoGamma(void)
1966 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1967 (void) AutoGammaImage(image(),exceptionInfo);
1971 void Magick::Image::autoGammaChannel(const ChannelType channel_)
1975 SetPPChannelMask(channel_);
1976 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1977 (void) AutoGammaImage(image(),exceptionInfo);
1978 RestorePPChannelMask;
1982 void Magick::Image::autoLevel(void)
1986 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1987 (void) AutoLevelImage(image(),exceptionInfo);
1991 void Magick::Image::autoLevelChannel(const ChannelType channel_)
1995 SetPPChannelMask(channel_);
1996 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1997 (void) AutoLevelImage(image(),exceptionInfo);
1998 RestorePPChannelMask;
2002 void Magick::Image::autoOrient(void)
2007 if (image()->orientation == UndefinedOrientation ||
2008 image()->orientation == TopLeftOrientation)
2012 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2013 newImage=AutoOrientImage(constImage(),image()->orientation,exceptionInfo);
2014 replaceImage(newImage);
2018 void Magick::Image::blackThreshold(const std::string &threshold_)
2022 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2026 void Magick::Image::blackThresholdChannel(const ChannelType channel_,
2027 const std::string &threshold_)
2031 SetPPChannelMask(channel_);
2032 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2033 RestorePPChannelMask;
2037 void Magick::Image::blueShift(const double factor_)
2043 newImage=BlueShiftImage(constImage(),factor_,exceptionInfo);
2044 replaceImage(newImage);
2048 void Magick::Image::blur(const double radius_,const double sigma_)
2054 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2055 replaceImage(newImage);
2059 void Magick::Image::blurChannel(const ChannelType channel_,
2060 const double radius_,const double sigma_)
2066 SetPPChannelMask(channel_);
2067 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2068 RestorePPChannelMask;
2069 replaceImage(newImage);
2073 void Magick::Image::border(const Geometry &geometry_)
2079 borderInfo=geometry_;
2082 newImage=BorderImage(constImage(),&borderInfo,image()->compose,
2084 replaceImage(newImage);
2088 void Magick::Image::brightnessContrast(const double brightness_,
2089 const double contrast_)
2093 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2097 void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
2098 const double brightness_,const double contrast_)
2102 SetPPChannelMask(channel_);
2103 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2104 RestorePPChannelMask;
2108 void Magick::Image::cannyEdge(const double radius_,const double sigma_,
2109 const double lowerPercent_,const double upperPercent_)
2116 newImage=CannyEdgeImage(constImage(),radius_,sigma_,lowerPercent_,
2117 upperPercent_,exceptionInfo);
2118 replaceImage(newImage);
2122 void Magick::Image::channel(const ChannelType channel_)
2128 newImage=SeparateImage(image(),channel_,exceptionInfo);
2129 replaceImage(newImage);
2133 void Magick::Image::charcoal(const double radius_,const double sigma_)
2139 newImage=CharcoalImage(image(),radius_,sigma_,exceptionInfo);
2140 replaceImage(newImage);
2144 void Magick::Image::chop(const Geometry &geometry_)
2153 newImage=ChopImage(image(),&chopInfo,exceptionInfo);
2154 replaceImage(newImage);
2158 void Magick::Image::chromaBluePrimary(const double x_,const double y_)
2161 image()->chromaticity.blue_primary.x=x_;
2162 image()->chromaticity.blue_primary.y=y_;
2165 void Magick::Image::chromaBluePrimary(double *x_,double *y_) const
2167 *x_=constImage()->chromaticity.blue_primary.x;
2168 *y_=constImage()->chromaticity.blue_primary.y;
2171 void Magick::Image::chromaGreenPrimary(const double x_,const double y_)
2174 image()->chromaticity.green_primary.x=x_;
2175 image()->chromaticity.green_primary.y=y_;
2178 void Magick::Image::chromaGreenPrimary(double *x_,double *y_) const
2180 *x_=constImage()->chromaticity.green_primary.x;
2181 *y_=constImage()->chromaticity.green_primary.y;
2184 void Magick::Image::chromaRedPrimary(const double x_,const double y_)
2187 image()->chromaticity.red_primary.x=x_;
2188 image()->chromaticity.red_primary.y=y_;
2191 void Magick::Image::chromaRedPrimary(double *x_,double *y_) const
2193 *x_=constImage()->chromaticity.red_primary.x;
2194 *y_=constImage()->chromaticity.red_primary.y;
2197 void Magick::Image::chromaWhitePoint(const double x_,const double y_)
2200 image()->chromaticity.white_point.x=x_;
2201 image()->chromaticity.white_point.y=y_;
2204 void Magick::Image::chromaWhitePoint(double *x_,double *y_) const
2206 *x_=constImage()->chromaticity.white_point.x;
2207 *y_=constImage()->chromaticity.white_point.y;
2210 void Magick::Image::cdl(const std::string &cdl_)
2214 (void) ColorDecisionListImage(image(),cdl_.c_str(),exceptionInfo);
2218 void Magick::Image::clamp(void)
2222 ClampImage(image(),exceptionInfo);
2226 void Magick::Image::clampChannel(const ChannelType channel_)
2230 SetPPChannelMask(channel_);
2231 ClampImage(image(),exceptionInfo);
2232 RestorePPChannelMask;
2236 void Magick::Image::clip(void)
2240 ClipImage(image(),exceptionInfo);
2244 void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
2248 ClipImagePath(image(),pathname_.c_str(),(MagickBooleanType) inside_,
2253 void Magick::Image::clut(const Image &clutImage_,
2254 const PixelInterpolateMethod method)
2258 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2262 void Magick::Image::clutChannel(const ChannelType channel_,
2263 const Image &clutImage_,const PixelInterpolateMethod method)
2267 SetPPChannelMask(channel_);
2268 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2269 RestorePPChannelMask;
2273 void Magick::Image::colorize(const unsigned int alpha_,const Color &penColor_)
2275 colorize(alpha_,alpha_,alpha_,penColor_);
2278 void Magick::Image::colorize(const unsigned int alphaRed_,
2279 const unsigned int alphaGreen_,const unsigned int alphaBlue_,
2280 const Color &penColor_)
2283 blend[MaxTextExtent];
2292 if (!penColor_.isValid())
2293 throwExceptionExplicit(OptionError,"Pen color argument is invalid");
2295 FormatLocaleString(blend,MaxTextExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
2298 GetPixelInfo(image(),&target);
2299 pixel=static_cast<PixelInfo>(penColor_);
2300 target.red=pixel.red;
2301 target.green=pixel.green;
2302 target.blue=pixel.blue;
2303 target.alpha=pixel.alpha;
2305 newImage=ColorizeImage(image(),blend,&target,exceptionInfo);
2306 replaceImage(newImage);
2310 void Magick::Image::colorMap(const size_t index_,const Color &color_)
2317 if (index_ > (MaxColormapSize-1))
2318 throwExceptionExplicit(OptionError,
2319 "Colormap index must be less than MaxColormapSize");
2321 if (!color_.isValid())
2322 throwExceptionExplicit(OptionError,"Color argument is invalid");
2326 // Ensure that colormap size is large enough
2327 if (colorMapSize() < (index_+1))
2328 colorMapSize(index_+1);
2330 // Set color at index in colormap
2331 (imageptr->colormap)[index_]=color_;
2334 Magick::Color Magick::Image::colorMap(const size_t index_) const
2336 if (!constImage()->colormap)
2338 throwExceptionExplicit(OptionError,"Image does not contain a colormap");
2342 if (index_ > constImage()->colors-1)
2343 throwExceptionExplicit(OptionError,"Index out of range");
2345 return(Magick::Color((constImage()->colormap)[index_]));
2348 void Magick::Image::colorMatrix(const size_t order_,
2349 const double *color_matrix_)
2355 kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2356 if (kernel_info != (KernelInfo *) NULL)
2358 kernel_info->width=order_;
2359 kernel_info->height=order_;
2360 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2361 order_*sizeof(*kernel_info->values));
2362 if (kernel_info->values != (MagickRealType *) NULL)
2367 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2368 kernel_info->values[i]=color_matrix_[i];
2369 newImage=ColorMatrixImage(image(),kernel_info,exceptionInfo);
2370 replaceImage(newImage);
2372 kernel_info=DestroyKernelInfo(kernel_info);
2377 bool Magick::Image::compare(const Image &reference_)
2388 status=static_cast<bool>(IsImagesEqual(image(),ref.image(),exceptionInfo));
2393 double Magick::Image::compare(const Image &reference_,const MetricType metric_)
2399 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2405 double Magick::Image::compareChannel(const ChannelType channel_,
2406 const Image &reference_,const MetricType metric_)
2412 SetPPChannelMask(channel_);
2413 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2415 RestorePPChannelMask;
2420 Magick::Image Magick::Image::compare(const Image &reference_,
2421 const MetricType metric_,double *distortion)
2427 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2430 if (newImage == (MagickCore::Image *) NULL)
2431 return(Magick::Image());
2433 return(Magick::Image(newImage));
2436 Magick::Image Magick::Image::compareChannel(const ChannelType channel_,
2437 const Image &reference_,const MetricType metric_,double *distortion)
2443 SetPPChannelMask(channel_);
2444 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2446 RestorePPChannelMask;
2448 if (newImage == (MagickCore::Image *) NULL)
2449 return(Magick::Image());
2451 return(Magick::Image(newImage));
2454 void Magick::Image::composite(const Image &compositeImage_,
2455 const Geometry &offset_,const CompositeOperator compose_)
2465 ParseMetaGeometry(static_cast<std::string>(offset_).c_str(),&x,&y,&width,
2470 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2475 void Magick::Image::composite(const Image &compositeImage_,
2476 const GravityType gravity_,const CompositeOperator compose_)
2482 SetGeometry(compositeImage_.constImage(),&geometry);
2483 GravityAdjustGeometry(columns(),rows(),gravity_,&geometry);
2486 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2487 geometry.x,geometry.y,exceptionInfo);
2491 void Magick::Image::composite(const Image &compositeImage_,
2492 const ssize_t xOffset_,const ssize_t yOffset_,
2493 const CompositeOperator compose_)
2495 // Image supplied as compositeImage is composited with current image and
2496 // results in updating current image.
2499 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2500 xOffset_,yOffset_,exceptionInfo);
2504 void Magick::Image::contrast(const size_t sharpen_)
2508 ContrastImage(image(),(MagickBooleanType) sharpen_,exceptionInfo);
2512 void Magick::Image::contrastStretch(const double blackPoint_,
2513 const double whitePoint_)
2517 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2521 void Magick::Image::contrastStretchChannel(const ChannelType channel_,
2522 const double blackPoint_,const double whitePoint_)
2526 SetPPChannelMask(channel_);
2527 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2528 RestorePPChannelMask;
2532 void Magick::Image::convolve(const size_t order_,const double *kernel_)
2538 kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2539 kernel_info->width=order_;
2540 kernel_info->height=order_;
2541 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2542 order_*sizeof(*kernel_info->values));
2543 if (kernel_info->values != (MagickRealType *) NULL)
2548 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2549 kernel_info->values[i]=kernel_[i];
2550 newImage=ConvolveImage(image(),kernel_info,exceptionInfo);
2551 replaceImage(newImage);
2553 kernel_info=DestroyKernelInfo(kernel_info);
2557 void Magick::Image::crop(const Geometry &geometry_)
2566 newImage=CropImage(constImage(),&cropInfo,exceptionInfo);
2567 replaceImage(newImage);
2571 void Magick::Image::cycleColormap(const ssize_t amount_)
2575 CycleColormapImage(image(),amount_,exceptionInfo);
2579 void Magick::Image::decipher(const std::string &passphrase_)
2583 DecipherImage(image(),passphrase_.c_str(),exceptionInfo);
2587 void Magick::Image::defineSet(const std::string &magick_,
2588 const std::string &key_,bool flag_)
2594 definition=magick_ + ":" + key_;
2596 (void) SetImageOption(imageInfo(),definition.c_str(),"");
2598 DeleteImageOption(imageInfo(),definition.c_str());
2601 bool Magick::Image::defineSet(const std::string &magick_,
2602 const std::string &key_ ) const
2610 key=magick_ + ":" + key_;
2611 option=GetImageOption(constImageInfo(),key.c_str());
2617 void Magick::Image::defineValue(const std::string &magick_,
2618 const std::string &key_,const std::string &value_)
2625 format=magick_ + ":" + key_;
2627 (void) SetImageOption(imageInfo(),format.c_str(),option.c_str());
2630 std::string Magick::Image::defineValue(const std::string &magick_,
2631 const std::string &key_) const
2639 definition=magick_ + ":" + key_;
2640 option=GetImageOption(constImageInfo(),definition.c_str());
2642 return(std::string(option));
2643 return(std::string());
2646 void Magick::Image::deskew(const double threshold_)
2652 newImage=DeskewImage(constImage(),threshold_,exceptionInfo);
2653 replaceImage(newImage);
2657 void Magick::Image::despeckle(void)
2663 newImage=DespeckleImage(constImage(),exceptionInfo);
2664 replaceImage(newImage);
2668 Magick::ImageType Magick::Image::determineType(void) const
2674 image_type=GetImageType(constImage(),exceptionInfo);
2679 void Magick::Image::display(void)
2682 DisplayImages(imageInfo(),image(),exceptionInfo);
2686 void Magick::Image::distort(const DistortImageMethod method_,
2687 const size_t numberArguments_,const double *arguments_,const bool bestfit_)
2693 newImage=DistortImage(constImage(), method_,numberArguments_,arguments_,
2694 bestfit_ == true ? MagickTrue : MagickFalse,exceptionInfo);
2695 replaceImage(newImage);
2699 void Magick::Image::draw(const Magick::Drawable &drawable_)
2706 wand=DrawAllocateWand(options()->drawInfo(),image());
2710 drawable_.operator()(wand);
2714 ClonePPDrawException(wand);
2715 wand=DestroyDrawingWand(wand);
2716 ThrowPPDrawException;
2720 void Magick::Image::draw(const std::list<Magick::Drawable> &drawable_)
2727 wand=DrawAllocateWand(options()->drawInfo(),image());
2731 for (std::list<Magick::Drawable>::const_iterator p = drawable_.begin();
2732 p != drawable_.end(); p++ )
2734 p->operator()(wand);
2735 if (DrawGetExceptionType(wand) != UndefinedException)
2739 if (DrawGetExceptionType(wand) == UndefinedException)
2742 ClonePPDrawException(wand);
2743 wand=DestroyDrawingWand(wand);
2744 ThrowPPDrawException;
2748 void Magick::Image::edge(const double radius_)
2754 newImage=EdgeImage(constImage(),radius_,exceptionInfo);
2755 replaceImage(newImage);
2759 void Magick::Image::emboss(const double radius_,const double sigma_)
2765 newImage=EmbossImage(constImage(),radius_,sigma_,exceptionInfo);
2766 replaceImage(newImage);
2770 void Magick::Image::encipher(const std::string &passphrase_)
2774 EncipherImage(image(),passphrase_.c_str(),exceptionInfo);
2778 void Magick::Image::enhance(void)
2784 newImage=EnhanceImage(constImage(),exceptionInfo);
2785 replaceImage(newImage);
2789 void Magick::Image::equalize(void)
2793 EqualizeImage(image(),exceptionInfo);
2797 void Magick::Image::erase(void)
2801 (void) SetImageBackgroundColor(image(),exceptionInfo);
2805 void Magick::Image::extent(const Geometry &geometry_ )
2811 extentInfo=geometry_;
2814 extentInfo.x=geometry_.xOff();
2815 extentInfo.y=geometry_.yOff();
2817 newImage=ExtentImage(image(),&extentInfo,exceptionInfo);
2818 replaceImage(newImage);
2822 void Magick::Image::extent(const Geometry &geometry_,
2823 const Color &backgroundColor_)
2825 backgroundColor(backgroundColor_);
2829 void Magick::Image::extent(const Geometry &geometry_,
2830 const Color &backgroundColor_,const GravityType gravity_)
2832 backgroundColor(backgroundColor_);
2833 extent(geometry_,gravity_);
2836 void Magick::Image::extent(const Geometry &geometry_,
2837 const GravityType gravity_)
2842 SetGeometry(image(),&geometry);
2843 geometry.width=geometry_.width();
2844 geometry.height=geometry_.height();
2845 GravityAdjustGeometry(image()->columns,image()->rows,gravity_,&geometry);
2849 void Magick::Image::flip(void)
2855 newImage=FlipImage(constImage(),exceptionInfo);
2856 replaceImage(newImage);
2860 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2861 const unsigned int alpha_,const bool invert_)
2869 GetPixelInfo(constImage(),&target);
2870 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2871 target.red=pixel.red;
2872 target.green=pixel.green;
2873 target.blue=pixel.blue;
2874 target.alpha=alpha_;
2876 SetPPChannelMask(AlphaChannel);
2877 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2878 (MagickBooleanType)invert_,exceptionInfo);
2879 RestorePPChannelMask;
2883 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2884 const unsigned int alpha_,const Color &target_,const bool invert_)
2892 GetPixelInfo(constImage(),&target);
2893 pixel=static_cast<PixelInfo>(target_);
2894 target.red=pixel.red;
2895 target.green=pixel.green;
2896 target.blue=pixel.blue;
2897 target.alpha=alpha_;
2899 SetPPChannelMask(AlphaChannel);
2900 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2901 (MagickBooleanType)invert_,exceptionInfo);
2902 RestorePPChannelMask;
2906 void Magick::Image::floodFillColor(const Geometry &point_,
2907 const Magick::Color &fillColor_,const bool invert_)
2909 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,invert_);
2912 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2913 const Magick::Color &fillColor_,const bool invert_)
2920 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2921 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2924 void Magick::Image::floodFillColor(const Geometry &point_,
2925 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2928 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,borderColor_,invert_);
2931 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2932 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2940 pixel=static_cast<PixelInfo>(borderColor_);
2941 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2944 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2945 const Magick::Image &texture_,const bool invert_)
2947 floodFillTexture(point_.xOff(),point_.yOff(),texture_,invert_);
2950 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2951 const Magick::Image &texture_,const bool invert_)
2958 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2959 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
2962 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2963 const Magick::Image &texture_,const Magick::Color &borderColor_,
2966 floodFillTexture(point_.xOff(),point_.yOff(),texture_,borderColor_,invert_);
2969 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2970 const Magick::Image &texture_,const Magick::Color &borderColor_,
2978 pixel=static_cast<PixelInfo>(borderColor_);
2979 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
2982 void Magick::Image::flop(void)
2988 newImage=FlopImage(constImage(),exceptionInfo);
2989 replaceImage(newImage);
2993 void Magick::Image::fontTypeMetrics(const std::string &text_,
2994 TypeMetric *metrics)
2999 drawInfo=options()->drawInfo();
3000 drawInfo->text=const_cast<char *>(text_.c_str());
3002 GetTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3007 void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
3008 TypeMetric *metrics)
3013 drawInfo=options()->drawInfo();
3014 drawInfo->text=const_cast<char *>(text_.c_str());
3016 GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3021 void Magick::Image::frame(const Geometry &geometry_)
3029 info.x=static_cast<ssize_t>(geometry_.width());
3030 info.y=static_cast<ssize_t>(geometry_.height());
3031 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3032 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3033 info.outer_bevel=geometry_.xOff();
3034 info.inner_bevel=geometry_.yOff();
3037 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3038 replaceImage(newImage);
3042 void Magick::Image::frame(const size_t width_,const size_t height_,
3043 const ssize_t outerBevel_,const ssize_t innerBevel_)
3051 info.x=static_cast<ssize_t>(width_);
3052 info.y=static_cast<ssize_t>(height_);
3053 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3054 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3055 info.outer_bevel=static_cast<ssize_t>(outerBevel_);
3056 info.inner_bevel=static_cast<ssize_t>(innerBevel_);
3059 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3060 replaceImage(newImage);
3064 void Magick::Image::fx(const std::string expression_)
3070 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3071 replaceImage(newImage);
3075 void Magick::Image::fx(const std::string expression_,
3076 const Magick::ChannelType channel_)
3082 SetPPChannelMask(channel_);
3083 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3084 RestorePPChannelMask;
3085 replaceImage(newImage);
3089 void Magick::Image::gamma(const double gamma_)
3093 GammaImage(image(),gamma_,exceptionInfo);
3097 void Magick::Image::gamma(const double gammaRed_,const double gammaGreen_,
3098 const double gammaBlue_)
3101 gamma[MaxTextExtent + 1];
3103 FormatLocaleString(gamma,MaxTextExtent,"%3.6f/%3.6f/%3.6f/",gammaRed_,
3104 gammaGreen_,gammaBlue_);
3108 GammaImage(image(),atof(gamma),exceptionInfo);
3112 void Magick::Image::gaussianBlur(const double width_,const double sigma_)
3118 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3119 replaceImage(newImage);
3123 void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
3124 const double width_,const double sigma_)
3130 SetPPChannelMask(channel_);
3131 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3132 RestorePPChannelMask;
3133 replaceImage(newImage);
3137 const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
3138 const ssize_t y_,const size_t columns_,const size_t rows_) const
3144 p=(*GetVirtualPixels)(constImage(),x_, y_,columns_, rows_,exceptionInfo);
3149 const void *Magick::Image::getConstMetacontent(void) const
3154 result=GetVirtualMetacontent(constImage());
3157 throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
3162 void *Magick::Image::getMetacontent(void )
3167 result=GetAuthenticMetacontent(image());
3170 throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
3175 Magick::Quantum *Magick::Image::getPixels(const ssize_t x_,const ssize_t y_,
3176 const size_t columns_,const size_t rows_)
3183 result=(*GetAuthenticPixels)(image(),x_, y_,columns_,rows_,exceptionInfo);
3189 void Magick::Image::grayscale(const PixelIntensityMethod method_)
3193 (void) GrayscaleImage(image(),method_,exceptionInfo);
3197 void Magick::Image::haldClut(const Image &clutImage_)
3201 (void) HaldClutImage(image(),clutImage_.constImage(),exceptionInfo);
3205 void Magick::Image::houghLine(const size_t width_,const size_t height_,
3206 const size_t threshold_)
3212 newImage=HoughLineImage(constImage(),width_,height_,threshold_,
3214 replaceImage(newImage);
3218 void Magick::Image::implode(const double factor_)
3224 newImage=ImplodeImage(constImage(),factor_,image()->interpolate,
3226 replaceImage(newImage);
3230 void Magick::Image::inverseFourierTransform(const Image &phase_)
3232 inverseFourierTransform(phase_,true);
3235 void Magick::Image::inverseFourierTransform(const Image &phase_,
3236 const bool magnitude_)
3242 newImage=InverseFourierTransformImage(constImage(),phase_.constImage(),
3243 magnitude_ == true ? MagickTrue : MagickFalse,exceptionInfo);
3244 replaceImage(newImage);
3248 void Magick::Image::kuwahara(const double radius_,const double sigma_)
3254 newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3255 replaceImage(newImage);
3259 void Magick::Image::kuwaharaChannel(const ChannelType channel_,
3260 const double radius_,const double sigma_)
3266 SetPPChannelMask(channel_);
3267 newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3268 replaceImage(newImage);
3269 RestorePPChannelMask;
3273 void Magick::Image::level(const double blackPoint_,const double whitePoint_,
3274 const double gamma_)
3278 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3282 void Magick::Image::levelChannel(const ChannelType channel_,
3283 const double blackPoint_,const double whitePoint_,const double gamma_)
3287 SetPPChannelMask(channel_);
3288 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3289 RestorePPChannelMask;
3293 void Magick::Image::levelColors(const Color &blackColor_,
3294 const Color &whiteColor_,const bool invert_)
3303 GetPixelInfo(image(),&black);
3304 pixel=static_cast<PixelInfo>(blackColor_);
3305 black.red=pixel.red;
3306 black.green=pixel.green;
3307 black.blue=pixel.blue;
3308 black.alpha=pixel.alpha;
3310 GetPixelInfo(image(),&white);
3311 pixel=static_cast<PixelInfo>(whiteColor_);
3312 white.red=pixel.red;
3313 white.green=pixel.green;
3314 white.blue=pixel.blue;
3315 white.alpha=pixel.alpha;
3318 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3319 MagickTrue : MagickFalse,exceptionInfo);
3323 void Magick::Image::levelColorsChannel(const ChannelType channel_,
3324 const Color &blackColor_,const Color &whiteColor_,const bool invert_)
3333 GetPixelInfo(image(),&black);
3334 pixel=static_cast<PixelInfo>(blackColor_);
3335 black.red=pixel.red;
3336 black.green=pixel.green;
3337 black.blue=pixel.blue;
3338 black.alpha=pixel.alpha;
3340 GetPixelInfo(image(),&white);
3341 pixel=static_cast<PixelInfo>(whiteColor_);
3342 white.red=pixel.red;
3343 white.green=pixel.green;
3344 white.blue=pixel.blue;
3345 white.alpha=pixel.alpha;
3348 SetPPChannelMask(channel_);
3349 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3350 MagickTrue : MagickFalse,exceptionInfo);
3351 RestorePPChannelMask;
3355 void Magick::Image::linearStretch(const double blackPoint_,
3356 const double whitePoint_)
3360 LinearStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
3364 void Magick::Image::liquidRescale(const Geometry &geometry_)
3377 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3381 newImage=LiquidRescaleImage(image(),width,height,x,y,exceptionInfo);
3382 replaceImage(newImage);
3386 void Magick::Image::magnify(void)
3392 newImage=MagnifyImage(constImage(),exceptionInfo);
3393 replaceImage(newImage);
3397 void Magick::Image::map(const Image &mapImage_,const bool dither_)
3401 options()->quantizeDither(dither_);
3402 RemapImage(options()->quantizeInfo(),image(),mapImage_.constImage(),
3407 void Magick::Image::medianFilter(const double radius_)
3413 newImage=StatisticImage(image(),MedianStatistic,(size_t) radius_,
3414 (size_t) radius_,exceptionInfo);
3415 replaceImage(newImage);
3419 void Magick::Image::minify(void)
3425 newImage=MinifyImage(constImage(),exceptionInfo);
3426 replaceImage(newImage);
3430 void Magick::Image::modulate(const double brightness_,const double saturation_,
3434 modulate[MaxTextExtent + 1];
3436 FormatLocaleString(modulate,MaxTextExtent,"%3.6f,%3.6f,%3.6f",brightness_,
3441 ModulateImage(image(),modulate,exceptionInfo);
3445 Magick::ImageMoments Magick::Image::moments(void)
3447 return(ImageMoments(constImage()));
3450 void Magick::Image::morphology(const MorphologyMethod method_,
3451 const std::string kernel_,const ssize_t iterations_)
3460 kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3461 if (kernel == (KernelInfo *) NULL)
3462 throwExceptionExplicit(OptionError,"Unable to parse kernel.");
3463 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3465 replaceImage(newImage);
3466 kernel=DestroyKernelInfo(kernel);
3470 void Magick::Image::morphology(const MorphologyMethod method_,
3471 const KernelInfoType kernel_,const std::string arguments_,
3472 const ssize_t iterations_)
3480 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3481 if (option == (const char *)NULL)
3482 throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
3484 kernel=std::string(option);
3485 if (!arguments_.empty())
3486 kernel+=":"+arguments_;
3488 morphology(method_,kernel,iterations_);
3491 void Magick::Image::morphologyChannel(const ChannelType channel_,
3492 const MorphologyMethod method_,const std::string kernel_,
3493 const ssize_t iterations_)
3503 kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3504 if (kernel == (KernelInfo *)NULL)
3505 throwExceptionExplicit(OptionError,"Unable to parse kernel.");
3506 SetPPChannelMask(channel_);
3507 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3509 RestorePPChannelMask;
3510 replaceImage(newImage);
3511 kernel=DestroyKernelInfo(kernel);
3515 void Magick::Image::morphologyChannel(const ChannelType channel_,
3516 const MorphologyMethod method_,const KernelInfoType kernel_,
3517 const std::string arguments_,const ssize_t iterations_)
3525 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3526 if (option == (const char *)NULL)
3527 throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
3529 kernel=std::string(option);
3530 if (!arguments_.empty())
3531 kernel+=":"+arguments_;
3533 morphologyChannel(channel_,method_,kernel,iterations_);
3536 void Magick::Image::motionBlur(const double radius_,const double sigma_,
3537 const double angle_)
3543 newImage=MotionBlurImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
3544 replaceImage(newImage);
3548 void Magick::Image::negate(const bool grayscale_)
3552 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3556 void Magick::Image::negateChannel(const ChannelType channel_,
3557 const bool grayscale_)
3561 SetPPChannelMask(channel_);
3562 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3563 RestorePPChannelMask;
3567 void Magick::Image::normalize(void)
3571 NormalizeImage(image(),exceptionInfo);
3575 void Magick::Image::oilPaint(const double radius_,const double sigma_)
3581 newImage=OilPaintImage(constImage(),radius_,sigma_,exceptionInfo);
3582 replaceImage(newImage);
3586 void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_,
3597 if (!opaqueColor_.isValid())
3598 throwExceptionExplicit(OptionError,"Opaque color argument is invalid");
3600 if (!penColor_.isValid())
3601 throwExceptionExplicit(OptionError,"Pen color argument is invalid");
3604 opaqueColor=opaqueColor_;
3608 (void) QueryColorCompliance(opaqueColor.c_str(),AllCompliance,&opaque,
3610 (void) QueryColorCompliance(penColor.c_str(),AllCompliance,&pen,
3612 OpaquePaintImage(image(),&opaque,&pen,invert_ ? MagickTrue : MagickFalse,
3617 void Magick::Image::orderedDither(std::string thresholdMap_)
3621 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3625 void Magick::Image::orderedDitherChannel(const ChannelType channel_,
3626 std::string thresholdMap_)
3630 SetPPChannelMask(channel_);
3631 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3632 RestorePPChannelMask;
3636 void Magick::Image::perceptible(const double epsilon_)
3640 PerceptibleImage(image(),epsilon_,exceptionInfo);
3644 void Magick::Image::perceptibleChannel(const ChannelType channel_,
3645 const double epsilon_)
3649 SetPPChannelMask(channel_);
3650 PerceptibleImage(image(),epsilon_,exceptionInfo);
3651 RestorePPChannelMask;
3655 Magick::ImagePerceptualHash Magick::Image::perceptualHash()
3657 return(ImagePerceptualHash(constImage()));
3660 void Magick::Image::ping(const std::string &imageSpec_)
3666 options()->fileName(imageSpec_);
3667 newImage=PingImage(imageInfo(),exceptionInfo);
3668 read(newImage,exceptionInfo);
3671 void Magick::Image::ping(const Blob& blob_)
3677 newImage=PingBlob(imageInfo(),blob_.data(),blob_.length(),exceptionInfo);
3678 read(newImage,exceptionInfo);
3681 void Magick::Image::pixelColor(const ssize_t x_,const ssize_t y_,
3682 const Color &color_)
3690 // Test arguments to ensure they are within the image.
3691 if (y_ > (ssize_t) rows() || x_ > (ssize_t) columns())
3692 throwExceptionExplicit(OptionError,"Access outside of image boundary");
3696 // Set image to DirectClass
3697 classType(DirectClass );
3700 Pixels pixels(*this);
3702 pixel=pixels.get(x_, y_, 1, 1 );
3704 MagickCore::SetPixelInfoPixel(constImage(),&packet,pixel);
3705 // Tell ImageMagick that pixels have been updated
3709 Magick::Color Magick::Image::pixelColor(const ssize_t x_,
3710 const ssize_t y_) const
3715 pixel=getConstPixels(x_,y_,1,1);
3721 MagickCore::GetPixelInfoPixel(constImage(),pixel,&packet);
3722 return(Color(packet));
3725 return(Color()); // invalid
3728 void Magick::Image::polaroid(const std::string &caption_,const double angle_,
3729 const PixelInterpolateMethod method_)
3735 newImage=PolaroidImage(constImage(),options()->drawInfo(),caption_.c_str(),
3736 angle_,method_,exceptionInfo);
3737 replaceImage(newImage);
3741 void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
3745 PosterizeImage(image(),levels_,method_,exceptionInfo);
3749 void Magick::Image::posterizeChannel(const ChannelType channel_,
3750 const size_t levels_,const DitherMethod method_)
3754 SetPPChannelMask(channel_);
3755 PosterizeImage(image(),levels_,method_,exceptionInfo);
3756 RestorePPChannelMask;
3760 void Magick::Image::process(std::string name_,const ssize_t argc,
3766 (void) InvokeDynamicImageFilter(name_.c_str(),&image(),argc,argv,
3771 void Magick::Image::profile(const std::string name_,
3772 const Magick::Blob &profile_)
3776 (void) ProfileImage(image(),name_.c_str(),(unsigned char *)profile_.data(),
3777 profile_.length(),exceptionInfo);
3781 Magick::Blob Magick::Image::profile(const std::string name_) const
3786 profile=GetImageProfile(constImage(),name_.c_str());
3788 if (profile == (StringInfo *) NULL)
3790 return(Blob((void*) GetStringInfoDatum(profile),GetStringInfoLength(
3794 void Magick::Image::quantize(const bool measureError_)
3799 options()->quantizeInfo()->measure_error=MagickTrue;
3801 options()->quantizeInfo()->measure_error=MagickFalse;
3804 QuantizeImage(options()->quantizeInfo(),image(),exceptionInfo);
3808 void Magick::Image::quantumOperator(const ChannelType channel_,
3809 const MagickEvaluateOperator operator_,double rvalue_)
3812 SetPPChannelMask(channel_);
3813 EvaluateImage(image(),operator_,rvalue_,exceptionInfo);
3814 RestorePPChannelMask;
3818 void Magick::Image::quantumOperator(const ssize_t x_,const ssize_t y_,
3819 const size_t columns_,const size_t rows_,const ChannelType channel_,
3820 const MagickEvaluateOperator operator_,const double rvalue_)
3828 geometry.width = columns_;
3829 geometry.height = rows_;
3834 cropImage=CropImage(image(),&geometry,exceptionInfo);
3835 SetPPChannelMask(channel_);
3836 EvaluateImage(cropImage,operator_,rvalue_,exceptionInfo);
3837 RestorePPChannelMask;
3838 (void) CompositeImage(image(),cropImage,image()->alpha_trait ==
3839 BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
3840 geometry.x,geometry.y,exceptionInfo );
3841 cropImage=DestroyImageList(cropImage);
3845 void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
3848 raiseInfo=geometry_;
3852 RaiseImage(image(),&raiseInfo,raisedFlag_ == true ? MagickTrue : MagickFalse,
3857 void Magick::Image::randomThreshold(const Geometry &thresholds_)
3860 (void) RandomThresholdImage(image(),static_cast<std::string>(
3861 thresholds_).c_str(),exceptionInfo);
3865 void Magick::Image::randomThresholdChannel(const ChannelType channel_,
3866 const Geometry &thresholds_)
3870 SetPPChannelMask(channel_);
3871 (void) RandomThresholdImage(image(),static_cast<std::string>(
3872 thresholds_).c_str(),exceptionInfo);
3873 RestorePPChannelMask;
3877 void Magick::Image::read(const Blob &blob_)
3883 newImage=BlobToImage(imageInfo(),static_cast<const void *>(blob_.data()),
3884 blob_.length(),exceptionInfo);
3885 read(newImage,exceptionInfo);
3888 void Magick::Image::read(const Blob &blob_,const Geometry &size_)
3894 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3895 const size_t depth_)
3902 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3903 const size_t depth_,const std::string &magick_)
3908 // Set explicit image format
3909 fileName(magick_ + ':');
3913 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3914 const std::string &magick_)
3918 // Set explicit image format
3919 fileName(magick_ + ':');
3923 void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_)
3929 void Magick::Image::read(const size_t width_,const size_t height_,
3930 const std::string &map_,const StorageType type_,const void *pixels_)
3936 newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
3938 replaceImage(newImage);
3942 void Magick::Image::read(const std::string &imageSpec_)
3948 options()->fileName(imageSpec_);
3949 newImage=ReadImage(imageInfo(),exceptionInfo);
3950 read(newImage,exceptionInfo);
3953 void Magick::Image::readPixels(const Magick::QuantumType quantum_,
3954 const unsigned char *source_)
3959 quantum_info=AcquireQuantumInfo(imageInfo(),image());
3961 ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
3962 quantum_,source_,exceptionInfo);
3963 quantum_info=DestroyQuantumInfo(quantum_info);
3967 void Magick::Image::reduceNoise(void)
3972 void Magick::Image::reduceNoise(const double order_)
3978 newImage=StatisticImage(constImage(),NonpeakStatistic,(size_t) order_,
3979 (size_t) order_,exceptionInfo);
3980 replaceImage(newImage);
3984 void Magick::Image::resample(const Geometry &geometry_)
3997 // Calculate new size. This code should be supported using binary arguments
3998 // in the ImageMagick library.
3999 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4003 newImage=ResampleImage(constImage(),width,height,image()->filter,
4005 replaceImage(newImage);
4009 void Magick::Image::resize(const Geometry &geometry_)
4022 // Calculate new size. This code should be supported using binary arguments
4023 // in the ImageMagick library.
4024 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4028 newImage=ResizeImage(constImage(),width,height,image()->filter,
4030 replaceImage(newImage);
4034 void Magick::Image::roll(const Geometry &roll_)
4040 newImage=RollImage(constImage(),roll_.xOff(),roll_.yOff(),exceptionInfo);
4041 replaceImage(newImage);
4045 void Magick::Image::roll(const size_t columns_,const size_t rows_)
4051 newImage=RollImage(constImage(),static_cast<ssize_t>(columns_),
4052 static_cast<ssize_t>(rows_),exceptionInfo);
4053 replaceImage(newImage);
4057 void Magick::Image::rotate(const double degrees_)
4063 newImage=RotateImage(constImage(),degrees_,exceptionInfo);
4064 replaceImage(newImage);
4068 void Magick::Image::rotationalBlur(const double angle_)
4074 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4075 replaceImage(newImage);
4079 void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
4080 const double angle_)
4086 SetPPChannelMask(channel_);
4087 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4088 RestorePPChannelMask;
4089 replaceImage(newImage);
4093 void Magick::Image::sample(const Geometry &geometry_)
4106 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4110 newImage=SampleImage(constImage(),width,height,exceptionInfo);
4111 replaceImage(newImage);
4115 void Magick::Image::scale(const Geometry &geometry_)
4128 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4132 newImage=ScaleImage(constImage(),width,height,exceptionInfo);
4133 replaceImage(newImage);
4137 void Magick::Image::segment(const double clusterThreshold_,
4138 const double smoothingThreshold_)
4142 SegmentImage(image(),options()->quantizeColorSpace(),
4143 (MagickBooleanType) options()->verbose(),clusterThreshold_,
4144 smoothingThreshold_,exceptionInfo);
4145 SyncImage(image(),exceptionInfo);
4149 void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
4150 const double threshold_)
4156 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4158 replaceImage(newImage);
4162 void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
4163 const double radius_,const double sigma_,const double threshold_)
4169 SetPPChannelMask(channel_);
4170 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4172 RestorePPChannelMask;
4173 replaceImage(newImage);
4177 Magick::Image Magick::Image::separate(const ChannelType channel_)
4183 image=SeparateImage(constImage(),channel_,exceptionInfo);
4185 if (image == (MagickCore::Image *) NULL)
4186 return(Magick::Image());
4188 return(Magick::Image(image));
4191 void Magick::Image::sepiaTone(const double threshold_)
4197 newImage=SepiaToneImage(constImage(),threshold_,exceptionInfo);
4198 replaceImage(newImage);
4202 Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
4203 const size_t columns_,const size_t rows_)
4210 result=(*QueueAuthenticPixels)(image(),x_,y_,columns_,rows_,exceptionInfo);
4215 void Magick::Image::shade(const double azimuth_,const double elevation_,
4216 const bool colorShading_)
4222 newImage=ShadeImage(constImage(),colorShading_ == true ?
4223 MagickTrue : MagickFalse,azimuth_,elevation_,exceptionInfo);
4224 replaceImage(newImage);
4228 void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
4229 const ssize_t x_,const ssize_t y_)
4235 newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
4237 replaceImage(newImage);
4241 void Magick::Image::sharpen(const double radius_,const double sigma_)
4247 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4248 replaceImage(newImage);
4252 void Magick::Image::sharpenChannel(const ChannelType channel_,
4253 const double radius_,const double sigma_)
4259 SetPPChannelMask(channel_);
4260 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4261 RestorePPChannelMask;
4262 replaceImage(newImage);
4266 void Magick::Image::shave(const Geometry &geometry_)
4272 shaveInfo=geometry_;
4275 newImage=ShaveImage(constImage(),&shaveInfo,exceptionInfo);
4276 replaceImage(newImage);
4280 void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
4286 newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,exceptionInfo);
4287 replaceImage(newImage);
4291 void Magick::Image::sigmoidalContrast(const size_t sharpen_,
4292 const double contrast,const double midpoint)
4296 (void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
4297 midpoint,exceptionInfo);
4301 std::string Magick::Image::signature(const bool force_) const
4306 Lock(&_imgRef->_mutexLock);
4308 // Re-calculate image signature if necessary
4310 if (force_ || !GetImageProperty(constImage(),"Signature",exceptionInfo) ||
4311 constImage()->taint)
4312 SignatureImage(const_cast<MagickCore::Image *>(constImage()),
4315 property=GetImageProperty(constImage(),"Signature",exceptionInfo);
4318 return(std::string(property));
4321 void Magick::Image::sketch(const double radius_,const double sigma_,
4322 const double angle_)
4328 newImage=SketchImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
4329 replaceImage(newImage);
4333 void Magick::Image::solarize(const double factor_)
4337 SolarizeImage(image(),factor_,exceptionInfo);
4341 void Magick::Image::sparseColor(const ChannelType channel_,
4342 const SparseColorMethod method_,const size_t numberArguments_,
4343 const double *arguments_)
4349 SetPPChannelMask(channel_);
4350 newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
4352 RestorePPChannelMask;
4353 replaceImage(newImage);
4357 void Magick::Image::splice(const Geometry &geometry_)
4363 spliceInfo=geometry_;
4366 newImage=SpliceImage(constImage(),&spliceInfo,exceptionInfo);
4367 replaceImage(newImage);
4371 void Magick::Image::spread(const size_t amount_)
4377 newImage=SpreadImage(constImage(),amount_,image()->interpolate,
4379 replaceImage(newImage);
4383 Magick::ImageStatistics Magick::Image::statistics()
4385 return(ImageStatistics(constImage()));
4388 void Magick::Image::stegano(const Image &watermark_)
4394 newImage=SteganoImage(constImage(),watermark_.constImage(),exceptionInfo);
4395 replaceImage(newImage);
4399 void Magick::Image::stereo(const Image &rightImage_)
4405 newImage=StereoImage(constImage(),rightImage_.constImage(),exceptionInfo);
4406 replaceImage(newImage);
4410 void Magick::Image::strip(void)
4414 StripImage(image(),exceptionInfo);
4418 Magick::Image Magick::Image::subImageSearch(const Image &reference_,
4419 const MetricType metric_,Geometry *offset_,double *similarityMetric_,
4420 const double similarityThreshold)
4429 newImage=SimilarityImage(image(),reference_.constImage(),metric_,
4430 similarityThreshold,&offset,similarityMetric_,exceptionInfo);
4432 if (offset_ != (Geometry *) NULL)
4434 if (newImage == (MagickCore::Image *) NULL)
4435 return(Magick::Image());
4437 return(Magick::Image(newImage));
4440 void Magick::Image::swirl(const double degrees_)
4446 newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
4448 replaceImage(newImage);
4452 void Magick::Image::syncPixels(void)
4455 (void) (*SyncAuthenticPixels)(image(),exceptionInfo);
4459 void Magick::Image::texture(const Image &texture_)
4463 TextureImage(image(),texture_.constImage(),exceptionInfo);
4467 void Magick::Image::threshold(const double threshold_)
4471 BilevelImage(image(),threshold_,exceptionInfo);
4475 void Magick::Image::thumbnail(const Geometry &geometry_)
4488 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4492 newImage=ThumbnailImage(constImage(),width,height,exceptionInfo);
4493 replaceImage(newImage);
4497 void Magick::Image::tint(const std::string opacity_)
4506 color=static_cast<PixelInfo>(constOptions()->fillColor());
4507 newImage=TintImage(constImage(),opacity_.c_str(),&color,exceptionInfo);
4508 replaceImage(newImage);
4512 void Magick::Image::transform(const Geometry &imageGeometry_)
4516 TransformImage(&(image()),0,std::string(imageGeometry_).c_str(),
4521 void Magick::Image::transform(const Geometry &imageGeometry_,
4522 const Geometry &cropGeometry_)
4526 TransformImage(&(image()),std::string(cropGeometry_).c_str(),std::string(
4527 imageGeometry_).c_str(), exceptionInfo);
4531 void Magick::Image::transformOrigin(const double x_,const double y_)
4534 options()->transformOrigin(x_,y_);
4537 void Magick::Image::transformReset(void)
4540 options()->transformReset();
4543 void Magick::Image::transformScale(const double sx_,const double sy_)
4546 options()->transformScale(sx_,sy_);
4549 void Magick::Image::transparent(const Color &color_)
4557 if (!color_.isValid())
4558 throwExceptionExplicit(OptionError,"Color argument is invalid");
4562 (void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
4565 TransparentPaintImage(image(),&target,TransparentAlpha,MagickFalse,
4570 void Magick::Image::transparentChroma(const Color &colorLow_,
4571 const Color &colorHigh_)
4581 if (!colorLow_.isValid() || !colorHigh_.isValid())
4582 throwExceptionExplicit(OptionError,"Color argument is invalid");
4585 colorHigh=colorHigh_;
4588 (void) QueryColorCompliance(colorLow.c_str(),AllCompliance,&targetLow,
4590 (void) QueryColorCompliance(colorHigh.c_str(),AllCompliance,&targetHigh,
4593 TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
4594 MagickFalse,exceptionInfo);
4598 void Magick::Image::transpose(void)
4604 newImage=TransposeImage(constImage(),exceptionInfo);
4605 replaceImage(newImage);
4609 void Magick::Image::transverse(void)
4615 newImage=TransverseImage(constImage(),exceptionInfo);
4616 replaceImage(newImage);
4620 void Magick::Image::trim(void)
4626 newImage=TrimImage(constImage(),exceptionInfo);
4627 replaceImage(newImage);
4631 Magick::Image Magick::Image::uniqueColors(void)
4637 image=UniqueImageColors(constImage(),exceptionInfo);
4639 if (image == (MagickCore::Image *) NULL)
4640 return(Magick::Image());
4642 return(Magick::Image(image));
4645 void Magick::Image::unsharpmask(const double radius_,const double sigma_,
4646 const double amount_,const double threshold_)
4652 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4654 replaceImage(newImage);
4658 void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
4659 const double radius_,const double sigma_,const double amount_,
4660 const double threshold_)
4666 SetPPChannelMask(channel_);
4667 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4669 RestorePPChannelMask;
4670 replaceImage(newImage);
4674 void Magick::Image::vignette(const double radius_,const double sigma_,
4675 const ssize_t x_,const ssize_t y_)
4681 newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,exceptionInfo);
4682 replaceImage(newImage);
4686 void Magick::Image::wave(const double amplitude_,const double wavelength_)
4692 newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
4694 replaceImage(newImage);
4698 void Magick::Image::whiteThreshold(const std::string &threshold_)
4702 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4706 void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
4707 const std::string &threshold_)
4711 SetPPChannelMask(channel_);
4712 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4713 RestorePPChannelMask;
4717 void Magick::Image::write(Blob *blob_)
4727 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4729 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4733 void Magick::Image::write(Blob *blob_,const std::string &magick_)
4744 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4746 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4750 void Magick::Image::write(Blob *blob_,const std::string &magick_,
4751 const size_t depth_)
4763 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4765 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4769 void Magick::Image::write(const ssize_t x_,const ssize_t y_,
4770 const size_t columns_,const size_t rows_,const std::string &map_,
4771 const StorageType type_,void *pixels_)
4774 ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
4779 void Magick::Image::write(const std::string &imageSpec_)
4782 fileName(imageSpec_);
4784 WriteImage(constImageInfo(),image(),exceptionInfo);
4788 void Magick::Image::writePixels(const Magick::QuantumType quantum_,
4789 unsigned char *destination_)
4794 quantum_info=AcquireQuantumInfo(imageInfo(),image());
4796 ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4797 quantum_,destination_, exceptionInfo);
4798 quantum_info=DestroyQuantumInfo(quantum_info);
4802 void Magick::Image::zoom(const Geometry &geometry_)
4815 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4819 newImage=ResizeImage(constImage(),width,height,image()->filter,exceptionInfo);
4820 replaceImage(newImage);
4824 Magick::Image::Image(MagickCore::Image *image_)
4825 : _imgRef(new ImageRef(image_))
4829 MagickCore::Image *&Magick::Image::image(void)
4831 return(_imgRef->image());
4834 const MagickCore::Image *Magick::Image::constImage(void) const
4836 return(_imgRef->image());
4839 MagickCore::ImageInfo *Magick::Image::imageInfo(void)
4841 return(_imgRef->options()->imageInfo());
4844 const MagickCore::ImageInfo *Magick::Image::constImageInfo(void) const
4846 return(_imgRef->options()->imageInfo());
4849 Magick::Options *Magick::Image::options(void)
4851 return(_imgRef->options());
4854 const Magick::Options *Magick::Image::constOptions(void) const
4856 return(_imgRef->options());
4859 MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)
4861 return(_imgRef->options()->quantizeInfo());
4864 const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
4866 return(_imgRef->options()->quantizeInfo());
4869 void Magick::Image::modifyImage(void)
4872 Lock(&_imgRef->_mutexLock);
4873 if (_imgRef->_refCount == 1)
4875 // De-register image and return
4882 replaceImage(CloneImage(image(),0,0,MagickTrue,exceptionInfo));
4886 ssize_t Magick::Image::registerId(void)
4888 Lock(&_imgRef->_mutexLock);
4889 if ( _imgRef->id() < 0)
4895 _imgRef->id(_imgRef->id()+1);
4896 sprintf(id,"%.20g\n",(double) _imgRef->id());
4897 SetImageRegistry(ImageRegistryType,id,image(),exceptionInfo);
4900 return(_imgRef->id());
4903 MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
4909 image = replacement_;
4913 image=AcquireImage(constImageInfo(),exceptionInfo);
4918 Lock(&_imgRef->_mutexLock);
4920 if (_imgRef->_refCount == 1)
4922 // We own the image, just replace it, and de-register
4924 _imgRef->image(image);
4928 // We don't own the image, dereference and replace with copy
4929 --_imgRef->_refCount;
4930 _imgRef=new ImageRef(image,constOptions());
4934 return(_imgRef->_image);
4937 void Magick::Image::unregisterId(void)
4943 void Magick::Image::read(MagickCore::Image *image,
4944 MagickCore::ExceptionInfo *exceptionInfo)
4946 // Ensure that multiple image frames were not read.
4947 if (image != (MagickCore::Image *) NULL &&
4948 image->next != (MagickCore::Image *) NULL)
4953 // Destroy any extra image frames
4955 image->next=(MagickCore::Image *) NULL;
4956 next->previous=(MagickCore::Image *) NULL;
4957 DestroyImageList(next);
4959 replaceImage(image);
4960 if (exceptionInfo->severity == MagickCore::UndefinedException &&
4961 image == (MagickCore::Image *) NULL)
4963 (void) MagickCore::DestroyExceptionInfo(exceptionInfo);
4964 throwExceptionExplicit(ImageWarning,"No image was loaded.");
4969 void Magick::Image::floodFill(const ssize_t x_,const ssize_t y_,
4970 const Magick::Image *fillPattern_,const Magick::Color &fill_,
4971 const MagickCore::PixelInfo *target_,const bool invert_)
4979 // Set drawing fill pattern or fill color
4980 fillColor=options()->fillColor();
4981 fillPattern=(MagickCore::Image *)NULL;
4982 if (options()->fillPattern() != (MagickCore::Image *)NULL)
4985 fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
4990 if (fillPattern_ == (Magick::Image *)NULL)
4992 options()->fillPattern((MagickCore::Image *)NULL);
4993 options()->fillColor(fill_);
4996 options()->fillPattern(fillPattern_->constImage());
4999 (void) FloodfillPaintImage(image(),options()->drawInfo(),
5000 target_,static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),
5001 (MagickBooleanType) invert_,exceptionInfo);
5003 options()->fillColor(fillColor);
5004 options()->fillPattern(fillPattern);