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)
933 text=InterpretImageProperties(imageInfo(),image(),expression.c_str(),
935 std::string text_string(text);
936 if (text != (char *) NULL)
937 text=DestroyString(text);
942 double Magick::Image::gamma(void) const
944 return(constImage()->gamma);
947 Magick::Geometry Magick::Image::geometry(void) const
949 if (constImage()->geometry)
950 return Geometry(constImage()->geometry);
952 throwExceptionExplicit(OptionWarning,"Image does not contain a geometry");
957 void Magick::Image::gifDisposeMethod(
958 const MagickCore::DisposeType disposeMethod_)
961 image()->dispose=disposeMethod_;
964 MagickCore::DisposeType Magick::Image::gifDisposeMethod(void) const
966 return(constImage()->dispose);
969 void Magick::Image::highlightColor(const Color color_)
975 artifact("highlight-color",value);
978 void Magick::Image::iccColorProfile(const Magick::Blob &colorProfile_)
980 profile("icm",colorProfile_);
983 Magick::Blob Magick::Image::iccColorProfile(void) const
988 color_profile=GetImageProfile(constImage(),"icc");
989 if (color_profile == (StringInfo *) NULL)
991 return(Blob(GetStringInfoDatum(color_profile),GetStringInfoLength(
995 void Magick::Image::interlaceType(const Magick::InterlaceType interlace_)
998 image()->interlace=interlace_;
999 options()->interlaceType(interlace_);
1002 Magick::InterlaceType Magick::Image::interlaceType(void) const
1004 return(constImage()->interlace);
1007 void Magick::Image::interpolate(const PixelInterpolateMethod interpolate_)
1010 image()->interpolate=interpolate_;
1013 Magick::PixelInterpolateMethod Magick::Image::interpolate(void) const
1015 return constImage()->interpolate;
1018 void Magick::Image::iptcProfile(const Magick::Blob &iptcProfile_)
1021 if (iptcProfile_.data() != 0)
1026 iptc_profile=AcquireStringInfo(iptcProfile_.length());
1027 SetStringInfoDatum(iptc_profile,(unsigned char *) iptcProfile_.data());
1029 (void) SetImageProfile(image(),"iptc",iptc_profile,exceptionInfo);
1030 iptc_profile=DestroyStringInfo(iptc_profile);
1035 Magick::Blob Magick::Image::iptcProfile(void) const
1040 iptc_profile=GetImageProfile(constImage(),"iptc");
1041 if (iptc_profile == (StringInfo *) NULL)
1043 return(Blob(GetStringInfoDatum(iptc_profile),GetStringInfoLength(
1047 void Magick::Image::isValid(const bool isValid_)
1052 _imgRef=new ImageRef;
1054 else if (!isValid())
1056 // Construct with single-pixel black image to make
1057 // image valid. This is an obvious hack.
1058 size(Geometry(1,1));
1063 bool Magick::Image::isValid(void) const
1065 return rows() && columns();
1068 void Magick::Image::label(const std::string &label_)
1072 (void) SetImageProperty(image(),"Label",NULL,exceptionInfo);
1073 if (label_.length() > 0)
1074 (void) SetImageProperty(image(),"Label",label_.c_str(),exceptionInfo);
1078 std::string Magick::Image::label(void) const
1084 value=GetImageProperty(constImage(),"Label",exceptionInfo);
1088 return(std::string(value));
1090 return(std::string());
1093 void Magick::Image::lowlightColor(const Color color_)
1099 artifact("lowlight-color",value);
1102 void Magick::Image::mask(const Magick::Image &mask_)
1107 if (mask_.isValid())
1108 SetImageMask(image(),mask_.constImage(),exceptionInfo);
1110 SetImageMask(image(),(MagickCore::Image *) NULL,exceptionInfo);
1114 Magick::Image Magick::Image::mask(void) const
1120 image=GetImageMask(constImage(),exceptionInfo);
1123 if (image == (MagickCore::Image *) NULL)
1124 return(Magick::Image());
1126 return(Magick::Image(image));
1129 void Magick::Image::magick(const std::string &magick_)
1133 magick_.copy(image()->magick,sizeof(image()->magick)-1);
1134 image()->magick[magick_.length()]=0;
1136 options()->magick(magick_);
1139 std::string Magick::Image::magick(void) const
1141 if (*(constImage()->magick) != '\0')
1142 return(std::string(constImage()->magick));
1144 return(constOptions()->magick());
1147 double Magick::Image::meanErrorPerPixel(void) const
1149 return(constImage()->error.mean_error_per_pixel);
1152 void Magick::Image::modulusDepth(const size_t depth_)
1156 SetImageDepth(image(),depth_,exceptionInfo);
1158 options()->depth(depth_);
1161 size_t Magick::Image::modulusDepth(void) const
1167 depth=GetImageDepth(constImage(),exceptionInfo);
1172 void Magick::Image::monochrome(const bool monochromeFlag_)
1175 options()->monochrome(monochromeFlag_);
1178 bool Magick::Image::monochrome(void) const
1180 return(constOptions()->monochrome());
1183 Magick::Geometry Magick::Image::montageGeometry(void) const
1185 if (constImage()->montage)
1186 return Magick::Geometry(constImage()->montage);
1188 throwExceptionExplicit(CorruptImageWarning,
1189 "Image does not contain a montage");
1191 return(Magick::Geometry());
1194 double Magick::Image::normalizedMaxError(void) const
1196 return(constImage()->error.normalized_maximum_error);
1199 double Magick::Image::normalizedMeanError(void) const
1201 return(constImage()->error.normalized_mean_error);
1204 void Magick::Image::orientation(const Magick::OrientationType orientation_)
1207 image()->orientation=orientation_;
1210 Magick::OrientationType Magick::Image::orientation(void) const
1212 return(constImage()->orientation);
1215 void Magick::Image::page(const Magick::Geometry &pageSize_)
1218 options()->page(pageSize_);
1219 image()->page=pageSize_;
1222 Magick::Geometry Magick::Image::page(void) const
1224 return(Geometry(constImage()->page.width,constImage()->page.height,
1225 AbsoluteValue(constImage()->page.x),AbsoluteValue(constImage()->page.y)));
1228 void Magick::Image::quality(const size_t quality_)
1231 image()->quality=quality_;
1232 options()->quality(quality_);
1235 size_t Magick::Image::quality(void) const
1237 return(constImage()->quality);
1240 void Magick::Image::quantizeColors(const size_t colors_)
1243 options()->quantizeColors(colors_);
1246 size_t Magick::Image::quantizeColors(void) const
1248 return(constOptions()->quantizeColors());
1251 void Magick::Image::quantizeColorSpace(
1252 const Magick::ColorspaceType colorSpace_)
1255 options()->quantizeColorSpace(colorSpace_);
1258 Magick::ColorspaceType Magick::Image::quantizeColorSpace(void) const
1260 return(constOptions()->quantizeColorSpace());
1263 void Magick::Image::quantizeDither(const bool ditherFlag_)
1266 options()->quantizeDither(ditherFlag_);
1269 bool Magick::Image::quantizeDither(void) const
1271 return(constOptions()->quantizeDither());
1274 void Magick::Image::quantizeDitherMethod(const DitherMethod ditherMethod_)
1277 options()->quantizeDitherMethod(ditherMethod_);
1280 MagickCore::DitherMethod Magick::Image::quantizeDitherMethod(void) const
1282 return(constOptions()->quantizeDitherMethod());
1285 void Magick::Image::quantizeTreeDepth(const size_t treeDepth_)
1288 options()->quantizeTreeDepth(treeDepth_);
1291 size_t Magick::Image::quantizeTreeDepth() const
1293 return(constOptions()->quantizeTreeDepth());
1296 void Magick::Image::renderingIntent(
1297 const Magick::RenderingIntent renderingIntent_)
1300 image()->rendering_intent=renderingIntent_;
1303 Magick::RenderingIntent Magick::Image::renderingIntent(void) const
1305 return(static_cast<Magick::RenderingIntent>(constImage()->rendering_intent));
1308 void Magick::Image::resolutionUnits(
1309 const Magick::ResolutionType resolutionUnits_)
1312 image()->units=resolutionUnits_;
1313 options()->resolutionUnits(resolutionUnits_);
1316 Magick::ResolutionType Magick::Image::resolutionUnits(void) const
1318 return(static_cast<Magick::ResolutionType>(constImage()->units));
1321 size_t Magick::Image::rows(void) const
1323 return(constImage()->rows);
1326 void Magick::Image::scene(const size_t scene_)
1329 image()->scene=scene_;
1332 size_t Magick::Image::scene(void) const
1334 return(constImage()->scene);
1337 void Magick::Image::size(const Geometry &geometry_)
1340 options()->size(geometry_);
1341 image()->rows=geometry_.height();
1342 image()->columns=geometry_.width();
1345 Magick::Geometry Magick::Image::size(void) const
1347 return(Magick::Geometry(constImage()->columns,constImage()->rows));
1350 void Magick::Image::strokeAntiAlias(const bool flag_)
1353 options()->strokeAntiAlias(flag_);
1356 bool Magick::Image::strokeAntiAlias(void) const
1358 return(constOptions()->strokeAntiAlias());
1361 void Magick::Image::strokeColor(const Magick::Color &strokeColor_)
1367 options()->strokeColor(strokeColor_);
1369 artifact("stroke",value);
1372 Magick::Color Magick::Image::strokeColor(void) const
1374 return(constOptions()->strokeColor());
1377 void Magick::Image::strokeDashArray(const double *strokeDashArray_)
1380 options()->strokeDashArray(strokeDashArray_);
1383 const double* Magick::Image::strokeDashArray(void) const
1385 return(constOptions()->strokeDashArray());
1388 void Magick::Image::strokeDashOffset(const double strokeDashOffset_)
1391 options()->strokeDashOffset(strokeDashOffset_);
1394 double Magick::Image::strokeDashOffset(void) const
1396 return(constOptions()->strokeDashOffset());
1399 void Magick::Image::strokeLineCap(const Magick::LineCap lineCap_)
1402 options()->strokeLineCap(lineCap_);
1405 Magick::LineCap Magick::Image::strokeLineCap(void) const
1407 return(constOptions()->strokeLineCap());
1410 void Magick::Image::strokeLineJoin(const Magick::LineJoin lineJoin_)
1413 options()->strokeLineJoin(lineJoin_);
1416 Magick::LineJoin Magick::Image::strokeLineJoin(void) const
1418 return(constOptions()->strokeLineJoin());
1421 void Magick::Image::strokeMiterLimit(const size_t strokeMiterLimit_)
1424 options()->strokeMiterLimit(strokeMiterLimit_);
1427 size_t Magick::Image::strokeMiterLimit(void) const
1429 return(constOptions()->strokeMiterLimit());
1432 void Magick::Image::strokePattern(const Image &strokePattern_)
1435 if(strokePattern_.isValid())
1436 options()->strokePattern(strokePattern_.constImage());
1438 options()->strokePattern(static_cast<MagickCore::Image*>(NULL));
1441 Magick::Image Magick::Image::strokePattern(void) const
1443 // FIXME: This is inordinately innefficient
1444 const MagickCore::Image
1450 tmpTexture=constOptions()->strokePattern();
1458 image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
1459 texture.replaceImage(image);
1465 void Magick::Image::strokeWidth(const double strokeWidth_)
1468 value[MaxTextExtent];
1471 options()->strokeWidth(strokeWidth_);
1472 FormatLocaleString(value,MaxTextExtent,"%.20g",strokeWidth_);
1473 (void) SetImageArtifact(image(),"strokewidth",value);
1476 double Magick::Image::strokeWidth(void) const
1478 return(constOptions()->strokeWidth());
1481 void Magick::Image::subImage(const size_t subImage_)
1484 options()->subImage(subImage_);
1487 size_t Magick::Image::subImage(void) const
1489 return(constOptions()->subImage());
1492 void Magick::Image::subRange(const size_t subRange_)
1495 options()->subRange(subRange_);
1498 size_t Magick::Image::subRange(void) const
1500 return(constOptions()->subRange());
1503 void Magick::Image::textDirection(DirectionType direction_)
1506 options()->textDirection(direction_);
1509 Magick::DirectionType Magick::Image::textDirection(void) const
1511 return(constOptions()->textDirection());
1514 void Magick::Image::textEncoding(const std::string &encoding_)
1517 options()->textEncoding(encoding_);
1520 std::string Magick::Image::textEncoding(void) const
1522 return(constOptions()->textEncoding());
1525 void Magick::Image::textGravity(GravityType gravity_)
1528 options()->textGravity(gravity_);
1531 Magick::GravityType Magick::Image::textGravity(void) const
1533 return(constOptions()->textGravity());
1536 void Magick::Image::textInterlineSpacing(double spacing_)
1539 options()->textInterlineSpacing(spacing_);
1542 double Magick::Image::textInterlineSpacing(void) const
1544 return(constOptions()->textInterlineSpacing());
1547 void Magick::Image::textInterwordSpacing(double spacing_)
1550 options()->textInterwordSpacing(spacing_);
1553 double Magick::Image::textInterwordSpacing(void) const
1555 return(constOptions()->textInterwordSpacing());
1558 void Magick::Image::textKerning(double kerning_)
1561 options()->textKerning(kerning_);
1564 double Magick::Image::textKerning(void) const
1566 return(constOptions()->textKerning());
1569 size_t Magick::Image::totalColors(void) const
1575 colors=GetNumberColors(constImage(),0,exceptionInfo);
1580 void Magick::Image::transformRotation(const double angle_)
1583 options()->transformRotation(angle_);
1586 void Magick::Image::transformSkewX(const double skewx_)
1589 options()->transformSkewX(skewx_);
1592 void Magick::Image::transformSkewY(const double skewy_)
1595 options()->transformSkewY(skewy_);
1598 Magick::ImageType Magick::Image::type(void) const
1600 if (constOptions()->type() != UndefinedType)
1601 return(constOptions()->type());
1602 else if (constImage()->type != UndefinedType)
1603 return(constImage()->type);
1605 return(determineType());
1608 void Magick::Image::type(const Magick::ImageType type_)
1611 options()->type(type_);
1613 SetImageType(image(),type_,exceptionInfo);
1617 void Magick::Image::verbose(const bool verboseFlag_)
1620 options()->verbose(verboseFlag_);
1623 bool Magick::Image::verbose(void) const
1625 return(constOptions()->verbose());
1628 void Magick::Image::view(const std::string &view_)
1631 options()->view(view_);
1634 std::string Magick::Image::view(void) const
1636 return(constOptions()->view());
1639 void Magick::Image::virtualPixelMethod(
1640 const VirtualPixelMethod virtualPixelMethod_)
1644 SetImageVirtualPixelMethod(image(),virtualPixelMethod_,exceptionInfo);
1648 Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod(void) const
1650 return(GetImageVirtualPixelMethod(constImage()));
1653 void Magick::Image::x11Display(const std::string &display_)
1656 options()->x11Display(display_);
1659 std::string Magick::Image::x11Display(void) const
1661 return(constOptions()->x11Display());
1664 double Magick::Image::xResolution(void) const
1666 return(constImage()->resolution.x);
1669 double Magick::Image::yResolution(void) const
1671 return(constImage()->resolution.y);
1674 void Magick::Image::adaptiveBlur(const double radius_,const double sigma_)
1680 newImage=AdaptiveBlurImage(constImage(),radius_,sigma_,exceptionInfo);
1681 replaceImage(newImage);
1685 void Magick::Image::adaptiveResize(const Geometry &geometry_)
1698 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
1702 newImage=AdaptiveResizeImage(constImage(),width,height,exceptionInfo);
1703 replaceImage(newImage);
1707 void Magick::Image::adaptiveSharpen(const double radius_,const double sigma_)
1713 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1714 replaceImage(newImage);
1718 void Magick::Image::adaptiveSharpenChannel(const ChannelType channel_,
1719 const double radius_,const double sigma_ )
1725 SetPPChannelMask(channel_);
1726 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1727 RestorePPChannelMask;
1728 replaceImage(newImage);
1732 void Magick::Image::adaptiveThreshold(const size_t width_,const size_t height_,
1733 const ssize_t offset_)
1740 newImage=AdaptiveThresholdImage(constImage(),width_,height_,offset_,
1742 replaceImage(newImage);
1746 void Magick::Image::addNoise(const NoiseType noiseType_)
1752 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1753 replaceImage(newImage);
1757 void Magick::Image::addNoiseChannel(const ChannelType channel_,
1758 const NoiseType noiseType_)
1764 SetPPChannelMask(channel_);
1765 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1766 RestorePPChannelMask;
1767 replaceImage(newImage);
1771 void Magick::Image::affineTransform(const DrawableAffine &affine_)
1779 _affine.sx=affine_.sx();
1780 _affine.sy=affine_.sy();
1781 _affine.rx=affine_.rx();
1782 _affine.ry=affine_.ry();
1783 _affine.tx=affine_.tx();
1784 _affine.ty=affine_.ty();
1787 newImage=AffineTransformImage(constImage(),&_affine,exceptionInfo);
1788 replaceImage(newImage);
1792 void Magick::Image::alpha(const unsigned int alpha_)
1796 SetImageAlpha(image(),alpha_,exceptionInfo);
1800 void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
1804 SetImageAlphaChannel(image(),alphaOption_,exceptionInfo);
1808 void Magick::Image::annotate(const std::string &text_,
1809 const Geometry &location_)
1811 annotate(text_,location_,NorthWestGravity,0.0);
1814 void Magick::Image::annotate(const std::string &text_,
1815 const Geometry &boundingArea_,const GravityType gravity_)
1817 annotate(text_,boundingArea_,gravity_,0.0);
1820 void Magick::Image::annotate(const std::string &text_,
1821 const Geometry &boundingArea_,const GravityType gravity_,
1822 const double degrees_)
1828 boundingArea[MaxTextExtent];
1835 drawInfo=options()->drawInfo();
1836 drawInfo->text=const_cast<char *>(text_.c_str());
1837 drawInfo->geometry=0;
1839 if (boundingArea_.isValid())
1841 if (boundingArea_.width() == 0 || boundingArea_.height() == 0)
1843 FormatLocaleString(boundingArea,MaxTextExtent,"%+.20g%+.20g",
1844 (double) boundingArea_.xOff(),(double) boundingArea_.yOff());
1848 (void) CopyMagickString(boundingArea,string(boundingArea_).c_str(),
1851 drawInfo->geometry=boundingArea;
1854 drawInfo->gravity=gravity_;
1856 oaffine=drawInfo->affine;
1857 if (degrees_ != 0.0)
1870 current=drawInfo->affine;
1871 affine.sx=cos(DegreesToRadians(fmod(degrees_,360.0)));
1872 affine.rx=sin(DegreesToRadians(fmod(degrees_,360.0)));
1873 affine.ry=(-sin(DegreesToRadians(fmod(degrees_,360.0))));
1874 affine.sy=cos(DegreesToRadians(fmod(degrees_,360.0)));
1876 drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
1877 drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
1878 drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
1879 drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
1880 drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty
1885 AnnotateImage(image(),drawInfo,exceptionInfo);
1887 // Restore original values
1888 drawInfo->affine=oaffine;
1890 drawInfo->geometry=0;
1895 void Magick::Image::annotate(const std::string &text_,
1896 const GravityType gravity_)
1903 drawInfo=options()->drawInfo();
1904 drawInfo->text=const_cast<char *>(text_.c_str());
1905 drawInfo->gravity=gravity_;
1908 AnnotateImage(image(),drawInfo,exceptionInfo);
1910 drawInfo->gravity=NorthWestGravity;
1916 void Magick::Image::artifact(const std::string &name_,const std::string &value_)
1919 (void) SetImageArtifact(image(),name_.c_str(),value_.c_str());
1922 std::string Magick::Image::artifact(const std::string &name_)
1927 value=GetImageArtifact(constImage(),name_.c_str());
1929 return(std::string(value));
1930 return(std::string());
1933 void Magick::Image::attribute(const std::string name_,const std::string value_)
1937 SetImageProperty(image(),name_.c_str(),value_.c_str(),exceptionInfo);
1941 std::string Magick::Image::attribute(const std::string name_)
1947 value=GetImageProperty(constImage(),name_.c_str(),exceptionInfo);
1951 return(std::string(value));
1953 return(std::string()); // Intentionally no exception
1956 void Magick::Image::autoGamma(void)
1960 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1961 (void) AutoGammaImage(image(),exceptionInfo);
1965 void Magick::Image::autoGammaChannel(const ChannelType channel_)
1969 SetPPChannelMask(channel_);
1970 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1971 (void) AutoGammaImage(image(),exceptionInfo);
1972 RestorePPChannelMask;
1976 void Magick::Image::autoLevel(void)
1980 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1981 (void) AutoLevelImage(image(),exceptionInfo);
1985 void Magick::Image::autoLevelChannel(const ChannelType channel_)
1989 SetPPChannelMask(channel_);
1990 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1991 (void) AutoLevelImage(image(),exceptionInfo);
1992 RestorePPChannelMask;
1996 void Magick::Image::autoOrient(void)
2001 if (image()->orientation == UndefinedOrientation ||
2002 image()->orientation == TopLeftOrientation)
2006 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2007 newImage=AutoOrientImage(constImage(),image()->orientation,exceptionInfo);
2008 replaceImage(newImage);
2012 void Magick::Image::blackThreshold(const std::string &threshold_)
2016 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2020 void Magick::Image::blackThresholdChannel(const ChannelType channel_,
2021 const std::string &threshold_)
2025 SetPPChannelMask(channel_);
2026 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2027 RestorePPChannelMask;
2031 void Magick::Image::blueShift(const double factor_)
2037 newImage=BlueShiftImage(constImage(),factor_,exceptionInfo);
2038 replaceImage(newImage);
2042 void Magick::Image::blur(const double radius_,const double sigma_)
2048 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2049 replaceImage(newImage);
2053 void Magick::Image::blurChannel(const ChannelType channel_,
2054 const double radius_,const double sigma_)
2060 SetPPChannelMask(channel_);
2061 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2062 RestorePPChannelMask;
2063 replaceImage(newImage);
2067 void Magick::Image::border(const Geometry &geometry_)
2073 borderInfo=geometry_;
2076 newImage=BorderImage(constImage(),&borderInfo,image()->compose,
2078 replaceImage(newImage);
2082 void Magick::Image::brightnessContrast(const double brightness_,
2083 const double contrast_)
2087 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2091 void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
2092 const double brightness_,const double contrast_)
2096 SetPPChannelMask(channel_);
2097 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2098 RestorePPChannelMask;
2102 void Magick::Image::cannyEdge(const double radius_,const double sigma_,
2103 const double lowerPercent_,const double upperPercent_)
2110 newImage=CannyEdgeImage(constImage(),radius_,sigma_,lowerPercent_,
2111 upperPercent_,exceptionInfo);
2112 replaceImage(newImage);
2116 void Magick::Image::channel(const ChannelType channel_)
2122 newImage=SeparateImage(image(),channel_,exceptionInfo);
2123 replaceImage(newImage);
2127 void Magick::Image::charcoal(const double radius_,const double sigma_)
2133 newImage=CharcoalImage(image(),radius_,sigma_,exceptionInfo);
2134 replaceImage(newImage);
2138 void Magick::Image::chop(const Geometry &geometry_)
2147 newImage=ChopImage(image(),&chopInfo,exceptionInfo);
2148 replaceImage(newImage);
2152 void Magick::Image::chromaBluePrimary(const double x_,const double y_)
2155 image()->chromaticity.blue_primary.x=x_;
2156 image()->chromaticity.blue_primary.y=y_;
2159 void Magick::Image::chromaBluePrimary(double *x_,double *y_) const
2161 *x_=constImage()->chromaticity.blue_primary.x;
2162 *y_=constImage()->chromaticity.blue_primary.y;
2165 void Magick::Image::chromaGreenPrimary(const double x_,const double y_)
2168 image()->chromaticity.green_primary.x=x_;
2169 image()->chromaticity.green_primary.y=y_;
2172 void Magick::Image::chromaGreenPrimary(double *x_,double *y_) const
2174 *x_=constImage()->chromaticity.green_primary.x;
2175 *y_=constImage()->chromaticity.green_primary.y;
2178 void Magick::Image::chromaRedPrimary(const double x_,const double y_)
2181 image()->chromaticity.red_primary.x=x_;
2182 image()->chromaticity.red_primary.y=y_;
2185 void Magick::Image::chromaRedPrimary(double *x_,double *y_) const
2187 *x_=constImage()->chromaticity.red_primary.x;
2188 *y_=constImage()->chromaticity.red_primary.y;
2191 void Magick::Image::chromaWhitePoint(const double x_,const double y_)
2194 image()->chromaticity.white_point.x=x_;
2195 image()->chromaticity.white_point.y=y_;
2198 void Magick::Image::chromaWhitePoint(double *x_,double *y_) const
2200 *x_=constImage()->chromaticity.white_point.x;
2201 *y_=constImage()->chromaticity.white_point.y;
2204 void Magick::Image::cdl(const std::string &cdl_)
2208 (void) ColorDecisionListImage(image(),cdl_.c_str(),exceptionInfo);
2212 void Magick::Image::clamp(void)
2216 ClampImage(image(),exceptionInfo);
2220 void Magick::Image::clampChannel(const ChannelType channel_)
2224 SetPPChannelMask(channel_);
2225 ClampImage(image(),exceptionInfo);
2226 RestorePPChannelMask;
2230 void Magick::Image::clip(void)
2234 ClipImage(image(),exceptionInfo);
2238 void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
2242 ClipImagePath(image(),pathname_.c_str(),(MagickBooleanType) inside_,
2247 void Magick::Image::clut(const Image &clutImage_,
2248 const PixelInterpolateMethod method)
2252 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2256 void Magick::Image::clutChannel(const ChannelType channel_,
2257 const Image &clutImage_,const PixelInterpolateMethod method)
2261 SetPPChannelMask(channel_);
2262 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2263 RestorePPChannelMask;
2267 void Magick::Image::colorize(const unsigned int alpha_,const Color &penColor_)
2269 colorize(alpha_,alpha_,alpha_,penColor_);
2272 void Magick::Image::colorize(const unsigned int alphaRed_,
2273 const unsigned int alphaGreen_,const unsigned int alphaBlue_,
2274 const Color &penColor_)
2277 blend[MaxTextExtent];
2286 if (!penColor_.isValid())
2287 throwExceptionExplicit(OptionError,"Pen color argument is invalid");
2289 FormatLocaleString(blend,MaxTextExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
2292 GetPixelInfo(image(),&target);
2293 pixel=static_cast<PixelInfo>(penColor_);
2294 target.red=pixel.red;
2295 target.green=pixel.green;
2296 target.blue=pixel.blue;
2297 target.alpha=pixel.alpha;
2299 newImage=ColorizeImage(image(),blend,&target,exceptionInfo);
2300 replaceImage(newImage);
2304 void Magick::Image::colorMap(const size_t index_,const Color &color_)
2311 if (index_ > (MaxColormapSize-1))
2312 throwExceptionExplicit(OptionError,
2313 "Colormap index must be less than MaxColormapSize");
2315 if (!color_.isValid())
2316 throwExceptionExplicit(OptionError,"Color argument is invalid");
2320 // Ensure that colormap size is large enough
2321 if (colorMapSize() < (index_+1))
2322 colorMapSize(index_+1);
2324 // Set color at index in colormap
2325 (imageptr->colormap)[index_]=color_;
2328 Magick::Color Magick::Image::colorMap(const size_t index_) const
2330 if (!constImage()->colormap)
2332 throwExceptionExplicit(OptionError,"Image does not contain a colormap");
2336 if (index_ > constImage()->colors-1)
2337 throwExceptionExplicit(OptionError,"Index out of range");
2339 return(Magick::Color((constImage()->colormap)[index_]));
2342 void Magick::Image::colorMatrix(const size_t order_,
2343 const double *color_matrix_)
2349 kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2350 if (kernel_info != (KernelInfo *) NULL)
2352 kernel_info->width=order_;
2353 kernel_info->height=order_;
2354 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2355 order_*sizeof(*kernel_info->values));
2356 if (kernel_info->values != (MagickRealType *) NULL)
2361 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2362 kernel_info->values[i]=color_matrix_[i];
2363 newImage=ColorMatrixImage(image(),kernel_info,exceptionInfo);
2364 replaceImage(newImage);
2366 kernel_info=DestroyKernelInfo(kernel_info);
2371 bool Magick::Image::compare(const Image &reference_)
2382 status=static_cast<bool>(IsImagesEqual(image(),ref.image(),exceptionInfo));
2387 double Magick::Image::compare(const Image &reference_,const MetricType metric_)
2393 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2399 double Magick::Image::compareChannel(const ChannelType channel_,
2400 const Image &reference_,const MetricType metric_)
2406 SetPPChannelMask(channel_);
2407 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2409 RestorePPChannelMask;
2414 Magick::Image Magick::Image::compare(const Image &reference_,
2415 const MetricType metric_,double *distortion)
2421 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2424 if (newImage == (MagickCore::Image *) NULL)
2425 return(Magick::Image());
2427 return(Magick::Image(newImage));
2430 Magick::Image Magick::Image::compareChannel(const ChannelType channel_,
2431 const Image &reference_,const MetricType metric_,double *distortion)
2437 SetPPChannelMask(channel_);
2438 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2440 RestorePPChannelMask;
2442 if (newImage == (MagickCore::Image *) NULL)
2443 return(Magick::Image());
2445 return(Magick::Image(newImage));
2448 void Magick::Image::composite(const Image &compositeImage_,
2449 const Geometry &offset_,const CompositeOperator compose_)
2459 ParseMetaGeometry(static_cast<std::string>(offset_).c_str(),&x,&y,&width,
2464 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2469 void Magick::Image::composite(const Image &compositeImage_,
2470 const GravityType gravity_,const CompositeOperator compose_)
2476 SetGeometry(compositeImage_.constImage(),&geometry);
2477 GravityAdjustGeometry(columns(),rows(),gravity_,&geometry);
2480 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2481 geometry.x,geometry.y,exceptionInfo);
2485 void Magick::Image::composite(const Image &compositeImage_,
2486 const ssize_t xOffset_,const ssize_t yOffset_,
2487 const CompositeOperator compose_)
2489 // Image supplied as compositeImage is composited with current image and
2490 // results in updating current image.
2493 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2494 xOffset_,yOffset_,exceptionInfo);
2498 void Magick::Image::contrast(const size_t sharpen_)
2502 ContrastImage(image(),(MagickBooleanType) sharpen_,exceptionInfo);
2506 void Magick::Image::contrastStretch(const double blackPoint_,
2507 const double whitePoint_)
2511 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2515 void Magick::Image::contrastStretchChannel(const ChannelType channel_,
2516 const double blackPoint_,const double whitePoint_)
2520 SetPPChannelMask(channel_);
2521 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2522 RestorePPChannelMask;
2526 void Magick::Image::convolve(const size_t order_,const double *kernel_)
2532 kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2533 kernel_info->width=order_;
2534 kernel_info->height=order_;
2535 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2536 order_*sizeof(*kernel_info->values));
2537 if (kernel_info->values != (MagickRealType *) NULL)
2542 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2543 kernel_info->values[i]=kernel_[i];
2544 newImage=ConvolveImage(image(),kernel_info,exceptionInfo);
2545 replaceImage(newImage);
2547 kernel_info=DestroyKernelInfo(kernel_info);
2551 void Magick::Image::crop(const Geometry &geometry_)
2560 newImage=CropImage(constImage(),&cropInfo,exceptionInfo);
2561 replaceImage(newImage);
2565 void Magick::Image::cycleColormap(const ssize_t amount_)
2569 CycleColormapImage(image(),amount_,exceptionInfo);
2573 void Magick::Image::decipher(const std::string &passphrase_)
2577 DecipherImage(image(),passphrase_.c_str(),exceptionInfo);
2581 void Magick::Image::defineSet(const std::string &magick_,
2582 const std::string &key_,bool flag_)
2588 definition=magick_ + ":" + key_;
2590 (void) SetImageOption(imageInfo(),definition.c_str(),"");
2592 DeleteImageOption(imageInfo(),definition.c_str());
2595 bool Magick::Image::defineSet(const std::string &magick_,
2596 const std::string &key_ ) const
2604 key=magick_ + ":" + key_;
2605 option=GetImageOption(constImageInfo(),key.c_str());
2611 void Magick::Image::defineValue(const std::string &magick_,
2612 const std::string &key_,const std::string &value_)
2619 format=magick_ + ":" + key_;
2621 (void) SetImageOption(imageInfo(),format.c_str(),option.c_str());
2624 std::string Magick::Image::defineValue(const std::string &magick_,
2625 const std::string &key_) const
2633 definition=magick_ + ":" + key_;
2634 option=GetImageOption(constImageInfo(),definition.c_str());
2636 return(std::string(option));
2637 return(std::string());
2640 void Magick::Image::deskew(const double threshold_)
2646 newImage=DeskewImage(constImage(),threshold_,exceptionInfo);
2647 replaceImage(newImage);
2651 void Magick::Image::despeckle(void)
2657 newImage=DespeckleImage(constImage(),exceptionInfo);
2658 replaceImage(newImage);
2662 Magick::ImageType Magick::Image::determineType(void) const
2668 image_type=GetImageType(constImage(),exceptionInfo);
2673 void Magick::Image::display(void)
2676 DisplayImages(imageInfo(),image(),exceptionInfo);
2680 void Magick::Image::distort(const DistortImageMethod method_,
2681 const size_t numberArguments_,const double *arguments_,const bool bestfit_)
2687 newImage=DistortImage(constImage(), method_,numberArguments_,arguments_,
2688 bestfit_ == true ? MagickTrue : MagickFalse,exceptionInfo);
2689 replaceImage(newImage);
2693 void Magick::Image::draw(const Magick::Drawable &drawable_)
2700 wand=DrawAllocateWand(options()->drawInfo(),image());
2704 drawable_.operator()(wand);
2708 ClonePPDrawException(wand);
2709 wand=DestroyDrawingWand(wand);
2710 ThrowPPDrawException;
2714 void Magick::Image::draw(const std::list<Magick::Drawable> &drawable_)
2721 wand=DrawAllocateWand(options()->drawInfo(),image());
2725 for (std::list<Magick::Drawable>::const_iterator p = drawable_.begin();
2726 p != drawable_.end(); p++ )
2728 p->operator()(wand);
2729 if (DrawGetExceptionType(wand) != UndefinedException)
2733 if (DrawGetExceptionType(wand) == UndefinedException)
2736 ClonePPDrawException(wand);
2737 wand=DestroyDrawingWand(wand);
2738 ThrowPPDrawException;
2742 void Magick::Image::edge(const double radius_)
2748 newImage=EdgeImage(constImage(),radius_,exceptionInfo);
2749 replaceImage(newImage);
2753 void Magick::Image::emboss(const double radius_,const double sigma_)
2759 newImage=EmbossImage(constImage(),radius_,sigma_,exceptionInfo);
2760 replaceImage(newImage);
2764 void Magick::Image::encipher(const std::string &passphrase_)
2768 EncipherImage(image(),passphrase_.c_str(),exceptionInfo);
2772 void Magick::Image::enhance(void)
2778 newImage=EnhanceImage(constImage(),exceptionInfo);
2779 replaceImage(newImage);
2783 void Magick::Image::equalize(void)
2787 EqualizeImage(image(),exceptionInfo);
2791 void Magick::Image::erase(void)
2795 (void) SetImageBackgroundColor(image(),exceptionInfo);
2799 void Magick::Image::extent(const Geometry &geometry_ )
2805 extentInfo=geometry_;
2808 extentInfo.x=geometry_.xOff();
2809 extentInfo.y=geometry_.yOff();
2811 newImage=ExtentImage(image(),&extentInfo,exceptionInfo);
2812 replaceImage(newImage);
2816 void Magick::Image::extent(const Geometry &geometry_,
2817 const Color &backgroundColor_)
2819 backgroundColor(backgroundColor_);
2823 void Magick::Image::extent(const Geometry &geometry_,
2824 const Color &backgroundColor_,const GravityType gravity_)
2826 backgroundColor(backgroundColor_);
2827 extent(geometry_,gravity_);
2830 void Magick::Image::extent(const Geometry &geometry_,
2831 const GravityType gravity_)
2836 SetGeometry(image(),&geometry);
2837 geometry.width=geometry_.width();
2838 geometry.height=geometry_.height();
2839 GravityAdjustGeometry(image()->columns,image()->rows,gravity_,&geometry);
2843 void Magick::Image::flip(void)
2849 newImage=FlipImage(constImage(),exceptionInfo);
2850 replaceImage(newImage);
2854 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2855 const unsigned int alpha_,const bool invert_)
2863 GetPixelInfo(constImage(),&target);
2864 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2865 target.red=pixel.red;
2866 target.green=pixel.green;
2867 target.blue=pixel.blue;
2868 target.alpha=alpha_;
2870 SetPPChannelMask(AlphaChannel);
2871 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2872 (MagickBooleanType)invert_,exceptionInfo);
2873 RestorePPChannelMask;
2877 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2878 const unsigned int alpha_,const Color &target_,const bool invert_)
2886 GetPixelInfo(constImage(),&target);
2887 pixel=static_cast<PixelInfo>(target_);
2888 target.red=pixel.red;
2889 target.green=pixel.green;
2890 target.blue=pixel.blue;
2891 target.alpha=alpha_;
2893 SetPPChannelMask(AlphaChannel);
2894 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2895 (MagickBooleanType)invert_,exceptionInfo);
2896 RestorePPChannelMask;
2900 void Magick::Image::floodFillColor(const Geometry &point_,
2901 const Magick::Color &fillColor_,const bool invert_)
2903 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,invert_);
2906 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2907 const Magick::Color &fillColor_,const bool invert_)
2914 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2915 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2918 void Magick::Image::floodFillColor(const Geometry &point_,
2919 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2922 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,borderColor_,invert_);
2925 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2926 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2934 pixel=static_cast<PixelInfo>(borderColor_);
2935 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2938 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2939 const Magick::Image &texture_,const bool invert_)
2941 floodFillTexture(point_.xOff(),point_.yOff(),texture_,invert_);
2944 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2945 const Magick::Image &texture_,const bool invert_)
2952 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2953 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
2956 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2957 const Magick::Image &texture_,const Magick::Color &borderColor_,
2960 floodFillTexture(point_.xOff(),point_.yOff(),texture_,borderColor_,invert_);
2963 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2964 const Magick::Image &texture_,const Magick::Color &borderColor_,
2972 pixel=static_cast<PixelInfo>(borderColor_);
2973 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
2976 void Magick::Image::flop(void)
2982 newImage=FlopImage(constImage(),exceptionInfo);
2983 replaceImage(newImage);
2987 void Magick::Image::fontTypeMetrics(const std::string &text_,
2988 TypeMetric *metrics)
2993 drawInfo=options()->drawInfo();
2994 drawInfo->text=const_cast<char *>(text_.c_str());
2996 GetTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3001 void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
3002 TypeMetric *metrics)
3007 drawInfo=options()->drawInfo();
3008 drawInfo->text=const_cast<char *>(text_.c_str());
3010 GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3015 void Magick::Image::frame(const Geometry &geometry_)
3023 info.x=static_cast<ssize_t>(geometry_.width());
3024 info.y=static_cast<ssize_t>(geometry_.height());
3025 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3026 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3027 info.outer_bevel=geometry_.xOff();
3028 info.inner_bevel=geometry_.yOff();
3031 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3032 replaceImage(newImage);
3036 void Magick::Image::frame(const size_t width_,const size_t height_,
3037 const ssize_t outerBevel_,const ssize_t innerBevel_)
3045 info.x=static_cast<ssize_t>(width_);
3046 info.y=static_cast<ssize_t>(height_);
3047 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3048 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3049 info.outer_bevel=static_cast<ssize_t>(outerBevel_);
3050 info.inner_bevel=static_cast<ssize_t>(innerBevel_);
3053 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3054 replaceImage(newImage);
3058 void Magick::Image::fx(const std::string expression_)
3064 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3065 replaceImage(newImage);
3069 void Magick::Image::fx(const std::string expression_,
3070 const Magick::ChannelType channel_)
3076 SetPPChannelMask(channel_);
3077 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3078 RestorePPChannelMask;
3079 replaceImage(newImage);
3083 void Magick::Image::gamma(const double gamma_)
3087 GammaImage(image(),gamma_,exceptionInfo);
3091 void Magick::Image::gamma(const double gammaRed_,const double gammaGreen_,
3092 const double gammaBlue_)
3095 gamma[MaxTextExtent + 1];
3097 FormatLocaleString(gamma,MaxTextExtent,"%3.6f/%3.6f/%3.6f/",gammaRed_,
3098 gammaGreen_,gammaBlue_);
3102 GammaImage(image(),atof(gamma),exceptionInfo);
3106 void Magick::Image::gaussianBlur(const double width_,const double sigma_)
3112 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3113 replaceImage(newImage);
3117 void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
3118 const double width_,const double sigma_)
3124 SetPPChannelMask(channel_);
3125 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3126 RestorePPChannelMask;
3127 replaceImage(newImage);
3131 const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
3132 const ssize_t y_,const size_t columns_,const size_t rows_) const
3138 p=(*GetVirtualPixels)(constImage(),x_, y_,columns_, rows_,exceptionInfo);
3143 const void *Magick::Image::getConstMetacontent(void) const
3148 result=GetVirtualMetacontent(constImage());
3151 throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
3156 void *Magick::Image::getMetacontent(void )
3161 result=GetAuthenticMetacontent(image());
3164 throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
3169 Magick::Quantum *Magick::Image::getPixels(const ssize_t x_,const ssize_t y_,
3170 const size_t columns_,const size_t rows_)
3177 result=(*GetAuthenticPixels)(image(),x_, y_,columns_,rows_,exceptionInfo);
3183 void Magick::Image::grayscale(const PixelIntensityMethod method_)
3187 (void) GrayscaleImage(image(),method_,exceptionInfo);
3191 void Magick::Image::haldClut(const Image &clutImage_)
3195 (void) HaldClutImage(image(),clutImage_.constImage(),exceptionInfo);
3199 void Magick::Image::houghLine(const size_t width_,const size_t height_,
3200 const size_t threshold_)
3206 newImage=HoughLineImage(constImage(),width_,height_,threshold_,
3208 replaceImage(newImage);
3212 void Magick::Image::implode(const double factor_)
3218 newImage=ImplodeImage(constImage(),factor_,image()->interpolate,
3220 replaceImage(newImage);
3224 void Magick::Image::inverseFourierTransform(const Image &phase_)
3226 inverseFourierTransform(phase_,true);
3229 void Magick::Image::inverseFourierTransform(const Image &phase_,
3230 const bool magnitude_)
3236 newImage=InverseFourierTransformImage(constImage(),phase_.constImage(),
3237 magnitude_ == true ? MagickTrue : MagickFalse,exceptionInfo);
3238 replaceImage(newImage);
3242 void Magick::Image::kuwahara(const double radius_,const double sigma_)
3248 newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3249 replaceImage(newImage);
3253 void Magick::Image::kuwaharaChannel(const ChannelType channel_,
3254 const double radius_,const double sigma_)
3260 SetPPChannelMask(channel_);
3261 newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3262 replaceImage(newImage);
3263 RestorePPChannelMask;
3267 void Magick::Image::level(const double blackPoint_,const double whitePoint_,
3268 const double gamma_)
3272 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3276 void Magick::Image::levelChannel(const ChannelType channel_,
3277 const double blackPoint_,const double whitePoint_,const double gamma_)
3281 SetPPChannelMask(channel_);
3282 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3283 RestorePPChannelMask;
3287 void Magick::Image::levelColors(const Color &blackColor_,
3288 const Color &whiteColor_,const bool invert_)
3297 GetPixelInfo(image(),&black);
3298 pixel=static_cast<PixelInfo>(blackColor_);
3299 black.red=pixel.red;
3300 black.green=pixel.green;
3301 black.blue=pixel.blue;
3302 black.alpha=pixel.alpha;
3304 GetPixelInfo(image(),&white);
3305 pixel=static_cast<PixelInfo>(whiteColor_);
3306 white.red=pixel.red;
3307 white.green=pixel.green;
3308 white.blue=pixel.blue;
3309 white.alpha=pixel.alpha;
3312 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3313 MagickTrue : MagickFalse,exceptionInfo);
3317 void Magick::Image::levelColorsChannel(const ChannelType channel_,
3318 const Color &blackColor_,const Color &whiteColor_,const bool invert_)
3327 GetPixelInfo(image(),&black);
3328 pixel=static_cast<PixelInfo>(blackColor_);
3329 black.red=pixel.red;
3330 black.green=pixel.green;
3331 black.blue=pixel.blue;
3332 black.alpha=pixel.alpha;
3334 GetPixelInfo(image(),&white);
3335 pixel=static_cast<PixelInfo>(whiteColor_);
3336 white.red=pixel.red;
3337 white.green=pixel.green;
3338 white.blue=pixel.blue;
3339 white.alpha=pixel.alpha;
3342 SetPPChannelMask(channel_);
3343 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3344 MagickTrue : MagickFalse,exceptionInfo);
3345 RestorePPChannelMask;
3349 void Magick::Image::linearStretch(const double blackPoint_,
3350 const double whitePoint_)
3354 LinearStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
3358 void Magick::Image::liquidRescale(const Geometry &geometry_)
3371 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3375 newImage=LiquidRescaleImage(image(),width,height,x,y,exceptionInfo);
3376 replaceImage(newImage);
3380 void Magick::Image::magnify(void)
3386 newImage=MagnifyImage(constImage(),exceptionInfo);
3387 replaceImage(newImage);
3391 void Magick::Image::map(const Image &mapImage_,const bool dither_)
3395 options()->quantizeDither(dither_);
3396 RemapImage(options()->quantizeInfo(),image(),mapImage_.constImage(),
3401 void Magick::Image::medianFilter(const double radius_)
3407 newImage=StatisticImage(image(),MedianStatistic,(size_t) radius_,
3408 (size_t) radius_,exceptionInfo);
3409 replaceImage(newImage);
3413 void Magick::Image::minify(void)
3419 newImage=MinifyImage(constImage(),exceptionInfo);
3420 replaceImage(newImage);
3424 void Magick::Image::modulate(const double brightness_,const double saturation_,
3428 modulate[MaxTextExtent + 1];
3430 FormatLocaleString(modulate,MaxTextExtent,"%3.6f,%3.6f,%3.6f",brightness_,
3435 ModulateImage(image(),modulate,exceptionInfo);
3439 Magick::ImageMoments Magick::Image::moments(void)
3441 return(ImageMoments(constImage()));
3444 void Magick::Image::morphology(const MorphologyMethod method_,
3445 const std::string kernel_,const ssize_t iterations_)
3454 kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3455 if (kernel == (KernelInfo *) NULL)
3456 throwExceptionExplicit(OptionError,"Unable to parse kernel.");
3457 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3459 replaceImage(newImage);
3460 kernel=DestroyKernelInfo(kernel);
3464 void Magick::Image::morphology(const MorphologyMethod method_,
3465 const KernelInfoType kernel_,const std::string arguments_,
3466 const ssize_t iterations_)
3474 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3475 if (option == (const char *)NULL)
3476 throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
3478 kernel=std::string(option);
3479 if (!arguments_.empty())
3480 kernel+=":"+arguments_;
3482 morphology(method_,kernel,iterations_);
3485 void Magick::Image::morphologyChannel(const ChannelType channel_,
3486 const MorphologyMethod method_,const std::string kernel_,
3487 const ssize_t iterations_)
3497 kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3498 if (kernel == (KernelInfo *)NULL)
3499 throwExceptionExplicit(OptionError,"Unable to parse kernel.");
3500 SetPPChannelMask(channel_);
3501 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3503 RestorePPChannelMask;
3504 replaceImage(newImage);
3505 kernel=DestroyKernelInfo(kernel);
3509 void Magick::Image::morphologyChannel(const ChannelType channel_,
3510 const MorphologyMethod method_,const KernelInfoType kernel_,
3511 const std::string arguments_,const ssize_t iterations_)
3519 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3520 if (option == (const char *)NULL)
3521 throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
3523 kernel=std::string(option);
3524 if (!arguments_.empty())
3525 kernel+=":"+arguments_;
3527 morphologyChannel(channel_,method_,kernel,iterations_);
3530 void Magick::Image::motionBlur(const double radius_,const double sigma_,
3531 const double angle_)
3537 newImage=MotionBlurImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
3538 replaceImage(newImage);
3542 void Magick::Image::negate(const bool grayscale_)
3546 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3550 void Magick::Image::negateChannel(const ChannelType channel_,
3551 const bool grayscale_)
3555 SetPPChannelMask(channel_);
3556 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3557 RestorePPChannelMask;
3561 void Magick::Image::normalize(void)
3565 NormalizeImage(image(),exceptionInfo);
3569 void Magick::Image::oilPaint(const double radius_,const double sigma_)
3575 newImage=OilPaintImage(constImage(),radius_,sigma_,exceptionInfo);
3576 replaceImage(newImage);
3580 void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_,
3591 if (!opaqueColor_.isValid())
3592 throwExceptionExplicit(OptionError,"Opaque color argument is invalid");
3594 if (!penColor_.isValid())
3595 throwExceptionExplicit(OptionError,"Pen color argument is invalid");
3598 opaqueColor=opaqueColor_;
3602 (void) QueryColorCompliance(opaqueColor.c_str(),AllCompliance,&opaque,
3604 (void) QueryColorCompliance(penColor.c_str(),AllCompliance,&pen,
3606 OpaquePaintImage(image(),&opaque,&pen,invert_ ? MagickTrue : MagickFalse,
3611 void Magick::Image::orderedDither(std::string thresholdMap_)
3615 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3619 void Magick::Image::orderedDitherChannel(const ChannelType channel_,
3620 std::string thresholdMap_)
3624 SetPPChannelMask(channel_);
3625 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3626 RestorePPChannelMask;
3630 void Magick::Image::perceptible(const double epsilon_)
3634 PerceptibleImage(image(),epsilon_,exceptionInfo);
3638 void Magick::Image::perceptibleChannel(const ChannelType channel_,
3639 const double epsilon_)
3643 SetPPChannelMask(channel_);
3644 PerceptibleImage(image(),epsilon_,exceptionInfo);
3645 RestorePPChannelMask;
3649 Magick::ImagePerceptualHash Magick::Image::perceptualHash()
3651 return(ImagePerceptualHash(constImage()));
3654 void Magick::Image::ping(const std::string &imageSpec_)
3660 options()->fileName(imageSpec_);
3661 newImage=PingImage(imageInfo(),exceptionInfo);
3662 read(newImage,exceptionInfo);
3665 void Magick::Image::ping(const Blob& blob_)
3671 newImage=PingBlob(imageInfo(),blob_.data(),blob_.length(),exceptionInfo);
3672 read(newImage,exceptionInfo);
3675 void Magick::Image::pixelColor(const ssize_t x_,const ssize_t y_,
3676 const Color &color_)
3684 // Test arguments to ensure they are within the image.
3685 if (y_ > (ssize_t) rows() || x_ > (ssize_t) columns())
3686 throwExceptionExplicit(OptionError,"Access outside of image boundary");
3690 // Set image to DirectClass
3691 classType(DirectClass );
3694 Pixels pixels(*this);
3696 pixel=pixels.get(x_, y_, 1, 1 );
3698 MagickCore::SetPixelInfoPixel(constImage(),&packet,pixel);
3699 // Tell ImageMagick that pixels have been updated
3703 Magick::Color Magick::Image::pixelColor(const ssize_t x_,
3704 const ssize_t y_) const
3709 pixel=getConstPixels(x_,y_,1,1);
3715 MagickCore::GetPixelInfoPixel(constImage(),pixel,&packet);
3716 return(Color(packet));
3719 return(Color()); // invalid
3722 void Magick::Image::polaroid(const std::string &caption_,const double angle_,
3723 const PixelInterpolateMethod method_)
3729 newImage=PolaroidImage(constImage(),options()->drawInfo(),caption_.c_str(),
3730 angle_,method_,exceptionInfo);
3731 replaceImage(newImage);
3735 void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
3739 PosterizeImage(image(),levels_,method_,exceptionInfo);
3743 void Magick::Image::posterizeChannel(const ChannelType channel_,
3744 const size_t levels_,const DitherMethod method_)
3748 SetPPChannelMask(channel_);
3749 PosterizeImage(image(),levels_,method_,exceptionInfo);
3750 RestorePPChannelMask;
3754 void Magick::Image::process(std::string name_,const ssize_t argc,
3760 (void) InvokeDynamicImageFilter(name_.c_str(),&image(),argc,argv,
3765 void Magick::Image::profile(const std::string name_,
3766 const Magick::Blob &profile_)
3770 (void) ProfileImage(image(),name_.c_str(),(unsigned char *)profile_.data(),
3771 profile_.length(),exceptionInfo);
3775 Magick::Blob Magick::Image::profile(const std::string name_) const
3780 profile=GetImageProfile(constImage(),name_.c_str());
3782 if (profile == (StringInfo *) NULL)
3784 return(Blob((void*) GetStringInfoDatum(profile),GetStringInfoLength(
3788 void Magick::Image::quantize(const bool measureError_)
3793 options()->quantizeInfo()->measure_error=MagickTrue;
3795 options()->quantizeInfo()->measure_error=MagickFalse;
3798 QuantizeImage(options()->quantizeInfo(),image(),exceptionInfo);
3802 void Magick::Image::quantumOperator(const ChannelType channel_,
3803 const MagickEvaluateOperator operator_,double rvalue_)
3806 SetPPChannelMask(channel_);
3807 EvaluateImage(image(),operator_,rvalue_,exceptionInfo);
3808 RestorePPChannelMask;
3812 void Magick::Image::quantumOperator(const ssize_t x_,const ssize_t y_,
3813 const size_t columns_,const size_t rows_,const ChannelType channel_,
3814 const MagickEvaluateOperator operator_,const double rvalue_)
3822 geometry.width = columns_;
3823 geometry.height = rows_;
3828 cropImage=CropImage(image(),&geometry,exceptionInfo);
3829 SetPPChannelMask(channel_);
3830 EvaluateImage(cropImage,operator_,rvalue_,exceptionInfo);
3831 RestorePPChannelMask;
3832 (void) CompositeImage(image(),cropImage,image()->alpha_trait ==
3833 BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
3834 geometry.x,geometry.y,exceptionInfo );
3835 cropImage=DestroyImageList(cropImage);
3839 void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
3842 raiseInfo=geometry_;
3846 RaiseImage(image(),&raiseInfo,raisedFlag_ == true ? MagickTrue : MagickFalse,
3851 void Magick::Image::randomThreshold(const Geometry &thresholds_)
3854 (void) RandomThresholdImage(image(),static_cast<std::string>(
3855 thresholds_).c_str(),exceptionInfo);
3859 void Magick::Image::randomThresholdChannel(const ChannelType channel_,
3860 const Geometry &thresholds_)
3864 SetPPChannelMask(channel_);
3865 (void) RandomThresholdImage(image(),static_cast<std::string>(
3866 thresholds_).c_str(),exceptionInfo);
3867 RestorePPChannelMask;
3871 void Magick::Image::read(const Blob &blob_)
3877 newImage=BlobToImage(imageInfo(),static_cast<const void *>(blob_.data()),
3878 blob_.length(),exceptionInfo);
3879 read(newImage,exceptionInfo);
3882 void Magick::Image::read(const Blob &blob_,const Geometry &size_)
3888 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3889 const size_t depth_)
3896 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3897 const size_t depth_,const std::string &magick_)
3902 // Set explicit image format
3903 fileName(magick_ + ':');
3907 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3908 const std::string &magick_)
3912 // Set explicit image format
3913 fileName(magick_ + ':');
3917 void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_)
3923 void Magick::Image::read(const size_t width_,const size_t height_,
3924 const std::string &map_,const StorageType type_,const void *pixels_)
3930 newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
3932 replaceImage(newImage);
3936 void Magick::Image::read(const std::string &imageSpec_)
3942 options()->fileName(imageSpec_);
3943 newImage=ReadImage(imageInfo(),exceptionInfo);
3944 read(newImage,exceptionInfo);
3947 void Magick::Image::readPixels(const Magick::QuantumType quantum_,
3948 const unsigned char *source_)
3953 quantum_info=AcquireQuantumInfo(imageInfo(),image());
3955 ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
3956 quantum_,source_,exceptionInfo);
3957 quantum_info=DestroyQuantumInfo(quantum_info);
3961 void Magick::Image::reduceNoise(void)
3966 void Magick::Image::reduceNoise(const double order_)
3972 newImage=StatisticImage(constImage(),NonpeakStatistic,(size_t) order_,
3973 (size_t) order_,exceptionInfo);
3974 replaceImage(newImage);
3978 void Magick::Image::resample(const Geometry &geometry_)
3991 // Calculate new size. This code should be supported using binary arguments
3992 // in the ImageMagick library.
3993 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3997 newImage=ResampleImage(constImage(),width,height,image()->filter,
3999 replaceImage(newImage);
4003 void Magick::Image::resize(const Geometry &geometry_)
4016 // Calculate new size. This code should be supported using binary arguments
4017 // in the ImageMagick library.
4018 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4022 newImage=ResizeImage(constImage(),width,height,image()->filter,
4024 replaceImage(newImage);
4028 void Magick::Image::roll(const Geometry &roll_)
4034 newImage=RollImage(constImage(),roll_.xOff(),roll_.yOff(),exceptionInfo);
4035 replaceImage(newImage);
4039 void Magick::Image::roll(const size_t columns_,const size_t rows_)
4045 newImage=RollImage(constImage(),static_cast<ssize_t>(columns_),
4046 static_cast<ssize_t>(rows_),exceptionInfo);
4047 replaceImage(newImage);
4051 void Magick::Image::rotate(const double degrees_)
4057 newImage=RotateImage(constImage(),degrees_,exceptionInfo);
4058 replaceImage(newImage);
4062 void Magick::Image::rotationalBlur(const double angle_)
4068 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4069 replaceImage(newImage);
4073 void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
4074 const double angle_)
4080 SetPPChannelMask(channel_);
4081 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4082 RestorePPChannelMask;
4083 replaceImage(newImage);
4087 void Magick::Image::sample(const Geometry &geometry_)
4100 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4104 newImage=SampleImage(constImage(),width,height,exceptionInfo);
4105 replaceImage(newImage);
4109 void Magick::Image::scale(const Geometry &geometry_)
4122 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4126 newImage=ScaleImage(constImage(),width,height,exceptionInfo);
4127 replaceImage(newImage);
4131 void Magick::Image::segment(const double clusterThreshold_,
4132 const double smoothingThreshold_)
4136 SegmentImage(image(),options()->quantizeColorSpace(),
4137 (MagickBooleanType) options()->verbose(),clusterThreshold_,
4138 smoothingThreshold_,exceptionInfo);
4139 SyncImage(image(),exceptionInfo);
4143 void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
4144 const double threshold_)
4150 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4152 replaceImage(newImage);
4156 void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
4157 const double radius_,const double sigma_,const double threshold_)
4163 SetPPChannelMask(channel_);
4164 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4166 RestorePPChannelMask;
4167 replaceImage(newImage);
4171 Magick::Image Magick::Image::separate(const ChannelType channel_)
4177 image=SeparateImage(constImage(),channel_,exceptionInfo);
4179 if (image == (MagickCore::Image *) NULL)
4180 return(Magick::Image());
4182 return(Magick::Image(image));
4185 void Magick::Image::sepiaTone(const double threshold_)
4191 newImage=SepiaToneImage(constImage(),threshold_,exceptionInfo);
4192 replaceImage(newImage);
4196 Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
4197 const size_t columns_,const size_t rows_)
4204 result=(*QueueAuthenticPixels)(image(),x_,y_,columns_,rows_,exceptionInfo);
4209 void Magick::Image::shade(const double azimuth_,const double elevation_,
4210 const bool colorShading_)
4216 newImage=ShadeImage(constImage(),colorShading_ == true ?
4217 MagickTrue : MagickFalse,azimuth_,elevation_,exceptionInfo);
4218 replaceImage(newImage);
4222 void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
4223 const ssize_t x_,const ssize_t y_)
4229 newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
4231 replaceImage(newImage);
4235 void Magick::Image::sharpen(const double radius_,const double sigma_)
4241 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4242 replaceImage(newImage);
4246 void Magick::Image::sharpenChannel(const ChannelType channel_,
4247 const double radius_,const double sigma_)
4253 SetPPChannelMask(channel_);
4254 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4255 RestorePPChannelMask;
4256 replaceImage(newImage);
4260 void Magick::Image::shave(const Geometry &geometry_)
4266 shaveInfo=geometry_;
4269 newImage=ShaveImage(constImage(),&shaveInfo,exceptionInfo);
4270 replaceImage(newImage);
4274 void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
4280 newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,exceptionInfo);
4281 replaceImage(newImage);
4285 void Magick::Image::sigmoidalContrast(const size_t sharpen_,
4286 const double contrast,const double midpoint)
4290 (void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
4291 midpoint,exceptionInfo);
4295 std::string Magick::Image::signature(const bool force_) const
4300 Lock(&_imgRef->_mutexLock);
4302 // Re-calculate image signature if necessary
4304 if (force_ || !GetImageProperty(constImage(),"Signature",exceptionInfo) ||
4305 constImage()->taint)
4306 SignatureImage(const_cast<MagickCore::Image *>(constImage()),
4309 property=GetImageProperty(constImage(),"Signature",exceptionInfo);
4312 return(std::string(property));
4315 void Magick::Image::sketch(const double radius_,const double sigma_,
4316 const double angle_)
4322 newImage=SketchImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
4323 replaceImage(newImage);
4327 void Magick::Image::solarize(const double factor_)
4331 SolarizeImage(image(),factor_,exceptionInfo);
4335 void Magick::Image::sparseColor(const ChannelType channel_,
4336 const SparseColorMethod method_,const size_t numberArguments_,
4337 const double *arguments_)
4343 SetPPChannelMask(channel_);
4344 newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
4346 RestorePPChannelMask;
4347 replaceImage(newImage);
4351 void Magick::Image::splice(const Geometry &geometry_)
4357 spliceInfo=geometry_;
4360 newImage=SpliceImage(constImage(),&spliceInfo,exceptionInfo);
4361 replaceImage(newImage);
4365 void Magick::Image::spread(const size_t amount_)
4371 newImage=SpreadImage(constImage(),amount_,image()->interpolate,
4373 replaceImage(newImage);
4377 Magick::ImageStatistics Magick::Image::statistics()
4379 return(ImageStatistics(constImage()));
4382 void Magick::Image::stegano(const Image &watermark_)
4388 newImage=SteganoImage(constImage(),watermark_.constImage(),exceptionInfo);
4389 replaceImage(newImage);
4393 void Magick::Image::stereo(const Image &rightImage_)
4399 newImage=StereoImage(constImage(),rightImage_.constImage(),exceptionInfo);
4400 replaceImage(newImage);
4404 void Magick::Image::strip(void)
4408 StripImage(image(),exceptionInfo);
4412 Magick::Image Magick::Image::subImageSearch(const Image &reference_,
4413 const MetricType metric_,Geometry *offset_,double *similarityMetric_,
4414 const double similarityThreshold)
4423 newImage=SimilarityImage(image(),reference_.constImage(),metric_,
4424 similarityThreshold,&offset,similarityMetric_,exceptionInfo);
4426 if (offset_ != (Geometry *) NULL)
4428 if (newImage == (MagickCore::Image *) NULL)
4429 return(Magick::Image());
4431 return(Magick::Image(newImage));
4434 void Magick::Image::swirl(const double degrees_)
4440 newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
4442 replaceImage(newImage);
4446 void Magick::Image::syncPixels(void)
4449 (void) (*SyncAuthenticPixels)(image(),exceptionInfo);
4453 void Magick::Image::texture(const Image &texture_)
4457 TextureImage(image(),texture_.constImage(),exceptionInfo);
4461 void Magick::Image::threshold(const double threshold_)
4465 BilevelImage(image(),threshold_,exceptionInfo);
4469 void Magick::Image::thumbnail(const Geometry &geometry_)
4482 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4486 newImage=ThumbnailImage(constImage(),width,height,exceptionInfo);
4487 replaceImage(newImage);
4491 void Magick::Image::tint(const std::string opacity_)
4500 color=static_cast<PixelInfo>(constOptions()->fillColor());
4501 newImage=TintImage(constImage(),opacity_.c_str(),&color,exceptionInfo);
4502 replaceImage(newImage);
4506 void Magick::Image::transform(const Geometry &imageGeometry_)
4510 TransformImage(&(image()),0,std::string(imageGeometry_).c_str(),
4515 void Magick::Image::transform(const Geometry &imageGeometry_,
4516 const Geometry &cropGeometry_)
4520 TransformImage(&(image()),std::string(cropGeometry_).c_str(),std::string(
4521 imageGeometry_).c_str(), exceptionInfo);
4525 void Magick::Image::transformOrigin(const double x_,const double y_)
4528 options()->transformOrigin(x_,y_);
4531 void Magick::Image::transformReset(void)
4534 options()->transformReset();
4537 void Magick::Image::transformScale(const double sx_,const double sy_)
4540 options()->transformScale(sx_,sy_);
4543 void Magick::Image::transparent(const Color &color_)
4551 if (!color_.isValid())
4552 throwExceptionExplicit(OptionError,"Color argument is invalid");
4556 (void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
4559 TransparentPaintImage(image(),&target,TransparentAlpha,MagickFalse,
4564 void Magick::Image::transparentChroma(const Color &colorLow_,
4565 const Color &colorHigh_)
4575 if (!colorLow_.isValid() || !colorHigh_.isValid())
4576 throwExceptionExplicit(OptionError,"Color argument is invalid");
4579 colorHigh=colorHigh_;
4582 (void) QueryColorCompliance(colorLow.c_str(),AllCompliance,&targetLow,
4584 (void) QueryColorCompliance(colorHigh.c_str(),AllCompliance,&targetHigh,
4587 TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
4588 MagickFalse,exceptionInfo);
4592 void Magick::Image::transpose(void)
4598 newImage=TransposeImage(constImage(),exceptionInfo);
4599 replaceImage(newImage);
4603 void Magick::Image::transverse(void)
4609 newImage=TransverseImage(constImage(),exceptionInfo);
4610 replaceImage(newImage);
4614 void Magick::Image::trim(void)
4620 newImage=TrimImage(constImage(),exceptionInfo);
4621 replaceImage(newImage);
4625 Magick::Image Magick::Image::uniqueColors(void)
4631 image=UniqueImageColors(constImage(),exceptionInfo);
4633 if (image == (MagickCore::Image *) NULL)
4634 return(Magick::Image());
4636 return(Magick::Image(image));
4639 void Magick::Image::unsharpmask(const double radius_,const double sigma_,
4640 const double amount_,const double threshold_)
4646 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4648 replaceImage(newImage);
4652 void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
4653 const double radius_,const double sigma_,const double amount_,
4654 const double threshold_)
4660 SetPPChannelMask(channel_);
4661 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4663 RestorePPChannelMask;
4664 replaceImage(newImage);
4668 void Magick::Image::vignette(const double radius_,const double sigma_,
4669 const ssize_t x_,const ssize_t y_)
4675 newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,exceptionInfo);
4676 replaceImage(newImage);
4680 void Magick::Image::wave(const double amplitude_,const double wavelength_)
4686 newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
4688 replaceImage(newImage);
4692 void Magick::Image::whiteThreshold(const std::string &threshold_)
4696 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4700 void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
4701 const std::string &threshold_)
4705 SetPPChannelMask(channel_);
4706 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4707 RestorePPChannelMask;
4711 void Magick::Image::write(Blob *blob_)
4721 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4723 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4727 void Magick::Image::write(Blob *blob_,const std::string &magick_)
4738 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4740 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4744 void Magick::Image::write(Blob *blob_,const std::string &magick_,
4745 const size_t depth_)
4757 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4759 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4763 void Magick::Image::write(const ssize_t x_,const ssize_t y_,
4764 const size_t columns_,const size_t rows_,const std::string &map_,
4765 const StorageType type_,void *pixels_)
4768 ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
4773 void Magick::Image::write(const std::string &imageSpec_)
4776 fileName(imageSpec_);
4778 WriteImage(constImageInfo(),image(),exceptionInfo);
4782 void Magick::Image::writePixels(const Magick::QuantumType quantum_,
4783 unsigned char *destination_)
4788 quantum_info=AcquireQuantumInfo(imageInfo(),image());
4790 ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4791 quantum_,destination_, exceptionInfo);
4792 quantum_info=DestroyQuantumInfo(quantum_info);
4796 void Magick::Image::zoom(const Geometry &geometry_)
4809 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4813 newImage=ResizeImage(constImage(),width,height,image()->filter,exceptionInfo);
4814 replaceImage(newImage);
4818 Magick::Image::Image(MagickCore::Image *image_)
4819 : _imgRef(new ImageRef(image_))
4823 MagickCore::Image *&Magick::Image::image(void)
4825 return(_imgRef->image());
4828 const MagickCore::Image *Magick::Image::constImage(void) const
4830 return(_imgRef->image());
4833 MagickCore::ImageInfo *Magick::Image::imageInfo(void)
4835 return(_imgRef->options()->imageInfo());
4838 const MagickCore::ImageInfo *Magick::Image::constImageInfo(void) const
4840 return(_imgRef->options()->imageInfo());
4843 Magick::Options *Magick::Image::options(void)
4845 return(_imgRef->options());
4848 const Magick::Options *Magick::Image::constOptions(void) const
4850 return(_imgRef->options());
4853 MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)
4855 return(_imgRef->options()->quantizeInfo());
4858 const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
4860 return(_imgRef->options()->quantizeInfo());
4863 void Magick::Image::modifyImage(void)
4866 Lock(&_imgRef->_mutexLock);
4867 if (_imgRef->_refCount == 1)
4869 // De-register image and return
4876 replaceImage(CloneImage(image(),0,0,MagickTrue,exceptionInfo));
4880 ssize_t Magick::Image::registerId(void)
4882 Lock(&_imgRef->_mutexLock);
4883 if ( _imgRef->id() < 0)
4889 _imgRef->id(_imgRef->id()+1);
4890 sprintf(id,"%.20g\n",(double) _imgRef->id());
4891 SetImageRegistry(ImageRegistryType,id,image(),exceptionInfo);
4894 return(_imgRef->id());
4897 MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
4903 image = replacement_;
4907 image=AcquireImage(constImageInfo(),exceptionInfo);
4912 Lock(&_imgRef->_mutexLock);
4914 if (_imgRef->_refCount == 1)
4916 // We own the image, just replace it, and de-register
4918 _imgRef->image(image);
4922 // We don't own the image, dereference and replace with copy
4923 --_imgRef->_refCount;
4924 _imgRef=new ImageRef(image,constOptions());
4928 return(_imgRef->_image);
4931 void Magick::Image::unregisterId(void)
4937 void Magick::Image::read(MagickCore::Image *image,
4938 MagickCore::ExceptionInfo *exceptionInfo)
4940 // Ensure that multiple image frames were not read.
4941 if (image != (MagickCore::Image *) NULL &&
4942 image->next != (MagickCore::Image *) NULL)
4947 // Destroy any extra image frames
4949 image->next=(MagickCore::Image *) NULL;
4950 next->previous=(MagickCore::Image *) NULL;
4951 DestroyImageList(next);
4953 replaceImage(image);
4954 if (exceptionInfo->severity == MagickCore::UndefinedException &&
4955 image == (MagickCore::Image *) NULL)
4957 (void) MagickCore::DestroyExceptionInfo(exceptionInfo);
4958 throwExceptionExplicit(ImageWarning,"No image was loaded.");
4963 void Magick::Image::floodFill(const ssize_t x_,const ssize_t y_,
4964 const Magick::Image *fillPattern_,const Magick::Color &fill_,
4965 const MagickCore::PixelInfo *target_,const bool invert_)
4973 // Set drawing fill pattern or fill color
4974 fillColor=options()->fillColor();
4975 fillPattern=(MagickCore::Image *)NULL;
4976 if (options()->fillPattern() != (MagickCore::Image *)NULL)
4979 fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
4984 if (fillPattern_ == (Magick::Image *)NULL)
4986 options()->fillPattern((MagickCore::Image *)NULL);
4987 options()->fillColor(fill_);
4990 options()->fillPattern(fillPattern_->constImage());
4993 (void) FloodfillPaintImage(image(),options()->drawInfo(),
4994 target_,static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),
4995 (MagickBooleanType) invert_,exceptionInfo);
4997 options()->fillColor(fillColor);
4998 options()->fillPattern(fillPattern);