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 size_t depth_)
507 SetImageDepth(image(),depth_,&exceptionInfo);
511 size_t Magick::Image::channelDepth()
517 channel_depth=GetImageDepth(constImage(),&exceptionInfo);
519 return(channel_depth);
522 size_t Magick::Image::channels() const
524 return(constImage()->number_channels);
527 void Magick::Image::classType(const ClassType class_)
529 if (classType() == PseudoClass && class_ == DirectClass)
531 // Use SyncImage to synchronize the DirectClass pixels with the
532 // color map and then set to DirectClass type.
535 SyncImage(image(),&exceptionInfo);
537 image()->colormap=(PixelInfo *)RelinquishMagickMemory(image()->colormap);
538 image()->storage_class=static_cast<MagickCore::ClassType>(DirectClass);
542 if (classType() == DirectClass && class_ == PseudoClass)
544 // Quantize to create PseudoClass color map
546 quantizeColors(MaxColormapSize);
548 image()->storage_class=static_cast<MagickCore::ClassType>(PseudoClass);
552 Magick::ClassType Magick::Image::classType(void) const
554 return static_cast<Magick::ClassType>(constImage()->storage_class);
557 void Magick::Image::clipMask(const Magick::Image &clipMask_)
562 if (clipMask_.isValid())
563 SetImageMask(image(),clipMask_.constImage(),&exceptionInfo);
565 SetImageMask(image(),0,&exceptionInfo);
569 Magick::Image Magick::Image::clipMask(void) const
575 image=GetImageMask(constImage(),&exceptionInfo);
577 if (image == (MagickCore::Image *) NULL)
578 return(Magick::Image());
580 return(Magick::Image(image));
583 void Magick::Image::colorFuzz(const double fuzz_)
587 options()->colorFuzz(fuzz_);
590 double Magick::Image::colorFuzz(void) const
592 return(constOptions()->colorFuzz());
595 void Magick::Image::colorMapSize(const size_t entries_)
597 if (entries_ >MaxColormapSize)
598 throwExceptionExplicit(OptionError,
599 "Colormap entries must not exceed MaxColormapSize");
603 (void) AcquireImageColormap(image(),entries_,&exceptionInfo);
607 size_t Magick::Image::colorMapSize(void) const
609 if (!constImage()->colormap)
610 throwExceptionExplicit(OptionError,"Image does not contain a colormap");
612 return(constImage()->colors);
615 void Magick::Image::colorSpace(const ColorspaceType colorSpace_)
617 if (image()->colorspace == colorSpace_)
622 TransformImageColorspace(image(),colorSpace_,&exceptionInfo);
626 Magick::ColorspaceType Magick::Image::colorSpace(void) const
628 return (constImage()->colorspace);
631 void Magick::Image::colorSpaceType(const ColorspaceType colorSpace_)
635 SetImageColorspace(image(),colorSpace_,&exceptionInfo);
637 options()->colorspaceType(colorSpace_);
640 Magick::ColorspaceType Magick::Image::colorSpaceType(void) const
642 return(constOptions()->colorspaceType());
645 size_t Magick::Image::columns(void) const
647 return(constImage()->columns);
650 void Magick::Image::comment(const std::string &comment_)
654 SetImageProperty(image(),"Comment",NULL,&exceptionInfo);
655 if (comment_.length() > 0)
656 SetImageProperty(image(),"Comment",comment_.c_str(),&exceptionInfo);
660 std::string Magick::Image::comment(void) const
666 value=GetImageProperty(constImage(),"Comment",&exceptionInfo);
670 return(std::string(value));
672 return(std::string()); // Intentionally no exception
675 void Magick::Image::compose(const CompositeOperator compose_)
677 image()->compose=compose_;
680 Magick::CompositeOperator Magick::Image::compose(void) const
682 return(constImage()->compose);
685 void Magick::Image::compressType(const CompressionType compressType_)
688 image()->compression=compressType_;
689 options()->compressType(compressType_);
692 Magick::CompressionType Magick::Image::compressType(void) const
694 return(constImage()->compression);
697 void Magick::Image::debug(const bool flag_)
700 options()->debug(flag_);
703 bool Magick::Image::debug(void) const
705 return(constOptions()->debug());
708 void Magick::Image::density(const Geometry &density_)
711 options()->density(density_);
712 if (density_.isValid())
714 image()->resolution.x=density_.width();
715 if (density_.height() != 0)
716 image()->resolution.y=density_.height();
718 image()->resolution.y=density_.width();
723 image()->resolution.x=0;
724 image()->resolution.y=0;
728 Magick::Geometry Magick::Image::density(void) const
736 if (constImage()->resolution.x > 0.0)
737 x_resolution=static_cast<ssize_t>(constImage()->resolution.x + 0.5);
739 if (constImage()->resolution.y > 0.0)
740 y_resolution=static_cast<ssize_t>(constImage()->resolution.y + 0.5);
742 return(Geometry(x_resolution,y_resolution));
745 return(constOptions()->density());
748 void Magick::Image::depth(const size_t depth_)
753 if (depth > MAGICKCORE_QUANTUM_DEPTH)
754 depth=MAGICKCORE_QUANTUM_DEPTH;
757 image()->depth=depth;
758 options()->depth(depth);
761 size_t Magick::Image::depth(void) const
763 return(constImage()->depth);
766 std::string Magick::Image::directory(void) const
768 if (constImage()->directory)
769 return(std::string(constImage()->directory));
771 throwExceptionExplicit(CorruptImageWarning,
772 "Image does not contain a directory");
774 return(std::string());
777 void Magick::Image::endian(const Magick::EndianType endian_)
780 options()->endian(endian_);
781 image()->endian=endian_;
784 Magick::EndianType Magick::Image::endian(void) const
786 return(constImage()->endian);
789 void Magick::Image::exifProfile(const Magick::Blob &exifProfile_)
793 if (exifProfile_.data() != 0)
798 exif_profile=AcquireStringInfo(exifProfile_.length());
799 SetStringInfoDatum(exif_profile,(unsigned char *) exifProfile_.data());
801 (void) SetImageProfile(image(),"exif",exif_profile,&exceptionInfo);
802 exif_profile=DestroyStringInfo(exif_profile);
807 Magick::Blob Magick::Image::exifProfile(void) const
812 exif_profile=GetImageProfile(constImage(),"exif");
813 if (exif_profile == (StringInfo *) NULL)
815 return(Blob(GetStringInfoDatum(exif_profile),
816 GetStringInfoLength(exif_profile)));
819 void Magick::Image::fileName(const std::string &fileName_)
823 fileName_.copy(image()->filename,sizeof(image()->filename)-1);
824 image()->filename[fileName_.length()]=0; // Null terminate
826 options()->fileName(fileName_);
829 std::string Magick::Image::fileName(void) const
831 return(constOptions()->fileName());
834 MagickCore::MagickSizeType Magick::Image::fileSize(void) const
836 return(GetBlobSize(constImage()));
839 void Magick::Image::fillColor(const Magick::Color &fillColor_)
845 options()->fillColor(fillColor_);
847 artifact("fill",value);
850 Magick::Color Magick::Image::fillColor(void) const
852 return(constOptions()->fillColor());
855 void Magick::Image::fillRule(const Magick::FillRule &fillRule_)
858 options()->fillRule(fillRule_);
861 Magick::FillRule Magick::Image::fillRule(void) const
863 return constOptions()->fillRule();
866 void Magick::Image::fillPattern(const Image &fillPattern_)
869 if (fillPattern_.isValid())
870 options()->fillPattern(fillPattern_.constImage());
872 options()->fillPattern(static_cast<MagickCore::Image*>(NULL));
875 Magick::Image Magick::Image::fillPattern(void) const
877 // FIXME: This is inordinately innefficient
878 const MagickCore::Image
884 tmpTexture=constOptions()->fillPattern();
892 image=CloneImage(tmpTexture,0,0,MagickTrue,&exceptionInfo);
893 texture.replaceImage(image);
899 void Magick::Image::filterType(const Magick::FilterTypes filterType_)
902 image()->filter=filterType_;
905 Magick::FilterTypes Magick::Image::filterType(void) const
907 return(constImage()->filter);
910 void Magick::Image::font(const std::string &font_)
913 options()->font(font_);
916 std::string Magick::Image::font(void) const
918 return(constOptions()->font());
921 void Magick::Image::fontPointsize(const double pointSize_)
924 options()->fontPointsize(pointSize_);
927 double Magick::Image::fontPointsize(void) const
929 return(constOptions()->fontPointsize());
932 std::string Magick::Image::format(void) const
938 magick_info=GetMagickInfo(constImage()->magick,&exceptionInfo);
941 if ((magick_info != 0) && (*magick_info->description != '\0'))
942 return(std::string(magick_info->description));
944 throwExceptionExplicit(CorruptImageWarning,"Unrecognized image magick type");
945 return(std::string());
948 std::string Magick::Image::formatExpression(const std::string expression)
957 text=InterpretImageProperties(imageInfo(),image(),expression.c_str(),
959 if (text != (char *) NULL)
961 result=std::string(text);
962 text=DestroyString(text);
968 double Magick::Image::gamma(void) const
970 return(constImage()->gamma);
973 Magick::Geometry Magick::Image::geometry(void) const
975 if (constImage()->geometry)
976 return Geometry(constImage()->geometry);
978 throwExceptionExplicit(OptionWarning,"Image does not contain a geometry");
983 void Magick::Image::gifDisposeMethod(
984 const MagickCore::DisposeType disposeMethod_)
987 image()->dispose=disposeMethod_;
990 MagickCore::DisposeType Magick::Image::gifDisposeMethod(void) const
992 return(constImage()->dispose);
995 void Magick::Image::highlightColor(const Color color_)
1001 artifact("highlight-color",value);
1004 void Magick::Image::iccColorProfile(const Magick::Blob &colorProfile_)
1006 profile("icm",colorProfile_);
1009 Magick::Blob Magick::Image::iccColorProfile(void) const
1014 color_profile=GetImageProfile(constImage(),"icc");
1015 if (color_profile == (StringInfo *) NULL)
1017 return(Blob(GetStringInfoDatum(color_profile),GetStringInfoLength(
1021 void Magick::Image::interlaceType(const Magick::InterlaceType interlace_)
1024 image()->interlace=interlace_;
1025 options()->interlaceType(interlace_);
1028 Magick::InterlaceType Magick::Image::interlaceType(void) const
1030 return(constImage()->interlace);
1033 void Magick::Image::interpolate(const PixelInterpolateMethod interpolate_)
1036 image()->interpolate=interpolate_;
1039 Magick::PixelInterpolateMethod Magick::Image::interpolate(void) const
1041 return constImage()->interpolate;
1044 void Magick::Image::iptcProfile(const Magick::Blob &iptcProfile_)
1047 if (iptcProfile_.data() != 0)
1052 iptc_profile=AcquireStringInfo(iptcProfile_.length());
1053 SetStringInfoDatum(iptc_profile,(unsigned char *) iptcProfile_.data());
1055 (void) SetImageProfile(image(),"iptc",iptc_profile,&exceptionInfo);
1056 iptc_profile=DestroyStringInfo(iptc_profile);
1061 Magick::Blob Magick::Image::iptcProfile(void) const
1066 iptc_profile=GetImageProfile(constImage(),"iptc");
1067 if (iptc_profile == (StringInfo *) NULL)
1069 return(Blob(GetStringInfoDatum(iptc_profile),GetStringInfoLength(
1073 void Magick::Image::isValid(const bool isValid_)
1078 _imgRef=new ImageRef;
1080 else if (!isValid())
1082 // Construct with single-pixel black image to make
1083 // image valid. This is an obvious hack.
1084 size(Geometry(1,1));
1089 bool Magick::Image::isValid(void) const
1091 return rows() && columns();
1094 void Magick::Image::label(const std::string &label_)
1098 (void) SetImageProperty(image(),"Label",NULL,&exceptionInfo);
1099 if (label_.length() > 0)
1100 (void) SetImageProperty(image(),"Label",label_.c_str(),&exceptionInfo);
1104 std::string Magick::Image::label(void) const
1110 value=GetImageProperty(constImage(),"Label",&exceptionInfo);
1114 return(std::string(value));
1116 return(std::string());
1119 void Magick::Image::lowlightColor(const Color color_)
1125 artifact("lowlight-color",value);
1128 void Magick::Image::magick(const std::string &magick_)
1132 magick_.copy(image()->magick,sizeof(image()->magick)-1);
1133 image()->magick[magick_.length()]=0;
1135 options()->magick(magick_);
1138 std::string Magick::Image::magick(void) const
1140 if (*(constImage()->magick) != '\0')
1141 return(std::string(constImage()->magick));
1143 return(constOptions()->magick());
1146 double Magick::Image::meanErrorPerPixel(void) const
1148 return(constImage()->error.mean_error_per_pixel);
1151 void Magick::Image::modulusDepth(const size_t depth_)
1155 SetImageDepth(image(),depth_,&exceptionInfo);
1157 options()->depth(depth_);
1160 size_t Magick::Image::modulusDepth(void) const
1166 depth=GetImageDepth(constImage(),&exceptionInfo);
1171 void Magick::Image::monochrome(const bool monochromeFlag_)
1174 options()->monochrome(monochromeFlag_);
1177 bool Magick::Image::monochrome(void) const
1179 return(constOptions()->monochrome());
1182 Magick::Geometry Magick::Image::montageGeometry(void) const
1184 if (constImage()->montage)
1185 return Magick::Geometry(constImage()->montage);
1187 throwExceptionExplicit(CorruptImageWarning,
1188 "Image does not contain a montage");
1190 return(Magick::Geometry());
1193 double Magick::Image::normalizedMaxError(void) const
1195 return(constImage()->error.normalized_maximum_error);
1198 double Magick::Image::normalizedMeanError(void) const
1200 return(constImage()->error.normalized_mean_error);
1203 void Magick::Image::orientation(const Magick::OrientationType orientation_)
1206 image()->orientation=orientation_;
1209 Magick::OrientationType Magick::Image::orientation(void) const
1211 return(constImage()->orientation);
1214 void Magick::Image::page(const Magick::Geometry &pageSize_)
1217 options()->page(pageSize_);
1218 image()->page=pageSize_;
1221 Magick::Geometry Magick::Image::page(void) const
1223 return(Geometry(constImage()->page.width,constImage()->page.height,
1224 AbsoluteValue(constImage()->page.x),AbsoluteValue(constImage()->page.y),
1225 constImage()->page.x < 0 ? true : false,
1226 constImage()->page.y < 0 ? true : false));
1229 void Magick::Image::quality(const size_t quality_)
1232 image()->quality=quality_;
1233 options()->quality(quality_);
1236 size_t Magick::Image::quality(void) const
1238 return(constImage()->quality);
1241 void Magick::Image::quantizeColors(const size_t colors_)
1244 options()->quantizeColors(colors_);
1247 size_t Magick::Image::quantizeColors(void) const
1249 return(constOptions()->quantizeColors());
1252 void Magick::Image::quantizeColorSpace(
1253 const Magick::ColorspaceType colorSpace_)
1256 options()->quantizeColorSpace(colorSpace_);
1259 Magick::ColorspaceType Magick::Image::quantizeColorSpace(void) const
1261 return(constOptions()->quantizeColorSpace());
1264 void Magick::Image::quantizeDither(const bool ditherFlag_)
1267 options()->quantizeDither(ditherFlag_);
1270 bool Magick::Image::quantizeDither(void) const
1272 return(constOptions()->quantizeDither());
1275 void Magick::Image::quantizeDitherMethod(const DitherMethod ditherMethod_)
1278 options()->quantizeDitherMethod(ditherMethod_);
1281 MagickCore::DitherMethod Magick::Image::quantizeDitherMethod(void) const
1283 return(constOptions()->quantizeDitherMethod());
1286 void Magick::Image::quantizeTreeDepth(const size_t treeDepth_)
1289 options()->quantizeTreeDepth(treeDepth_);
1292 size_t Magick::Image::quantizeTreeDepth() const
1294 return(constOptions()->quantizeTreeDepth());
1297 void Magick::Image::renderingIntent(
1298 const Magick::RenderingIntent renderingIntent_)
1301 image()->rendering_intent=renderingIntent_;
1304 Magick::RenderingIntent Magick::Image::renderingIntent(void) const
1306 return(static_cast<Magick::RenderingIntent>(constImage()->rendering_intent));
1309 void Magick::Image::resolutionUnits(
1310 const Magick::ResolutionType resolutionUnits_)
1313 image()->units=resolutionUnits_;
1314 options()->resolutionUnits(resolutionUnits_);
1317 Magick::ResolutionType Magick::Image::resolutionUnits(void) const
1319 return(constOptions()->resolutionUnits());
1322 size_t Magick::Image::rows(void) const
1324 return(constImage()->rows);
1327 void Magick::Image::scene(const size_t scene_)
1330 image()->scene=scene_;
1333 size_t Magick::Image::scene(void) const
1335 return(constImage()->scene);
1338 void Magick::Image::size(const Geometry &geometry_)
1341 options()->size(geometry_);
1342 image()->rows=geometry_.height();
1343 image()->columns=geometry_.width();
1346 Magick::Geometry Magick::Image::size(void) const
1348 return(Magick::Geometry(constImage()->columns,constImage()->rows));
1351 void Magick::Image::strokeAntiAlias(const bool flag_)
1354 options()->strokeAntiAlias(flag_);
1357 bool Magick::Image::strokeAntiAlias(void) const
1359 return(constOptions()->strokeAntiAlias());
1362 void Magick::Image::strokeColor(const Magick::Color &strokeColor_)
1368 options()->strokeColor(strokeColor_);
1370 artifact("stroke",value);
1373 Magick::Color Magick::Image::strokeColor(void) const
1375 return(constOptions()->strokeColor());
1378 void Magick::Image::strokeDashArray(const double *strokeDashArray_)
1381 options()->strokeDashArray(strokeDashArray_);
1384 const double* Magick::Image::strokeDashArray(void) const
1386 return(constOptions()->strokeDashArray());
1389 void Magick::Image::strokeDashOffset(const double strokeDashOffset_)
1392 options()->strokeDashOffset(strokeDashOffset_);
1395 double Magick::Image::strokeDashOffset(void) const
1397 return(constOptions()->strokeDashOffset());
1400 void Magick::Image::strokeLineCap(const Magick::LineCap lineCap_)
1403 options()->strokeLineCap(lineCap_);
1406 Magick::LineCap Magick::Image::strokeLineCap(void) const
1408 return(constOptions()->strokeLineCap());
1411 void Magick::Image::strokeLineJoin(const Magick::LineJoin lineJoin_)
1414 options()->strokeLineJoin(lineJoin_);
1417 Magick::LineJoin Magick::Image::strokeLineJoin(void) const
1419 return(constOptions()->strokeLineJoin());
1422 void Magick::Image::strokeMiterLimit(const size_t strokeMiterLimit_)
1425 options()->strokeMiterLimit(strokeMiterLimit_);
1428 size_t Magick::Image::strokeMiterLimit(void) const
1430 return(constOptions()->strokeMiterLimit());
1433 void Magick::Image::strokePattern(const Image &strokePattern_)
1436 if(strokePattern_.isValid())
1437 options()->strokePattern(strokePattern_.constImage());
1439 options()->strokePattern(static_cast<MagickCore::Image*>(NULL));
1442 Magick::Image Magick::Image::strokePattern(void) const
1444 // FIXME: This is inordinately innefficient
1445 const MagickCore::Image
1451 tmpTexture=constOptions()->strokePattern();
1459 image=CloneImage(tmpTexture,0,0,MagickTrue,&exceptionInfo);
1460 texture.replaceImage(image);
1466 void Magick::Image::strokeWidth(const double strokeWidth_)
1469 value[MaxTextExtent];
1472 options()->strokeWidth(strokeWidth_);
1473 FormatLocaleString(value,MaxTextExtent,"%.20g",strokeWidth_);
1474 (void) SetImageArtifact(image(),"strokewidth",value);
1477 double Magick::Image::strokeWidth(void) const
1479 return(constOptions()->strokeWidth());
1482 void Magick::Image::subImage(const size_t subImage_)
1485 options()->subImage(subImage_);
1488 size_t Magick::Image::subImage(void) const
1490 return(constOptions()->subImage());
1493 void Magick::Image::subRange(const size_t subRange_)
1496 options()->subRange(subRange_);
1499 size_t Magick::Image::subRange(void) const
1501 return(constOptions()->subRange());
1504 void Magick::Image::textDirection(DirectionType direction_)
1507 options()->textDirection(direction_);
1510 Magick::DirectionType Magick::Image::textDirection(void) const
1512 return(constOptions()->textDirection());
1515 void Magick::Image::textEncoding(const std::string &encoding_)
1518 options()->textEncoding(encoding_);
1521 std::string Magick::Image::textEncoding(void) const
1523 return(constOptions()->textEncoding());
1526 void Magick::Image::textGravity(GravityType gravity_)
1529 options()->textGravity(gravity_);
1532 Magick::GravityType Magick::Image::textGravity(void) const
1534 return(constOptions()->textGravity());
1537 void Magick::Image::textInterlineSpacing(double spacing_)
1540 options()->textInterlineSpacing(spacing_);
1543 double Magick::Image::textInterlineSpacing(void) const
1545 return(constOptions()->textInterlineSpacing());
1548 void Magick::Image::textInterwordSpacing(double spacing_)
1551 options()->textInterwordSpacing(spacing_);
1554 double Magick::Image::textInterwordSpacing(void) const
1556 return(constOptions()->textInterwordSpacing());
1559 void Magick::Image::textKerning(double kerning_)
1562 options()->textKerning(kerning_);
1565 double Magick::Image::textKerning(void) const
1567 return(constOptions()->textKerning());
1570 size_t Magick::Image::totalColors(void) const
1576 colors=GetNumberColors(constImage(),0,&exceptionInfo);
1581 void Magick::Image::transformRotation(const double angle_)
1584 options()->transformRotation(angle_);
1587 void Magick::Image::transformSkewX(const double skewx_)
1590 options()->transformSkewX(skewx_);
1593 void Magick::Image::transformSkewY(const double skewy_)
1596 options()->transformSkewY(skewy_);
1599 Magick::ImageType Magick::Image::type(void) const
1601 if (constOptions()->type() != UndefinedType)
1602 return(constOptions()->type());
1603 else if (constImage()->type != UndefinedType)
1604 return(constImage()->type);
1606 return(determineType());
1609 void Magick::Image::type(const Magick::ImageType type_)
1612 options()->type(type_);
1614 SetImageType(image(),type_,&exceptionInfo);
1618 void Magick::Image::verbose(const bool verboseFlag_)
1621 options()->verbose(verboseFlag_);
1624 bool Magick::Image::verbose(void) const
1626 return(constOptions()->verbose());
1629 void Magick::Image::view(const std::string &view_)
1632 options()->view(view_);
1635 std::string Magick::Image::view(void) const
1637 return(constOptions()->view());
1640 void Magick::Image::virtualPixelMethod(
1641 const VirtualPixelMethod virtualPixelMethod_)
1645 SetImageVirtualPixelMethod(image(),virtualPixelMethod_,&exceptionInfo);
1649 Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod(void) const
1651 return(GetImageVirtualPixelMethod(constImage()));
1654 void Magick::Image::x11Display(const std::string &display_)
1657 options()->x11Display(display_);
1660 std::string Magick::Image::x11Display(void) const
1662 return(constOptions()->x11Display());
1665 double Magick::Image::xResolution(void) const
1667 return(constImage()->resolution.x);
1670 double Magick::Image::yResolution(void) const
1672 return(constImage()->resolution.y);
1675 void Magick::Image::adaptiveBlur(const double radius_,const double sigma_)
1681 newImage=AdaptiveBlurImage(constImage(),radius_,sigma_,&exceptionInfo);
1682 replaceImage(newImage);
1686 void Magick::Image::adaptiveResize(const Geometry &geometry_)
1699 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
1703 newImage=AdaptiveResizeImage(constImage(),width,height,&exceptionInfo);
1704 replaceImage(newImage);
1708 void Magick::Image::adaptiveSharpen(const double radius_,const double sigma_)
1714 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,&exceptionInfo);
1715 replaceImage(newImage);
1719 void Magick::Image::adaptiveSharpenChannel(const ChannelType channel_,
1720 const double radius_,const double sigma_ )
1726 SetPPChannelMask(channel_);
1727 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,&exceptionInfo);
1728 RestorePPChannelMask;
1729 replaceImage(newImage);
1733 void Magick::Image::adaptiveThreshold(const size_t width_,const size_t height_,
1734 const ssize_t offset_)
1741 newImage=AdaptiveThresholdImage(constImage(),width_,height_,offset_,
1743 replaceImage(newImage);
1747 void Magick::Image::addNoise(const NoiseType noiseType_)
1753 newImage=AddNoiseImage(constImage(),noiseType_,1.0,&exceptionInfo);
1754 replaceImage(newImage);
1758 void Magick::Image::addNoiseChannel(const ChannelType channel_,
1759 const NoiseType noiseType_)
1765 SetPPChannelMask(channel_);
1766 newImage=AddNoiseImage(constImage(),noiseType_,1.0,&exceptionInfo);
1767 RestorePPChannelMask;
1768 replaceImage(newImage);
1772 void Magick::Image::affineTransform(const DrawableAffine &affine_)
1780 _affine.sx=affine_.sx();
1781 _affine.sy=affine_.sy();
1782 _affine.rx=affine_.rx();
1783 _affine.ry=affine_.ry();
1784 _affine.tx=affine_.tx();
1785 _affine.ty=affine_.ty();
1788 newImage=AffineTransformImage(constImage(),&_affine,&exceptionInfo);
1789 replaceImage(newImage);
1793 void Magick::Image::alpha(const unsigned int alpha_)
1797 SetImageAlpha(image(),alpha_,&exceptionInfo);
1801 void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
1805 SetImageAlphaChannel(image(),alphaOption_,&exceptionInfo);
1809 void Magick::Image::alphaFloodfill(const Color &target_,
1810 const unsigned int alpha_,const ssize_t x_,const ssize_t y_,
1811 const Magick::PaintMethod method_)
1817 GetPixelInfo(constImage(),&target);
1818 target.red=static_cast<PixelInfo>(target_).red;
1819 target.green=static_cast<PixelInfo>(target_).green;
1820 target.blue=static_cast<PixelInfo>(target_).blue;
1821 target.alpha=alpha_;
1823 SetPPChannelMask(AlphaChannel);
1824 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
1825 method_ == FloodfillMethod ? MagickFalse : MagickTrue,&exceptionInfo);
1826 RestorePPChannelMask;
1830 void Magick::Image::annotate(const std::string &text_,
1831 const Geometry &location_)
1833 annotate(text_,location_,NorthWestGravity,0.0);
1836 void Magick::Image::annotate(const std::string &text_,
1837 const Geometry &boundingArea_,const GravityType gravity_)
1839 annotate(text_,boundingArea_,gravity_,0.0);
1842 void Magick::Image::annotate(const std::string &text_,
1843 const Geometry &boundingArea_,const GravityType gravity_,
1844 const double degrees_)
1850 boundingArea[MaxTextExtent];
1857 drawInfo=options()->drawInfo();
1858 drawInfo->text=const_cast<char *>(text_.c_str());
1859 drawInfo->geometry=0;
1861 if (boundingArea_.isValid())
1863 if (boundingArea_.width() == 0 || boundingArea_.height() == 0)
1865 FormatLocaleString(boundingArea,MaxTextExtent,"%+.20g%+.20g",
1866 (double) boundingArea_.xOff(),(double) boundingArea_.yOff());
1870 (void) CopyMagickString(boundingArea,string(boundingArea_).c_str(),
1873 drawInfo->geometry=boundingArea;
1876 drawInfo->gravity=gravity_;
1878 oaffine=drawInfo->affine;
1879 if (degrees_ != 0.0)
1892 current=drawInfo->affine;
1893 affine.sx=cos(DegreesToRadians(fmod(degrees_,360.0)));
1894 affine.rx=sin(DegreesToRadians(fmod(degrees_,360.0)));
1895 affine.ry=(-sin(DegreesToRadians(fmod(degrees_,360.0))));
1896 affine.sy=cos(DegreesToRadians(fmod(degrees_,360.0)));
1898 drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
1899 drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
1900 drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
1901 drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
1902 drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty
1907 AnnotateImage(image(),drawInfo,&exceptionInfo);
1909 // Restore original values
1910 drawInfo->affine=oaffine;
1912 drawInfo->geometry=0;
1917 void Magick::Image::annotate(const std::string &text_,
1918 const GravityType gravity_)
1925 drawInfo=options()->drawInfo();
1926 drawInfo->text=const_cast<char *>(text_.c_str());
1927 drawInfo->gravity=gravity_;
1930 AnnotateImage(image(),drawInfo,&exceptionInfo);
1932 drawInfo->gravity=NorthWestGravity;
1938 void Magick::Image::artifact(const std::string &name_,const std::string &value_)
1941 (void) SetImageArtifact(image(),name_.c_str(),value_.c_str());
1944 std::string Magick::Image::artifact(const std::string &name_)
1949 value=GetImageArtifact(constImage(),name_.c_str());
1951 return(std::string(value));
1952 return(std::string());
1955 void Magick::Image::attribute(const std::string name_,const std::string value_)
1959 SetImageProperty(image(),name_.c_str(),value_.c_str(),&exceptionInfo);
1963 std::string Magick::Image::attribute(const std::string name_)
1969 value=GetImageProperty(constImage(),name_.c_str(),&exceptionInfo);
1973 return(std::string(value));
1975 return(std::string()); // Intentionally no exception
1978 void Magick::Image::autoGamma(void)
1982 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
1983 (void) AutoGammaImage(image(),&exceptionInfo);
1987 void Magick::Image::autoGammaChannel(const ChannelType channel_)
1991 SetPPChannelMask(channel_);
1992 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
1993 (void) AutoGammaImage(image(),&exceptionInfo);
1994 RestorePPChannelMask;
1998 void Magick::Image::autoLevel(void)
2002 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
2003 (void) AutoLevelImage(image(),&exceptionInfo);
2007 void Magick::Image::autoLevelChannel(const ChannelType channel_)
2011 SetPPChannelMask(channel_);
2012 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
2013 (void) AutoLevelImage(image(),&exceptionInfo);
2014 RestorePPChannelMask;
2018 void Magick::Image::autoOrient(void)
2023 if (image()->orientation == UndefinedOrientation ||
2024 image()->orientation == TopLeftOrientation)
2028 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
2029 newImage=AutoOrientImage(constImage(),image()->orientation,&exceptionInfo);
2030 replaceImage(newImage);
2034 void Magick::Image::blackThreshold(const std::string &threshold_)
2038 BlackThresholdImage(image(),threshold_.c_str(),&exceptionInfo);
2042 void Magick::Image::blackThresholdChannel(const ChannelType channel_,
2043 const std::string &threshold_)
2047 SetPPChannelMask(channel_);
2048 BlackThresholdImage(image(),threshold_.c_str(),&exceptionInfo);
2049 RestorePPChannelMask;
2053 void Magick::Image::blueShift(const double factor_)
2059 newImage=BlueShiftImage(constImage(),factor_,&exceptionInfo);
2060 replaceImage(newImage);
2064 void Magick::Image::blur(const double radius_,const double sigma_)
2070 newImage=BlurImage(constImage(),radius_,sigma_,&exceptionInfo);
2071 replaceImage(newImage);
2075 void Magick::Image::blurChannel(const ChannelType channel_,
2076 const double radius_,const double sigma_)
2082 SetPPChannelMask(channel_);
2083 newImage=BlurImage(constImage(),radius_,sigma_,&exceptionInfo);
2084 RestorePPChannelMask;
2085 replaceImage(newImage);
2089 void Magick::Image::border(const Geometry &geometry_)
2095 borderInfo=geometry_;
2098 newImage=BorderImage(constImage(),&borderInfo,image()->compose,
2100 replaceImage(newImage);
2104 void Magick::Image::brightnessContrast(const double brightness_,
2105 const double contrast_)
2109 BrightnessContrastImage(image(),brightness_,contrast_,&exceptionInfo);
2113 void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
2114 const double brightness_,const double contrast_)
2118 SetPPChannelMask(channel_);
2119 BrightnessContrastImage(image(),brightness_,contrast_,&exceptionInfo);
2120 RestorePPChannelMask;
2124 void Magick::Image::cannyEdge(const double radius_,const double sigma_,
2125 const double lowerPercent_,const double upperPercent_)
2132 newImage=CannyEdgeImage(constImage(),radius_,sigma_,lowerPercent_,
2133 upperPercent_,&exceptionInfo);
2134 replaceImage(newImage);
2138 void Magick::Image::channel(const ChannelType channel_)
2144 newImage=SeparateImage(image(),channel_,&exceptionInfo);
2145 replaceImage(newImage);
2149 void Magick::Image::charcoal(const double radius_,const double sigma_)
2155 newImage=CharcoalImage(image(),radius_,sigma_,&exceptionInfo);
2156 replaceImage(newImage);
2160 void Magick::Image::chop(const Geometry &geometry_)
2169 newImage=ChopImage(image(),&chopInfo,&exceptionInfo);
2170 replaceImage(newImage);
2174 void Magick::Image::chromaBluePrimary(const double x_,const double y_)
2177 image()->chromaticity.blue_primary.x=x_;
2178 image()->chromaticity.blue_primary.y=y_;
2181 void Magick::Image::chromaBluePrimary(double *x_,double *y_) const
2183 *x_=constImage()->chromaticity.blue_primary.x;
2184 *y_=constImage()->chromaticity.blue_primary.y;
2187 void Magick::Image::chromaGreenPrimary(const double x_,const double y_)
2190 image()->chromaticity.green_primary.x=x_;
2191 image()->chromaticity.green_primary.y=y_;
2194 void Magick::Image::chromaGreenPrimary(double *x_,double *y_) const
2196 *x_=constImage()->chromaticity.green_primary.x;
2197 *y_=constImage()->chromaticity.green_primary.y;
2200 void Magick::Image::chromaRedPrimary(const double x_,const double y_)
2203 image()->chromaticity.red_primary.x=x_;
2204 image()->chromaticity.red_primary.y=y_;
2207 void Magick::Image::chromaRedPrimary(double *x_,double *y_) const
2209 *x_=constImage()->chromaticity.red_primary.x;
2210 *y_=constImage()->chromaticity.red_primary.y;
2213 void Magick::Image::chromaWhitePoint(const double x_,const double y_)
2216 image()->chromaticity.white_point.x=x_;
2217 image()->chromaticity.white_point.y=y_;
2220 void Magick::Image::chromaWhitePoint(double *x_,double *y_) const
2222 *x_=constImage()->chromaticity.white_point.x;
2223 *y_=constImage()->chromaticity.white_point.y;
2226 void Magick::Image::cdl(const std::string &cdl_)
2230 (void) ColorDecisionListImage(image(),cdl_.c_str(),&exceptionInfo);
2234 void Magick::Image::clamp(void)
2238 ClampImage(image(),&exceptionInfo);
2242 void Magick::Image::clampChannel(const ChannelType channel_)
2246 SetPPChannelMask(channel_);
2247 ClampImage(image(),&exceptionInfo);
2248 RestorePPChannelMask;
2252 void Magick::Image::clip(void)
2256 ClipImage(image(),&exceptionInfo);
2260 void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
2264 ClipImagePath(image(),pathname_.c_str(),(MagickBooleanType) inside_,
2269 void Magick::Image::clut(const Image &clutImage_,
2270 const PixelInterpolateMethod method)
2274 ClutImage(image(),clutImage_.constImage(),method,&exceptionInfo);
2278 void Magick::Image::clutChannel(const ChannelType channel_,
2279 const Image &clutImage_,const PixelInterpolateMethod method)
2283 SetPPChannelMask(channel_);
2284 ClutImage(image(),clutImage_.constImage(),method,&exceptionInfo);
2285 RestorePPChannelMask;
2289 void Magick::Image::colorize(const unsigned int alpha_,const Color &penColor_)
2291 colorize(alpha_,alpha_,alpha_,penColor_);
2294 void Magick::Image::colorize(const unsigned int alphaRed_,
2295 const unsigned int alphaGreen_,const unsigned int alphaBlue_,
2296 const Color &penColor_)
2299 blend[MaxTextExtent];
2308 if (!penColor_.isValid())
2309 throwExceptionExplicit(OptionError,"Pen color argument is invalid");
2311 FormatLocaleString(blend,MaxTextExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
2314 GetPixelInfo(image(),&target);
2315 pixel=static_cast<PixelInfo>(penColor_);
2316 target.red=pixel.red;
2317 target.green=pixel.green;
2318 target.blue=pixel.blue;
2319 target.alpha=pixel.alpha;
2321 newImage=ColorizeImage(image(),blend,&target,&exceptionInfo);
2322 replaceImage(newImage);
2326 void Magick::Image::colorMap(const size_t index_,const Color &color_)
2333 if (index_ > (MaxColormapSize-1))
2334 throwExceptionExplicit(OptionError,
2335 "Colormap index must be less than MaxColormapSize");
2337 if (!color_.isValid())
2338 throwExceptionExplicit(OptionError,"Color argument is invalid");
2342 // Ensure that colormap size is large enough
2343 if (colorMapSize() < (index_+1))
2344 colorMapSize(index_+1);
2346 // Set color at index in colormap
2347 (imageptr->colormap)[index_]=color_;
2350 Magick::Color Magick::Image::colorMap(const size_t index_) const
2352 if (!constImage()->colormap)
2354 throwExceptionExplicit(OptionError,"Image does not contain a colormap");
2358 if (index_ > constImage()->colors-1)
2359 throwExceptionExplicit(OptionError,"Index out of range");
2361 return(Magick::Color((constImage()->colormap)[index_]));
2364 void Magick::Image::colorMatrix(const size_t order_,
2365 const double *color_matrix_)
2371 kernel_info=AcquireKernelInfo((const char *) NULL);
2372 if (kernel_info != (KernelInfo *) NULL)
2374 kernel_info->width=order_;
2375 kernel_info->height=order_;
2376 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2377 order_*sizeof(*kernel_info->values));
2378 if (kernel_info->values != (MagickRealType *) NULL)
2383 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2384 kernel_info->values[i]=color_matrix_[i];
2385 newImage=ColorMatrixImage(image(),kernel_info,&exceptionInfo);
2386 replaceImage(newImage);
2388 kernel_info=DestroyKernelInfo(kernel_info);
2393 bool Magick::Image::compare(const Image &reference_)
2404 status=static_cast<bool>(IsImagesEqual(image(),ref.image(),&exceptionInfo));
2409 double Magick::Image::compare(const Image &reference_,const MetricType metric_)
2415 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2421 double Magick::Image::compareChannel(const ChannelType channel_,
2422 const Image &reference_,const MetricType metric_)
2428 SetPPChannelMask(channel_);
2429 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2431 RestorePPChannelMask;
2436 Magick::Image Magick::Image::compare(const Image &reference_,
2437 const MetricType metric_,double *distortion)
2443 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2446 if (newImage == (MagickCore::Image *) NULL)
2447 return(Magick::Image());
2449 return(Magick::Image(newImage));
2452 Magick::Image Magick::Image::compareChannel(const ChannelType channel_,
2453 const Image &reference_,const MetricType metric_,double *distortion)
2459 SetPPChannelMask(channel_);
2460 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2462 RestorePPChannelMask;
2464 if (newImage == (MagickCore::Image *) NULL)
2465 return(Magick::Image());
2467 return(Magick::Image(newImage));
2470 void Magick::Image::composite(const Image &compositeImage_,
2471 const Geometry &offset_,const CompositeOperator compose_)
2481 ParseMetaGeometry(static_cast<std::string>(offset_).c_str(),&x,&y,&width,
2486 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickFalse,
2487 x,y,&exceptionInfo);
2491 void Magick::Image::composite(const Image &compositeImage_,
2492 const GravityType gravity_,const CompositeOperator compose_)
2498 SetGeometry(compositeImage_.constImage(),&geometry);
2499 GravityAdjustGeometry(columns(),rows(),gravity_,&geometry);
2502 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickFalse,
2503 geometry.x,geometry.y,&exceptionInfo);
2507 void Magick::Image::composite(const Image &compositeImage_,
2508 const ssize_t xOffset_,const ssize_t yOffset_,
2509 const CompositeOperator compose_)
2511 // Image supplied as compositeImage is composited with current image and
2512 // results in updating current image.
2515 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickFalse,
2516 xOffset_,yOffset_,&exceptionInfo);
2520 void Magick::Image::contrast(const size_t sharpen_)
2524 ContrastImage(image(),(MagickBooleanType) sharpen_,&exceptionInfo);
2528 void Magick::Image::contrastStretch(const double blackPoint_,
2529 const double whitePoint_)
2533 ContrastStretchImage(image(),blackPoint_,whitePoint_,&exceptionInfo);
2537 void Magick::Image::contrastStretchChannel(const ChannelType channel_,
2538 const double blackPoint_,const double whitePoint_)
2542 SetPPChannelMask(channel_);
2543 ContrastStretchImage(image(),blackPoint_,whitePoint_,&exceptionInfo);
2544 RestorePPChannelMask;
2548 void Magick::Image::convolve(const size_t order_,const double *kernel_)
2554 kernel_info=AcquireKernelInfo((const char *) NULL);
2555 kernel_info->width=order_;
2556 kernel_info->height=order_;
2557 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2558 order_*sizeof(*kernel_info->values));
2559 if (kernel_info->values != (MagickRealType *) NULL)
2564 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2565 kernel_info->values[i]=kernel_[i];
2566 newImage=ConvolveImage(image(),kernel_info,&exceptionInfo);
2567 replaceImage(newImage);
2569 kernel_info=DestroyKernelInfo(kernel_info);
2573 void Magick::Image::crop(const Geometry &geometry_)
2582 newImage=CropImage(constImage(),&cropInfo,&exceptionInfo);
2583 replaceImage(newImage);
2587 void Magick::Image::cycleColormap(const ssize_t amount_)
2591 CycleColormapImage(image(),amount_,&exceptionInfo);
2595 void Magick::Image::decipher(const std::string &passphrase_)
2599 DecipherImage(image(),passphrase_.c_str(),&exceptionInfo);
2603 void Magick::Image::defineSet(const std::string &magick_,
2604 const std::string &key_,bool flag_)
2610 definition=magick_ + ":" + key_;
2612 (void) SetImageOption(imageInfo(),definition.c_str(),"");
2614 DeleteImageOption(imageInfo(),definition.c_str());
2617 bool Magick::Image::defineSet(const std::string &magick_,
2618 const std::string &key_ ) const
2626 key=magick_ + ":" + key_;
2627 option=GetImageOption(constImageInfo(),key.c_str());
2633 void Magick::Image::defineValue(const std::string &magick_,
2634 const std::string &key_,const std::string &value_)
2641 format=magick_ + ":" + key_;
2643 (void) SetImageOption(imageInfo(),format.c_str(),option.c_str());
2646 std::string Magick::Image::defineValue(const std::string &magick_,
2647 const std::string &key_) const
2655 definition=magick_ + ":" + key_;
2656 option=GetImageOption(constImageInfo(),definition.c_str());
2658 return(std::string(option));
2659 return(std::string());
2662 void Magick::Image::deskew(const double threshold_)
2668 newImage=DeskewImage(constImage(),threshold_,&exceptionInfo);
2669 replaceImage(newImage);
2673 void Magick::Image::despeckle(void)
2679 newImage=DespeckleImage(constImage(),&exceptionInfo);
2680 replaceImage(newImage);
2684 Magick::ImageType Magick::Image::determineType(void) const
2690 image_type=GetImageType(constImage(),&exceptionInfo);
2695 void Magick::Image::display(void)
2698 DisplayImages(imageInfo(),image(),&exceptionInfo);
2702 void Magick::Image::distort(const DistortImageMethod method_,
2703 const size_t numberArguments_,const double *arguments_,const bool bestfit_)
2709 newImage=DistortImage(constImage(), method_,numberArguments_,arguments_,
2710 bestfit_ == true ? MagickTrue : MagickFalse,&exceptionInfo);
2711 replaceImage(newImage);
2715 void Magick::Image::draw(const Magick::Drawable &drawable_)
2722 wand=DrawAllocateWand(options()->drawInfo(),image());
2726 drawable_.operator()(wand);
2730 ClonePPDrawException(wand);
2731 wand=DestroyDrawingWand(wand);
2732 ThrowPPDrawException;
2736 void Magick::Image::draw(const std::list<Magick::Drawable> &drawable_)
2743 wand=DrawAllocateWand(options()->drawInfo(),image());
2747 for (std::list<Magick::Drawable>::const_iterator p = drawable_.begin();
2748 p != drawable_.end(); p++ )
2750 p->operator()(wand);
2751 if (DrawGetExceptionType(wand) != UndefinedException)
2755 if (DrawGetExceptionType(wand) == UndefinedException)
2758 ClonePPDrawException(wand);
2759 wand=DestroyDrawingWand(wand);
2760 ThrowPPDrawException;
2764 void Magick::Image::edge(const double radius_)
2770 newImage=EdgeImage(constImage(),radius_,&exceptionInfo);
2771 replaceImage(newImage);
2775 void Magick::Image::emboss(const double radius_,const double sigma_)
2781 newImage=EmbossImage(constImage(),radius_,sigma_,&exceptionInfo);
2782 replaceImage(newImage);
2786 void Magick::Image::encipher(const std::string &passphrase_)
2790 EncipherImage(image(),passphrase_.c_str(),&exceptionInfo);
2794 void Magick::Image::enhance(void)
2800 newImage=EnhanceImage(constImage(),&exceptionInfo);
2801 replaceImage(newImage);
2805 void Magick::Image::equalize(void)
2809 EqualizeImage(image(),&exceptionInfo);
2813 void Magick::Image::erase(void)
2817 (void) SetImageBackgroundColor(image(),&exceptionInfo);
2821 void Magick::Image::extent(const Geometry &geometry_ )
2827 extentInfo=geometry_;
2830 extentInfo.x=geometry_.xOff();
2831 extentInfo.y=geometry_.yOff();
2833 newImage=ExtentImage(image(),&extentInfo,&exceptionInfo);
2834 replaceImage(newImage);
2838 void Magick::Image::extent(const Geometry &geometry_,
2839 const Color &backgroundColor_)
2841 backgroundColor(backgroundColor_);
2845 void Magick::Image::extent(const Geometry &geometry_,
2846 const Color &backgroundColor_,const GravityType gravity_)
2848 backgroundColor(backgroundColor_);
2849 extent(geometry_,gravity_);
2852 void Magick::Image::extent(const Geometry &geometry_,
2853 const GravityType gravity_)
2858 SetGeometry(image(),&geometry);
2859 geometry.width=geometry_.width();
2860 geometry.height=geometry_.height();
2861 GravityAdjustGeometry(image()->columns,image()->rows,gravity_,&geometry);
2865 void Magick::Image::flip(void)
2871 newImage=FlipImage(constImage(),&exceptionInfo);
2872 replaceImage(newImage);
2876 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2877 const unsigned int alpha_,const PaintMethod method_)
2884 GetPixelInfo(image(),&target);
2885 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2886 target.red=pixel.red;
2887 target.green=pixel.green;
2888 target.blue=pixel.blue;
2889 target.alpha=alpha_;
2892 FloodfillPaintImage(image(),options()->drawInfo(),&target,
2893 static_cast<ssize_t>(x_), static_cast<ssize_t>(y_),
2894 method_ == FloodfillMethod ? MagickFalse : MagickTrue,&exceptionInfo);
2898 void Magick::Image::floodFillColor(const Geometry &point_,
2899 const Magick::Color &fillColor_)
2901 floodFillTexture(point_,Image(Geometry(1,1),fillColor_));
2904 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2905 const Magick::Color &fillColor_)
2907 floodFillTexture(x_,y_,Image(Geometry(1,1),fillColor_));
2910 void Magick::Image::floodFillColor(const Geometry &point_,
2911 const Magick::Color &fillColor_,const Magick::Color &borderColor_)
2913 floodFillTexture(point_,Image(Geometry(1,1),fillColor_),borderColor_);
2916 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2917 const Magick::Color &fillColor_,const Magick::Color &borderColor_)
2919 floodFillTexture(x_,y_,Image(Geometry(1,1),fillColor_),borderColor_);
2922 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2923 const Magick::Image &texture_)
2925 floodFillTexture(point_.xOff(),point_.yOff(),texture_);
2928 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2929 const Magick::Image &texture_)
2939 // Set drawing fill pattern
2940 fillPattern=(MagickCore::Image *)NULL;
2941 if (options()->fillPattern() != (MagickCore::Image *)NULL)
2944 fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
2948 options()->fillPattern(texture_.constImage());
2951 Pixels pixels(*this);
2953 p=pixels.get(x_,y_,1,1);
2960 GetPixelInfo(constImage(),&target);
2961 target.red=GetPixelRed(constImage(),p);
2962 target.green=GetPixelGreen(constImage(),p);
2963 target.blue=GetPixelBlue(constImage(),p);
2965 FloodfillPaintImage(image(),options()->drawInfo(),&target,
2966 static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),MagickFalse,
2968 options()->fillPattern(fillPattern);
2972 options()->fillPattern(fillPattern);
2975 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2976 const Magick::Image &texture_,const Magick::Color &borderColor_)
2978 floodFillTexture(point_.xOff(),point_.yOff(),texture_,borderColor_);
2981 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2982 const Magick::Image &texture_,const Magick::Color &borderColor_)
2992 // Set drawing fill pattern
2993 fillPattern=(MagickCore::Image *)NULL;
2994 if (options()->fillPattern() != (MagickCore::Image *)NULL)
2997 fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
3001 options()->fillPattern(texture_.constImage());
3003 GetPixelInfo(constImage(),&target);
3004 target.red=static_cast<PixelInfo>(borderColor_).red;
3005 target.green=static_cast<PixelInfo>(borderColor_).green;
3006 target.blue=static_cast<PixelInfo>(borderColor_).blue;
3008 FloodfillPaintImage(image(),options()->drawInfo(),&target,
3009 static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),MagickTrue,
3011 options()->fillPattern(fillPattern);
3015 void Magick::Image::flop(void)
3021 newImage=FlopImage(constImage(),&exceptionInfo);
3022 replaceImage(newImage);
3026 void Magick::Image::fontTypeMetrics(const std::string &text_,
3027 TypeMetric *metrics)
3032 drawInfo=options()->drawInfo();
3033 drawInfo->text=const_cast<char *>(text_.c_str());
3035 GetTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),&exceptionInfo);
3040 void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
3041 TypeMetric *metrics)
3046 drawInfo=options()->drawInfo();
3047 drawInfo->text=const_cast<char *>(text_.c_str());
3049 GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),&exceptionInfo);
3054 void Magick::Image::frame(const Geometry &geometry_)
3062 info.x=static_cast<ssize_t>(geometry_.width());
3063 info.y=static_cast<ssize_t>(geometry_.height());
3064 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3065 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3066 info.outer_bevel=geometry_.xOff();
3067 info.inner_bevel=geometry_.yOff();
3070 newImage=FrameImage(constImage(),&info,image()->compose,&exceptionInfo);
3071 replaceImage(newImage);
3075 void Magick::Image::frame(const size_t width_,const size_t height_,
3076 const ssize_t outerBevel_,const ssize_t innerBevel_)
3084 info.x=static_cast<ssize_t>(width_);
3085 info.y=static_cast<ssize_t>(height_);
3086 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3087 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3088 info.outer_bevel=static_cast<ssize_t>(outerBevel_);
3089 info.inner_bevel=static_cast<ssize_t>(innerBevel_);
3092 newImage=FrameImage(constImage(),&info,image()->compose,&exceptionInfo);
3093 replaceImage(newImage);
3097 void Magick::Image::fx(const std::string expression_)
3103 newImage=FxImage(constImage(),expression_.c_str(),&exceptionInfo);
3104 replaceImage(newImage);
3108 void Magick::Image::fx(const std::string expression_,
3109 const Magick::ChannelType channel_)
3115 SetPPChannelMask(channel_);
3116 newImage=FxImage(constImage(),expression_.c_str(),&exceptionInfo);
3117 RestorePPChannelMask;
3118 replaceImage(newImage);
3122 void Magick::Image::gamma(const double gamma_)
3126 GammaImage(image(),gamma_,&exceptionInfo);
3130 void Magick::Image::gamma(const double gammaRed_,const double gammaGreen_,
3131 const double gammaBlue_)
3134 gamma[MaxTextExtent + 1];
3136 FormatLocaleString(gamma,MaxTextExtent,"%3.6f/%3.6f/%3.6f/",gammaRed_,
3137 gammaGreen_,gammaBlue_);
3141 GammaImage(image(),atof(gamma),&exceptionInfo);
3145 void Magick::Image::gaussianBlur(const double width_,const double sigma_)
3151 newImage=GaussianBlurImage(constImage(),width_,sigma_,&exceptionInfo);
3152 replaceImage(newImage);
3156 void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
3157 const double width_,const double sigma_)
3163 SetPPChannelMask(channel_);
3164 newImage=GaussianBlurImage(constImage(),width_,sigma_,&exceptionInfo);
3165 RestorePPChannelMask;
3166 replaceImage(newImage);
3170 const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
3171 const ssize_t y_,const size_t columns_,const size_t rows_) const
3177 p=(*GetVirtualPixels)(constImage(),x_, y_,columns_, rows_,&exceptionInfo);
3182 const void *Magick::Image::getConstMetacontent(void) const
3187 result=GetVirtualMetacontent(constImage());
3190 throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
3195 void *Magick::Image::getMetacontent(void )
3200 result=GetAuthenticMetacontent(image());
3203 throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
3208 Magick::Quantum *Magick::Image::getPixels(const ssize_t x_,const ssize_t y_,
3209 const size_t columns_,const size_t rows_)
3216 result=(*GetAuthenticPixels)(image(),x_, y_,columns_,rows_,&exceptionInfo);
3222 void Magick::Image::haldClut(const Image &clutImage_)
3226 (void) HaldClutImage(image(),clutImage_.constImage(),&exceptionInfo);
3230 void Magick::Image::houghLine(const size_t width_,const size_t height_,
3231 const size_t threshold_)
3237 newImage=HoughLineImage(constImage(),width_,height_,threshold_,
3239 replaceImage(newImage);
3243 void Magick::Image::implode(const double factor_)
3249 newImage=ImplodeImage(constImage(),factor_,image()->interpolate,
3251 replaceImage(newImage);
3255 void Magick::Image::inverseFourierTransform(const Image &phase_)
3257 inverseFourierTransform(phase_,true);
3260 void Magick::Image::inverseFourierTransform(const Image &phase_,
3261 const bool magnitude_)
3267 newImage=InverseFourierTransformImage(constImage(),phase_.constImage(),
3268 magnitude_ == true ? MagickTrue : MagickFalse,&exceptionInfo);
3269 replaceImage(newImage);
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_)
3459 kernel=AcquireKernelInfo(kernel_.c_str());
3460 if (kernel == (KernelInfo *)NULL)
3461 throwExceptionExplicit(OptionError,"Unable to parse kernel.");
3464 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3466 replaceImage(newImage);
3467 kernel=DestroyKernelInfo(kernel);
3471 void Magick::Image::morphology(const MorphologyMethod method_,
3472 const KernelInfoType kernel_,const std::string arguments_,
3473 const ssize_t iterations_)
3481 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3482 if (option == (const char *)NULL)
3483 throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
3485 kernel=std::string(option);
3486 if (!arguments_.empty())
3487 kernel+=":"+arguments_;
3489 morphology(method_,kernel,iterations_);
3492 void Magick::Image::morphologyChannel(const ChannelType channel_,
3493 const MorphologyMethod method_,const std::string kernel_,
3494 const ssize_t iterations_)
3502 kernel=AcquireKernelInfo(kernel_.c_str());
3503 if (kernel == (KernelInfo *)NULL)
3504 throwExceptionExplicit(OptionError,"Unable to parse kernel.");
3507 SetPPChannelMask(channel_);
3508 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3510 RestorePPChannelMask;
3511 replaceImage(newImage);
3512 kernel=DestroyKernelInfo(kernel);
3516 void Magick::Image::morphologyChannel(const ChannelType channel_,
3517 const MorphologyMethod method_,const KernelInfoType kernel_,
3518 const std::string arguments_,const ssize_t iterations_)
3526 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3527 if (option == (const char *)NULL)
3528 throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
3530 kernel=std::string(option);
3531 if (!arguments_.empty())
3532 kernel+=":"+arguments_;
3534 morphologyChannel(channel_,method_,kernel,iterations_);
3537 void Magick::Image::motionBlur(const double radius_,const double sigma_,
3538 const double angle_)
3544 newImage=MotionBlurImage(constImage(),radius_,sigma_,angle_,&exceptionInfo);
3545 replaceImage(newImage);
3549 void Magick::Image::negate(const bool grayscale_)
3553 NegateImage(image(),(MagickBooleanType) grayscale_,&exceptionInfo);
3557 void Magick::Image::negateChannel(const ChannelType channel_,
3558 const bool grayscale_)
3562 SetPPChannelMask(channel_);
3563 NegateImage(image(),(MagickBooleanType) grayscale_,&exceptionInfo);
3564 RestorePPChannelMask;
3568 void Magick::Image::normalize(void)
3572 NormalizeImage(image(),&exceptionInfo);
3576 void Magick::Image::oilPaint(const double radius_,const double sigma_)
3582 newImage=OilPaintImage(constImage(),radius_,sigma_,&exceptionInfo);
3583 replaceImage(newImage);
3587 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,MagickFalse,&exceptionInfo);
3616 void Magick::Image::orderedDither(std::string thresholdMap_)
3620 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),&exceptionInfo);
3624 void Magick::Image::orderedDitherChannel(const ChannelType channel_,
3625 std::string thresholdMap_)
3629 SetPPChannelMask(channel_);
3630 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),&exceptionInfo);
3631 RestorePPChannelMask;
3635 void Magick::Image::perceptible(const double epsilon_)
3639 PerceptibleImage(image(),epsilon_,&exceptionInfo);
3643 void Magick::Image::perceptibleChannel(const ChannelType channel_,
3644 const double epsilon_)
3648 SetPPChannelMask(channel_);
3649 PerceptibleImage(image(),epsilon_,&exceptionInfo);
3650 RestorePPChannelMask;
3654 void Magick::Image::ping(const std::string &imageSpec_)
3660 options()->fileName(imageSpec_);
3661 newImage=PingImage(imageInfo(),&exceptionInfo);
3662 replaceImage(newImage);
3666 void Magick::Image::ping(const Blob& blob_)
3672 newImage=PingBlob(imageInfo(),blob_.data(),blob_.length(),&exceptionInfo);
3673 replaceImage(newImage);
3677 void Magick::Image::pixelColor(const ssize_t x_,const ssize_t y_,
3678 const Color &color_)
3686 // Test arguments to ensure they are within the image.
3687 if (y_ > (ssize_t) rows() || x_ > (ssize_t) columns())
3688 throwExceptionExplicit(OptionError,"Access outside of image boundary");
3692 // Set image to DirectClass
3693 classType(DirectClass );
3696 Pixels pixels(*this);
3698 pixel=pixels.get(x_, y_, 1, 1 );
3700 MagickCore::SetPixelInfoPixel(constImage(),&packet,pixel);
3701 // Tell ImageMagick that pixels have been updated
3705 Magick::Color Magick::Image::pixelColor(const ssize_t x_,
3706 const ssize_t y_) const
3711 pixel=getConstPixels(x_,y_,1,1);
3717 MagickCore::GetPixelInfoPixel(constImage(),pixel,&packet);
3718 return(Color(packet));
3721 return(Color()); // invalid
3724 void Magick::Image::polaroid(const std::string &caption_,const double angle_,
3725 const PixelInterpolateMethod method_)
3731 newImage=PolaroidImage(constImage(),options()->drawInfo(),caption_.c_str(),
3732 angle_,method_,&exceptionInfo);
3733 replaceImage(newImage);
3737 void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
3741 PosterizeImage(image(),levels_,method_,&exceptionInfo);
3745 void Magick::Image::posterizeChannel(const ChannelType channel_,
3746 const size_t levels_,const DitherMethod method_)
3750 SetPPChannelMask(channel_);
3751 PosterizeImage(image(),levels_,method_,&exceptionInfo);
3752 RestorePPChannelMask;
3756 void Magick::Image::process(std::string name_,const ssize_t argc,
3762 (void) InvokeDynamicImageFilter(name_.c_str(),&image(),argc,argv,
3767 void Magick::Image::profile(const std::string name_,
3768 const Magick::Blob &profile_)
3772 (void) ProfileImage(image(),name_.c_str(),(unsigned char *)profile_.data(),
3773 profile_.length(),&exceptionInfo);
3777 Magick::Blob Magick::Image::profile(const std::string name_) const
3782 profile=GetImageProfile(constImage(),name_.c_str());
3784 if (profile == (StringInfo *) NULL)
3786 return(Blob((void*) GetStringInfoDatum(profile),GetStringInfoLength(
3790 void Magick::Image::quantize(const bool measureError_)
3795 options()->quantizeInfo()->measure_error=MagickTrue;
3797 options()->quantizeInfo()->measure_error=MagickFalse;
3800 QuantizeImage(options()->quantizeInfo(),image(),&exceptionInfo);
3804 void Magick::Image::quantumOperator(const ChannelType channel_,
3805 const MagickEvaluateOperator operator_,double rvalue_)
3808 SetPPChannelMask(channel_);
3809 EvaluateImage(image(),operator_,rvalue_,&exceptionInfo);
3810 RestorePPChannelMask;
3814 void Magick::Image::quantumOperator(const ssize_t x_,const ssize_t y_,
3815 const size_t columns_,const size_t rows_,const ChannelType channel_,
3816 const MagickEvaluateOperator operator_,const double rvalue_)
3824 geometry.width = columns_;
3825 geometry.height = rows_;
3830 cropImage=CropImage(image(),&geometry,&exceptionInfo);
3831 SetPPChannelMask(channel_);
3832 EvaluateImage(cropImage,operator_,rvalue_,&exceptionInfo);
3833 RestorePPChannelMask;
3834 (void) CompositeImage(image(),cropImage,image()->alpha_trait ==
3835 BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
3836 geometry.x,geometry.y,&exceptionInfo );
3837 cropImage=DestroyImageList(cropImage);
3841 void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
3844 raiseInfo=geometry_;
3848 RaiseImage(image(),&raiseInfo,raisedFlag_ == true ? MagickTrue : MagickFalse,
3853 void Magick::Image::randomThreshold(const Geometry &thresholds_)
3856 (void) RandomThresholdImage(image(),static_cast<std::string>(
3857 thresholds_).c_str(),&exceptionInfo);
3861 void Magick::Image::randomThresholdChannel(const ChannelType channel_,
3862 const Geometry &thresholds_)
3866 SetPPChannelMask(channel_);
3867 (void) RandomThresholdImage(image(),static_cast<std::string>(
3868 thresholds_).c_str(),&exceptionInfo);
3869 RestorePPChannelMask;
3873 void Magick::Image::read(const Blob &blob_)
3879 newImage=BlobToImage(imageInfo(),static_cast<const void *>(blob_.data()),
3880 blob_.length(),&exceptionInfo);
3881 replaceImage(newImage);
3885 void Magick::Image::read(const Blob &blob_,const Geometry &size_)
3891 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3892 const size_t depth_)
3899 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3900 const size_t depth_,const std::string &magick_)
3905 // Set explicit image format
3906 fileName(magick_ + ':');
3910 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3911 const std::string &magick_)
3915 // Set explicit image format
3916 fileName(magick_ + ':');
3920 void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_)
3926 void Magick::Image::read(const size_t width_,const size_t height_,
3927 const std::string &map_,const StorageType type_,const void *pixels_)
3933 newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
3935 replaceImage(newImage);
3939 void Magick::Image::read(const std::string &imageSpec_)
3945 options()->fileName(imageSpec_);
3946 newImage=ReadImage(imageInfo(),&exceptionInfo);
3948 // Ensure that multiple image frames were not read.
3949 if (newImage && newImage->next)
3954 // Destroy any extra image frames
3955 next=newImage->next;
3958 DestroyImageList(next);
3960 replaceImage(newImage);
3964 void Magick::Image::readPixels(const Magick::QuantumType quantum_,
3965 const unsigned char *source_)
3970 quantum_info=AcquireQuantumInfo(imageInfo(),image());
3972 ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
3973 quantum_,source_,&exceptionInfo);
3974 quantum_info=DestroyQuantumInfo(quantum_info);
3978 void Magick::Image::reduceNoise(void)
3983 void Magick::Image::reduceNoise(const double order_)
3989 newImage=StatisticImage(constImage(),NonpeakStatistic,(size_t) order_,
3990 (size_t) order_,&exceptionInfo);
3991 replaceImage(newImage);
3995 void Magick::Image::resample(const Geometry &geometry_)
4008 // Calculate new size. This code should be supported using binary arguments
4009 // in the ImageMagick library.
4010 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4014 newImage=ResampleImage(constImage(),width,height,image()->filter,
4016 replaceImage(newImage);
4020 void Magick::Image::resize(const Geometry &geometry_)
4033 // Calculate new size. This code should be supported using binary arguments
4034 // in the ImageMagick library.
4035 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4039 newImage=ResizeImage(constImage(),width,height,image()->filter,
4041 replaceImage(newImage);
4045 void Magick::Image::roll(const Geometry &roll_)
4054 if (roll_.xNegative())
4056 if (roll_.yNegative())
4060 newImage=RollImage(constImage(),xOff,yOff,&exceptionInfo);
4061 replaceImage(newImage);
4065 void Magick::Image::roll(const size_t columns_,const size_t rows_)
4071 newImage=RollImage(constImage(),static_cast<ssize_t>(columns_),
4072 static_cast<ssize_t>(rows_),&exceptionInfo);
4073 replaceImage(newImage);
4077 void Magick::Image::rotate(const double degrees_)
4083 newImage=RotateImage(constImage(),degrees_,&exceptionInfo);
4084 replaceImage(newImage);
4088 void Magick::Image::rotationalBlur(const double angle_)
4094 newImage=RotationalBlurImage(constImage(),angle_,&exceptionInfo);
4095 replaceImage(newImage);
4099 void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
4100 const double angle_)
4106 SetPPChannelMask(channel_);
4107 newImage=RotationalBlurImage(constImage(),angle_,&exceptionInfo);
4108 RestorePPChannelMask;
4109 replaceImage(newImage);
4113 void Magick::Image::sample(const Geometry &geometry_)
4126 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4130 newImage=SampleImage(constImage(),width,height,&exceptionInfo);
4131 replaceImage(newImage);
4135 void Magick::Image::scale(const Geometry &geometry_)
4148 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4152 newImage=ScaleImage(constImage(),width,height,&exceptionInfo);
4153 replaceImage(newImage);
4157 void Magick::Image::segment(const double clusterThreshold_,
4158 const double smoothingThreshold_)
4162 SegmentImage(image(),options()->quantizeColorSpace(),
4163 (MagickBooleanType) options()->verbose(),clusterThreshold_,
4164 smoothingThreshold_,&exceptionInfo);
4165 SyncImage(image(),&exceptionInfo);
4169 void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
4170 const double threshold_)
4176 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4178 replaceImage(newImage);
4182 void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
4183 const double radius_,const double sigma_,const double threshold_)
4189 SetPPChannelMask(channel_);
4190 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4192 RestorePPChannelMask;
4193 replaceImage(newImage);
4197 Magick::Image Magick::Image::separate(const ChannelType channel_)
4203 image=SeparateImage(constImage(),channel_,&exceptionInfo);
4205 if (image == (MagickCore::Image *) NULL)
4206 return(Magick::Image());
4208 return(Magick::Image(image));
4211 void Magick::Image::sepiaTone(const double threshold_)
4217 newImage=SepiaToneImage(constImage(),threshold_,&exceptionInfo);
4218 replaceImage(newImage);
4222 Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
4223 const size_t columns_,const size_t rows_)
4230 result=(*QueueAuthenticPixels)(image(),x_,y_,columns_,rows_,&exceptionInfo);
4235 void Magick::Image::shade(const double azimuth_,const double elevation_,
4236 const bool colorShading_)
4242 newImage=ShadeImage(constImage(),colorShading_ == true ?
4243 MagickTrue : MagickFalse,azimuth_,elevation_,&exceptionInfo);
4244 replaceImage(newImage);
4248 void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
4249 const ssize_t x_,const ssize_t y_)
4255 newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
4257 replaceImage(newImage);
4261 void Magick::Image::sharpen(const double radius_,const double sigma_)
4267 newImage=SharpenImage(constImage(),radius_,sigma_,&exceptionInfo);
4268 replaceImage(newImage);
4272 void Magick::Image::sharpenChannel(const ChannelType channel_,
4273 const double radius_,const double sigma_)
4279 SetPPChannelMask(channel_);
4280 newImage=SharpenImage(constImage(),radius_,sigma_,&exceptionInfo);
4281 RestorePPChannelMask;
4282 replaceImage(newImage);
4286 void Magick::Image::shave(const Geometry &geometry_)
4292 shaveInfo=geometry_;
4295 newImage=ShaveImage(constImage(),&shaveInfo,&exceptionInfo);
4296 replaceImage(newImage);
4300 void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
4306 newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,&exceptionInfo);
4307 replaceImage(newImage);
4311 void Magick::Image::sigmoidalContrast(const size_t sharpen_,
4312 const double contrast,const double midpoint)
4316 (void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
4317 midpoint,&exceptionInfo);
4321 std::string Magick::Image::signature(const bool force_) const
4326 Lock(&_imgRef->_mutexLock);
4328 // Re-calculate image signature if necessary
4330 if (force_ || !GetImageProperty(constImage(),"Signature",&exceptionInfo) ||
4331 constImage()->taint)
4332 SignatureImage(const_cast<MagickCore::Image *>(constImage()),
4335 property=GetImageProperty(constImage(),"Signature",&exceptionInfo);
4338 return(std::string(property));
4341 void Magick::Image::sketch(const double radius_,const double sigma_,
4342 const double angle_)
4348 newImage=SketchImage(constImage(),radius_,sigma_,angle_,&exceptionInfo);
4349 replaceImage(newImage);
4353 void Magick::Image::solarize(const double factor_)
4357 SolarizeImage(image(),factor_,&exceptionInfo);
4361 void Magick::Image::sparseColor(const ChannelType channel_,
4362 const SparseColorMethod method_,const size_t numberArguments_,
4363 const double *arguments_)
4369 SetPPChannelMask(channel_);
4370 newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
4372 RestorePPChannelMask;
4373 replaceImage(newImage);
4377 void Magick::Image::splice(const Geometry &geometry_)
4383 spliceInfo=geometry_;
4386 newImage=SpliceImage(constImage(),&spliceInfo,&exceptionInfo);
4387 replaceImage(newImage);
4391 void Magick::Image::spread(const size_t amount_)
4397 newImage=SpreadImage(constImage(),amount_,image()->interpolate,
4399 replaceImage(newImage);
4403 void Magick::Image::statistics(ImageStatistics *statistics)
4411 SetPPChannelMask(RedChannel);
4412 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4413 statistics->red.minimum=minimum;
4414 statistics->red.maximum=maximum;
4415 (void) GetImageMean(constImage(),&statistics->red.mean,
4416 &statistics->red.standard_deviation,&exceptionInfo);
4417 (void) GetImageKurtosis(constImage(),&statistics->red.kurtosis,
4418 &statistics->red.skewness,&exceptionInfo);
4420 (void) SetImageChannelMask(image(),GreenChannel);
4421 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4422 statistics->green.minimum=minimum;
4423 statistics->green.maximum=maximum;
4424 (void) GetImageMean(constImage(),&statistics->green.mean,
4425 &statistics->green.standard_deviation,&exceptionInfo);
4426 (void) GetImageKurtosis(constImage(),&statistics->green.kurtosis,
4427 &statistics->green.skewness,&exceptionInfo);
4429 (void) SetImageChannelMask(image(),GreenChannel);
4430 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4431 statistics->blue.minimum=minimum;
4432 statistics->blue.maximum=maximum;
4433 (void) GetImageMean(constImage(),&statistics->blue.mean,
4434 &statistics->blue.standard_deviation,&exceptionInfo);
4435 (void) GetImageKurtosis(constImage(),&statistics->blue.kurtosis,
4436 &statistics->blue.skewness,&exceptionInfo);
4438 (void) SetImageChannelMask(image(),AlphaChannel);
4439 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4440 statistics->alpha.minimum=minimum;
4441 statistics->alpha.maximum=maximum;
4442 (void) GetImageMean(constImage(),&statistics->alpha.mean,
4443 &statistics->alpha.standard_deviation,&exceptionInfo);
4444 (void) GetImageKurtosis(constImage(),&statistics->alpha.kurtosis,
4445 &statistics->alpha.skewness,&exceptionInfo);
4446 RestorePPChannelMask;
4450 void Magick::Image::stegano(const Image &watermark_)
4456 newImage=SteganoImage(constImage(),watermark_.constImage(),&exceptionInfo);
4457 replaceImage(newImage);
4461 void Magick::Image::stereo(const Image &rightImage_)
4467 newImage=StereoImage(constImage(),rightImage_.constImage(),&exceptionInfo);
4468 replaceImage(newImage);
4472 void Magick::Image::strip(void)
4476 StripImage(image(),&exceptionInfo);
4480 Magick::Image Magick::Image::subImageSearch(const Image &reference_,
4481 const MetricType metric_,Geometry *offset_,double *similarityMetric_,
4482 const double similarityThreshold)
4491 newImage=SimilarityImage(image(),reference_.constImage(),metric_,
4492 similarityThreshold,&offset,similarityMetric_,&exceptionInfo);
4494 if (offset_ != (Geometry *) NULL)
4496 if (newImage == (MagickCore::Image *) NULL)
4497 return(Magick::Image());
4499 return(Magick::Image(newImage));
4502 void Magick::Image::swirl(const double degrees_)
4508 newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
4510 replaceImage(newImage);
4514 void Magick::Image::syncPixels(void)
4517 (void) (*SyncAuthenticPixels)(image(),&exceptionInfo);
4521 void Magick::Image::texture(const Image &texture_)
4525 TextureImage(image(),texture_.constImage(),&exceptionInfo);
4529 void Magick::Image::threshold(const double threshold_)
4533 BilevelImage(image(),threshold_,&exceptionInfo);
4537 void Magick::Image::thumbnail(const Geometry &geometry_)
4550 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4554 newImage=ThumbnailImage(constImage(),width,height,&exceptionInfo);
4555 replaceImage(newImage);
4559 void Magick::Image::tint(const std::string opacity_)
4568 color=static_cast<PixelInfo>(constOptions()->fillColor());
4569 newImage=TintImage(constImage(),opacity_.c_str(),&color,&exceptionInfo);
4570 replaceImage(newImage);
4574 void Magick::Image::transform(const Geometry &imageGeometry_)
4578 TransformImage(&(image()),0,std::string(imageGeometry_).c_str(),
4583 void Magick::Image::transform(const Geometry &imageGeometry_,
4584 const Geometry &cropGeometry_)
4588 TransformImage(&(image()),std::string(cropGeometry_).c_str(),std::string(
4589 imageGeometry_).c_str(), &exceptionInfo);
4593 void Magick::Image::transformOrigin(const double x_,const double y_)
4596 options()->transformOrigin(x_,y_);
4599 void Magick::Image::transformReset(void)
4602 options()->transformReset();
4605 void Magick::Image::transformScale(const double sx_,const double sy_)
4608 options()->transformScale(sx_,sy_);
4611 void Magick::Image::transparent(const Color &color_)
4619 if (!color_.isValid())
4620 throwExceptionExplicit(OptionError,"Color argument is invalid");
4624 (void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
4627 TransparentPaintImage(image(),&target,TransparentAlpha,MagickFalse,
4632 void Magick::Image::transparentChroma(const Color &colorLow_,
4633 const Color &colorHigh_)
4643 if (!colorLow_.isValid() || !colorHigh_.isValid())
4644 throwExceptionExplicit(OptionError,"Color argument is invalid");
4647 colorHigh=colorHigh_;
4650 (void) QueryColorCompliance(colorLow.c_str(),AllCompliance,&targetLow,
4652 (void) QueryColorCompliance(colorHigh.c_str(),AllCompliance,&targetHigh,
4655 TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
4656 MagickFalse,&exceptionInfo);
4660 void Magick::Image::transpose(void)
4666 newImage=TransposeImage(constImage(),&exceptionInfo);
4667 replaceImage(newImage);
4671 void Magick::Image::transverse(void)
4677 newImage=TransverseImage(constImage(),&exceptionInfo);
4678 replaceImage(newImage);
4682 void Magick::Image::trim(void)
4688 newImage=TrimImage(constImage(),&exceptionInfo);
4689 replaceImage(newImage);
4693 Magick::Image Magick::Image::uniqueColors(void)
4699 image=UniqueImageColors(constImage(),&exceptionInfo);
4701 if (image == (MagickCore::Image *) NULL)
4702 return(Magick::Image());
4704 return(Magick::Image(image));
4707 void Magick::Image::unsharpmask(const double radius_,const double sigma_,
4708 const double amount_,const double threshold_)
4714 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4716 replaceImage(newImage);
4720 void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
4721 const double radius_,const double sigma_,const double amount_,
4722 const double threshold_)
4728 SetPPChannelMask(channel_);
4729 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4731 RestorePPChannelMask;
4732 replaceImage(newImage);
4736 void Magick::Image::vignette(const double radius_,const double sigma_,
4737 const ssize_t x_,const ssize_t y_)
4743 newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,&exceptionInfo);
4744 replaceImage(newImage);
4748 void Magick::Image::wave(const double amplitude_,const double wavelength_)
4754 newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
4756 replaceImage(newImage);
4760 void Magick::Image::whiteThreshold(const std::string &threshold_)
4764 WhiteThresholdImage(image(),threshold_.c_str(),&exceptionInfo);
4768 void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
4769 const std::string &threshold_)
4773 SetPPChannelMask(channel_);
4774 WhiteThresholdImage(image(),threshold_.c_str(),&exceptionInfo);
4775 RestorePPChannelMask;
4779 void Magick::Image::write(Blob *blob_)
4789 data=ImagesToBlob(constImageInfo(),image(),&length,&exceptionInfo);
4791 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4795 void Magick::Image::write(Blob *blob_,const std::string &magick_)
4806 data=ImagesToBlob(constImageInfo(),image(),&length,&exceptionInfo);
4808 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4812 void Magick::Image::write(Blob *blob_,const std::string &magick_,
4813 const size_t depth_)
4825 data=ImagesToBlob(constImageInfo(),image(),&length,&exceptionInfo);
4827 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4831 void Magick::Image::write(const ssize_t x_,const ssize_t y_,
4832 const size_t columns_,const size_t rows_,const std::string &map_,
4833 const StorageType type_,void *pixels_)
4836 ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
4841 void Magick::Image::write(const std::string &imageSpec_)
4844 fileName(imageSpec_);
4846 WriteImage(constImageInfo(),image(),&exceptionInfo);
4850 void Magick::Image::writePixels(const Magick::QuantumType quantum_,
4851 unsigned char *destination_)
4856 quantum_info=AcquireQuantumInfo(imageInfo(),image());
4858 ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4859 quantum_,destination_, &exceptionInfo);
4860 quantum_info=DestroyQuantumInfo(quantum_info);
4864 void Magick::Image::zoom(const Geometry &geometry_)
4877 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4881 newImage=ResizeImage(constImage(),width,height,image()->filter,&exceptionInfo);
4882 replaceImage(newImage);
4886 Magick::Image::Image(MagickCore::Image *image_)
4887 : _imgRef(new ImageRef(image_))
4891 MagickCore::Image *&Magick::Image::image(void)
4893 return(_imgRef->image());
4896 const MagickCore::Image *Magick::Image::constImage(void) const
4898 return(_imgRef->image());
4901 MagickCore::ImageInfo *Magick::Image::imageInfo(void)
4903 return(_imgRef->options()->imageInfo());
4906 const MagickCore::ImageInfo *Magick::Image::constImageInfo(void) const
4908 return(_imgRef->options()->imageInfo());
4911 Magick::Options *Magick::Image::options(void)
4913 return(_imgRef->options());
4916 const Magick::Options *Magick::Image::constOptions(void) const
4918 return(_imgRef->options());
4921 MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)
4923 return(_imgRef->options()->quantizeInfo());
4926 const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
4928 return(_imgRef->options()->quantizeInfo());
4931 void Magick::Image::modifyImage(void)
4934 Lock(&_imgRef->_mutexLock);
4935 if (_imgRef->_refCount == 1)
4937 // De-register image and return
4944 replaceImage(CloneImage(image(),0,0,MagickTrue,&exceptionInfo));
4948 ssize_t Magick::Image::registerId(void)
4950 Lock(&_imgRef->_mutexLock);
4951 if ( _imgRef->id() < 0)
4957 _imgRef->id(_imgRef->id()+1);
4958 sprintf(id,"%.20g\n",(double) _imgRef->id());
4959 SetImageRegistry(ImageRegistryType,id,image(),&exceptionInfo);
4962 return(_imgRef->id());
4965 MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
4971 image = replacement_;
4975 image=AcquireImage(constImageInfo(),&exceptionInfo);
4980 Lock(&_imgRef->_mutexLock);
4982 if (_imgRef->_refCount == 1)
4984 // We own the image, just replace it, and de-register
4986 _imgRef->image(image);
4990 // We don't own the image, dereference and replace with copy
4991 --_imgRef->_refCount;
4992 _imgRef=new ImageRef(image,constOptions());
4996 return(_imgRef->_image);
4999 void Magick::Image::unregisterId(void)