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::clipMask(const Magick::Image &clipMask_)
567 if (clipMask_.isValid())
568 SetImageMask(image(),clipMask_.constImage(),exceptionInfo);
570 SetImageMask(image(),0,exceptionInfo);
574 Magick::Image Magick::Image::clipMask(void) const
580 image=GetImageMask(constImage(),exceptionInfo);
582 if (image == (MagickCore::Image *) NULL)
583 return(Magick::Image());
585 return(Magick::Image(image));
588 void Magick::Image::colorFuzz(const double fuzz_)
592 options()->colorFuzz(fuzz_);
595 double Magick::Image::colorFuzz(void) const
597 return(constOptions()->colorFuzz());
600 void Magick::Image::colorMapSize(const size_t entries_)
602 if (entries_ >MaxColormapSize)
603 throwExceptionExplicit(OptionError,
604 "Colormap entries must not exceed MaxColormapSize");
608 (void) AcquireImageColormap(image(),entries_,exceptionInfo);
612 size_t Magick::Image::colorMapSize(void) const
614 if (!constImage()->colormap)
615 throwExceptionExplicit(OptionError,"Image does not contain a colormap");
617 return(constImage()->colors);
620 void Magick::Image::colorSpace(const ColorspaceType colorSpace_)
622 if (image()->colorspace == colorSpace_)
627 TransformImageColorspace(image(),colorSpace_,exceptionInfo);
631 Magick::ColorspaceType Magick::Image::colorSpace(void) const
633 return (constImage()->colorspace);
636 void Magick::Image::colorSpaceType(const ColorspaceType colorSpace_)
640 SetImageColorspace(image(),colorSpace_,exceptionInfo);
642 options()->colorspaceType(colorSpace_);
645 Magick::ColorspaceType Magick::Image::colorSpaceType(void) const
647 return(constOptions()->colorspaceType());
650 size_t Magick::Image::columns(void) const
652 return(constImage()->columns);
655 void Magick::Image::comment(const std::string &comment_)
659 SetImageProperty(image(),"Comment",NULL,exceptionInfo);
660 if (comment_.length() > 0)
661 SetImageProperty(image(),"Comment",comment_.c_str(),exceptionInfo);
665 std::string Magick::Image::comment(void) const
671 value=GetImageProperty(constImage(),"Comment",exceptionInfo);
675 return(std::string(value));
677 return(std::string()); // Intentionally no exception
680 void Magick::Image::compose(const CompositeOperator compose_)
682 image()->compose=compose_;
685 Magick::CompositeOperator Magick::Image::compose(void) const
687 return(constImage()->compose);
690 void Magick::Image::compressType(const CompressionType compressType_)
693 image()->compression=compressType_;
694 options()->compressType(compressType_);
697 Magick::CompressionType Magick::Image::compressType(void) const
699 return(constImage()->compression);
702 void Magick::Image::debug(const bool flag_)
705 options()->debug(flag_);
708 bool Magick::Image::debug(void) const
710 return(constOptions()->debug());
713 void Magick::Image::density(const Geometry &density_)
716 options()->density(density_);
717 if (density_.isValid())
719 image()->resolution.x=density_.width();
720 if (density_.height() != 0)
721 image()->resolution.y=density_.height();
723 image()->resolution.y=density_.width();
728 image()->resolution.x=0;
729 image()->resolution.y=0;
733 Magick::Geometry Magick::Image::density(void) const
741 if (constImage()->resolution.x > 0.0)
742 x_resolution=static_cast<ssize_t>(constImage()->resolution.x + 0.5);
744 if (constImage()->resolution.y > 0.0)
745 y_resolution=static_cast<ssize_t>(constImage()->resolution.y + 0.5);
747 return(Geometry(x_resolution,y_resolution));
750 return(constOptions()->density());
753 void Magick::Image::depth(const size_t depth_)
758 if (depth > MAGICKCORE_QUANTUM_DEPTH)
759 depth=MAGICKCORE_QUANTUM_DEPTH;
762 image()->depth=depth;
763 options()->depth(depth);
766 size_t Magick::Image::depth(void) const
768 return(constImage()->depth);
771 std::string Magick::Image::directory(void) const
773 if (constImage()->directory)
774 return(std::string(constImage()->directory));
776 throwExceptionExplicit(CorruptImageWarning,
777 "Image does not contain a directory");
779 return(std::string());
782 void Magick::Image::endian(const Magick::EndianType endian_)
785 options()->endian(endian_);
786 image()->endian=endian_;
789 Magick::EndianType Magick::Image::endian(void) const
791 return(constImage()->endian);
794 void Magick::Image::exifProfile(const Magick::Blob &exifProfile_)
798 if (exifProfile_.data() != 0)
803 exif_profile=AcquireStringInfo(exifProfile_.length());
804 SetStringInfoDatum(exif_profile,(unsigned char *) exifProfile_.data());
806 (void) SetImageProfile(image(),"exif",exif_profile,exceptionInfo);
807 exif_profile=DestroyStringInfo(exif_profile);
812 Magick::Blob Magick::Image::exifProfile(void) const
817 exif_profile=GetImageProfile(constImage(),"exif");
818 if (exif_profile == (StringInfo *) NULL)
820 return(Blob(GetStringInfoDatum(exif_profile),
821 GetStringInfoLength(exif_profile)));
824 void Magick::Image::fileName(const std::string &fileName_)
828 fileName_.copy(image()->filename,sizeof(image()->filename)-1);
829 image()->filename[fileName_.length()]=0; // Null terminate
831 options()->fileName(fileName_);
834 std::string Magick::Image::fileName(void) const
836 return(constOptions()->fileName());
839 MagickCore::MagickSizeType Magick::Image::fileSize(void) const
841 return(GetBlobSize(constImage()));
844 void Magick::Image::fillColor(const Magick::Color &fillColor_)
850 options()->fillColor(fillColor_);
852 artifact("fill",value);
855 Magick::Color Magick::Image::fillColor(void) const
857 return(constOptions()->fillColor());
860 void Magick::Image::fillRule(const Magick::FillRule &fillRule_)
863 options()->fillRule(fillRule_);
866 Magick::FillRule Magick::Image::fillRule(void) const
868 return constOptions()->fillRule();
871 void Magick::Image::fillPattern(const Image &fillPattern_)
874 if (fillPattern_.isValid())
875 options()->fillPattern(fillPattern_.constImage());
877 options()->fillPattern(static_cast<MagickCore::Image*>(NULL));
880 Magick::Image Magick::Image::fillPattern(void) const
882 // FIXME: This is inordinately innefficient
883 const MagickCore::Image
889 tmpTexture=constOptions()->fillPattern();
897 image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
898 texture.replaceImage(image);
904 void Magick::Image::filterType(const Magick::FilterTypes filterType_)
907 image()->filter=filterType_;
910 Magick::FilterTypes Magick::Image::filterType(void) const
912 return(constImage()->filter);
915 void Magick::Image::font(const std::string &font_)
918 options()->font(font_);
921 std::string Magick::Image::font(void) const
923 return(constOptions()->font());
926 void Magick::Image::fontPointsize(const double pointSize_)
929 options()->fontPointsize(pointSize_);
932 double Magick::Image::fontPointsize(void) const
934 return(constOptions()->fontPointsize());
937 std::string Magick::Image::format(void) const
943 magick_info=GetMagickInfo(constImage()->magick,exceptionInfo);
946 if ((magick_info != 0) && (*magick_info->description != '\0'))
947 return(std::string(magick_info->description));
949 throwExceptionExplicit(CorruptImageWarning,"Unrecognized image magick type");
950 return(std::string());
953 std::string Magick::Image::formatExpression(const std::string expression)
962 text=InterpretImageProperties(imageInfo(),image(),expression.c_str(),
964 if (text != (char *) NULL)
966 result=std::string(text);
967 text=DestroyString(text);
973 double Magick::Image::gamma(void) const
975 return(constImage()->gamma);
978 Magick::Geometry Magick::Image::geometry(void) const
980 if (constImage()->geometry)
981 return Geometry(constImage()->geometry);
983 throwExceptionExplicit(OptionWarning,"Image does not contain a geometry");
988 void Magick::Image::gifDisposeMethod(
989 const MagickCore::DisposeType disposeMethod_)
992 image()->dispose=disposeMethod_;
995 MagickCore::DisposeType Magick::Image::gifDisposeMethod(void) const
997 return(constImage()->dispose);
1000 void Magick::Image::highlightColor(const Color color_)
1006 artifact("highlight-color",value);
1009 void Magick::Image::iccColorProfile(const Magick::Blob &colorProfile_)
1011 profile("icm",colorProfile_);
1014 Magick::Blob Magick::Image::iccColorProfile(void) const
1019 color_profile=GetImageProfile(constImage(),"icc");
1020 if (color_profile == (StringInfo *) NULL)
1022 return(Blob(GetStringInfoDatum(color_profile),GetStringInfoLength(
1026 void Magick::Image::interlaceType(const Magick::InterlaceType interlace_)
1029 image()->interlace=interlace_;
1030 options()->interlaceType(interlace_);
1033 Magick::InterlaceType Magick::Image::interlaceType(void) const
1035 return(constImage()->interlace);
1038 void Magick::Image::interpolate(const PixelInterpolateMethod interpolate_)
1041 image()->interpolate=interpolate_;
1044 Magick::PixelInterpolateMethod Magick::Image::interpolate(void) const
1046 return constImage()->interpolate;
1049 void Magick::Image::iptcProfile(const Magick::Blob &iptcProfile_)
1052 if (iptcProfile_.data() != 0)
1057 iptc_profile=AcquireStringInfo(iptcProfile_.length());
1058 SetStringInfoDatum(iptc_profile,(unsigned char *) iptcProfile_.data());
1060 (void) SetImageProfile(image(),"iptc",iptc_profile,exceptionInfo);
1061 iptc_profile=DestroyStringInfo(iptc_profile);
1066 Magick::Blob Magick::Image::iptcProfile(void) const
1071 iptc_profile=GetImageProfile(constImage(),"iptc");
1072 if (iptc_profile == (StringInfo *) NULL)
1074 return(Blob(GetStringInfoDatum(iptc_profile),GetStringInfoLength(
1078 void Magick::Image::isValid(const bool isValid_)
1083 _imgRef=new ImageRef;
1085 else if (!isValid())
1087 // Construct with single-pixel black image to make
1088 // image valid. This is an obvious hack.
1089 size(Geometry(1,1));
1094 bool Magick::Image::isValid(void) const
1096 return rows() && columns();
1099 void Magick::Image::label(const std::string &label_)
1103 (void) SetImageProperty(image(),"Label",NULL,exceptionInfo);
1104 if (label_.length() > 0)
1105 (void) SetImageProperty(image(),"Label",label_.c_str(),exceptionInfo);
1109 std::string Magick::Image::label(void) const
1115 value=GetImageProperty(constImage(),"Label",exceptionInfo);
1119 return(std::string(value));
1121 return(std::string());
1124 void Magick::Image::lowlightColor(const Color color_)
1130 artifact("lowlight-color",value);
1133 void Magick::Image::mask(const Magick::Image &mask_)
1138 if (mask_.isValid())
1139 SetImageMask(image(),mask_.constImage(),exceptionInfo);
1141 SetImageMask(image(),(MagickCore::Image *) NULL,exceptionInfo);
1145 Magick::Image Magick::Image::mask(void) const
1151 image=GetImageMask(constImage(),exceptionInfo);
1154 if (image == (MagickCore::Image *) NULL)
1155 return(Magick::Image());
1157 return(Magick::Image(image));
1160 void Magick::Image::magick(const std::string &magick_)
1164 magick_.copy(image()->magick,sizeof(image()->magick)-1);
1165 image()->magick[magick_.length()]=0;
1167 options()->magick(magick_);
1170 std::string Magick::Image::magick(void) const
1172 if (*(constImage()->magick) != '\0')
1173 return(std::string(constImage()->magick));
1175 return(constOptions()->magick());
1178 double Magick::Image::meanErrorPerPixel(void) const
1180 return(constImage()->error.mean_error_per_pixel);
1183 void Magick::Image::modulusDepth(const size_t depth_)
1187 SetImageDepth(image(),depth_,exceptionInfo);
1189 options()->depth(depth_);
1192 size_t Magick::Image::modulusDepth(void) const
1198 depth=GetImageDepth(constImage(),exceptionInfo);
1203 void Magick::Image::monochrome(const bool monochromeFlag_)
1206 options()->monochrome(monochromeFlag_);
1209 bool Magick::Image::monochrome(void) const
1211 return(constOptions()->monochrome());
1214 Magick::Geometry Magick::Image::montageGeometry(void) const
1216 if (constImage()->montage)
1217 return Magick::Geometry(constImage()->montage);
1219 throwExceptionExplicit(CorruptImageWarning,
1220 "Image does not contain a montage");
1222 return(Magick::Geometry());
1225 double Magick::Image::normalizedMaxError(void) const
1227 return(constImage()->error.normalized_maximum_error);
1230 double Magick::Image::normalizedMeanError(void) const
1232 return(constImage()->error.normalized_mean_error);
1235 void Magick::Image::orientation(const Magick::OrientationType orientation_)
1238 image()->orientation=orientation_;
1241 Magick::OrientationType Magick::Image::orientation(void) const
1243 return(constImage()->orientation);
1246 void Magick::Image::page(const Magick::Geometry &pageSize_)
1249 options()->page(pageSize_);
1250 image()->page=pageSize_;
1253 Magick::Geometry Magick::Image::page(void) const
1255 return(Geometry(constImage()->page.width,constImage()->page.height,
1256 AbsoluteValue(constImage()->page.x),AbsoluteValue(constImage()->page.y),
1257 constImage()->page.x < 0 ? true : false,
1258 constImage()->page.y < 0 ? true : false));
1261 void Magick::Image::quality(const size_t quality_)
1264 image()->quality=quality_;
1265 options()->quality(quality_);
1268 size_t Magick::Image::quality(void) const
1270 return(constImage()->quality);
1273 void Magick::Image::quantizeColors(const size_t colors_)
1276 options()->quantizeColors(colors_);
1279 size_t Magick::Image::quantizeColors(void) const
1281 return(constOptions()->quantizeColors());
1284 void Magick::Image::quantizeColorSpace(
1285 const Magick::ColorspaceType colorSpace_)
1288 options()->quantizeColorSpace(colorSpace_);
1291 Magick::ColorspaceType Magick::Image::quantizeColorSpace(void) const
1293 return(constOptions()->quantizeColorSpace());
1296 void Magick::Image::quantizeDither(const bool ditherFlag_)
1299 options()->quantizeDither(ditherFlag_);
1302 bool Magick::Image::quantizeDither(void) const
1304 return(constOptions()->quantizeDither());
1307 void Magick::Image::quantizeDitherMethod(const DitherMethod ditherMethod_)
1310 options()->quantizeDitherMethod(ditherMethod_);
1313 MagickCore::DitherMethod Magick::Image::quantizeDitherMethod(void) const
1315 return(constOptions()->quantizeDitherMethod());
1318 void Magick::Image::quantizeTreeDepth(const size_t treeDepth_)
1321 options()->quantizeTreeDepth(treeDepth_);
1324 size_t Magick::Image::quantizeTreeDepth() const
1326 return(constOptions()->quantizeTreeDepth());
1329 void Magick::Image::renderingIntent(
1330 const Magick::RenderingIntent renderingIntent_)
1333 image()->rendering_intent=renderingIntent_;
1336 Magick::RenderingIntent Magick::Image::renderingIntent(void) const
1338 return(static_cast<Magick::RenderingIntent>(constImage()->rendering_intent));
1341 void Magick::Image::resolutionUnits(
1342 const Magick::ResolutionType resolutionUnits_)
1345 image()->units=resolutionUnits_;
1346 options()->resolutionUnits(resolutionUnits_);
1349 Magick::ResolutionType Magick::Image::resolutionUnits(void) const
1351 return(constOptions()->resolutionUnits());
1354 size_t Magick::Image::rows(void) const
1356 return(constImage()->rows);
1359 void Magick::Image::scene(const size_t scene_)
1362 image()->scene=scene_;
1365 size_t Magick::Image::scene(void) const
1367 return(constImage()->scene);
1370 void Magick::Image::size(const Geometry &geometry_)
1373 options()->size(geometry_);
1374 image()->rows=geometry_.height();
1375 image()->columns=geometry_.width();
1378 Magick::Geometry Magick::Image::size(void) const
1380 return(Magick::Geometry(constImage()->columns,constImage()->rows));
1383 void Magick::Image::strokeAntiAlias(const bool flag_)
1386 options()->strokeAntiAlias(flag_);
1389 bool Magick::Image::strokeAntiAlias(void) const
1391 return(constOptions()->strokeAntiAlias());
1394 void Magick::Image::strokeColor(const Magick::Color &strokeColor_)
1400 options()->strokeColor(strokeColor_);
1402 artifact("stroke",value);
1405 Magick::Color Magick::Image::strokeColor(void) const
1407 return(constOptions()->strokeColor());
1410 void Magick::Image::strokeDashArray(const double *strokeDashArray_)
1413 options()->strokeDashArray(strokeDashArray_);
1416 const double* Magick::Image::strokeDashArray(void) const
1418 return(constOptions()->strokeDashArray());
1421 void Magick::Image::strokeDashOffset(const double strokeDashOffset_)
1424 options()->strokeDashOffset(strokeDashOffset_);
1427 double Magick::Image::strokeDashOffset(void) const
1429 return(constOptions()->strokeDashOffset());
1432 void Magick::Image::strokeLineCap(const Magick::LineCap lineCap_)
1435 options()->strokeLineCap(lineCap_);
1438 Magick::LineCap Magick::Image::strokeLineCap(void) const
1440 return(constOptions()->strokeLineCap());
1443 void Magick::Image::strokeLineJoin(const Magick::LineJoin lineJoin_)
1446 options()->strokeLineJoin(lineJoin_);
1449 Magick::LineJoin Magick::Image::strokeLineJoin(void) const
1451 return(constOptions()->strokeLineJoin());
1454 void Magick::Image::strokeMiterLimit(const size_t strokeMiterLimit_)
1457 options()->strokeMiterLimit(strokeMiterLimit_);
1460 size_t Magick::Image::strokeMiterLimit(void) const
1462 return(constOptions()->strokeMiterLimit());
1465 void Magick::Image::strokePattern(const Image &strokePattern_)
1468 if(strokePattern_.isValid())
1469 options()->strokePattern(strokePattern_.constImage());
1471 options()->strokePattern(static_cast<MagickCore::Image*>(NULL));
1474 Magick::Image Magick::Image::strokePattern(void) const
1476 // FIXME: This is inordinately innefficient
1477 const MagickCore::Image
1483 tmpTexture=constOptions()->strokePattern();
1491 image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
1492 texture.replaceImage(image);
1498 void Magick::Image::strokeWidth(const double strokeWidth_)
1501 value[MaxTextExtent];
1504 options()->strokeWidth(strokeWidth_);
1505 FormatLocaleString(value,MaxTextExtent,"%.20g",strokeWidth_);
1506 (void) SetImageArtifact(image(),"strokewidth",value);
1509 double Magick::Image::strokeWidth(void) const
1511 return(constOptions()->strokeWidth());
1514 void Magick::Image::subImage(const size_t subImage_)
1517 options()->subImage(subImage_);
1520 size_t Magick::Image::subImage(void) const
1522 return(constOptions()->subImage());
1525 void Magick::Image::subRange(const size_t subRange_)
1528 options()->subRange(subRange_);
1531 size_t Magick::Image::subRange(void) const
1533 return(constOptions()->subRange());
1536 void Magick::Image::textDirection(DirectionType direction_)
1539 options()->textDirection(direction_);
1542 Magick::DirectionType Magick::Image::textDirection(void) const
1544 return(constOptions()->textDirection());
1547 void Magick::Image::textEncoding(const std::string &encoding_)
1550 options()->textEncoding(encoding_);
1553 std::string Magick::Image::textEncoding(void) const
1555 return(constOptions()->textEncoding());
1558 void Magick::Image::textGravity(GravityType gravity_)
1561 options()->textGravity(gravity_);
1564 Magick::GravityType Magick::Image::textGravity(void) const
1566 return(constOptions()->textGravity());
1569 void Magick::Image::textInterlineSpacing(double spacing_)
1572 options()->textInterlineSpacing(spacing_);
1575 double Magick::Image::textInterlineSpacing(void) const
1577 return(constOptions()->textInterlineSpacing());
1580 void Magick::Image::textInterwordSpacing(double spacing_)
1583 options()->textInterwordSpacing(spacing_);
1586 double Magick::Image::textInterwordSpacing(void) const
1588 return(constOptions()->textInterwordSpacing());
1591 void Magick::Image::textKerning(double kerning_)
1594 options()->textKerning(kerning_);
1597 double Magick::Image::textKerning(void) const
1599 return(constOptions()->textKerning());
1602 size_t Magick::Image::totalColors(void) const
1608 colors=GetNumberColors(constImage(),0,exceptionInfo);
1613 void Magick::Image::transformRotation(const double angle_)
1616 options()->transformRotation(angle_);
1619 void Magick::Image::transformSkewX(const double skewx_)
1622 options()->transformSkewX(skewx_);
1625 void Magick::Image::transformSkewY(const double skewy_)
1628 options()->transformSkewY(skewy_);
1631 Magick::ImageType Magick::Image::type(void) const
1633 if (constOptions()->type() != UndefinedType)
1634 return(constOptions()->type());
1635 else if (constImage()->type != UndefinedType)
1636 return(constImage()->type);
1638 return(determineType());
1641 void Magick::Image::type(const Magick::ImageType type_)
1644 options()->type(type_);
1646 SetImageType(image(),type_,exceptionInfo);
1650 void Magick::Image::verbose(const bool verboseFlag_)
1653 options()->verbose(verboseFlag_);
1656 bool Magick::Image::verbose(void) const
1658 return(constOptions()->verbose());
1661 void Magick::Image::view(const std::string &view_)
1664 options()->view(view_);
1667 std::string Magick::Image::view(void) const
1669 return(constOptions()->view());
1672 void Magick::Image::virtualPixelMethod(
1673 const VirtualPixelMethod virtualPixelMethod_)
1677 SetImageVirtualPixelMethod(image(),virtualPixelMethod_,exceptionInfo);
1681 Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod(void) const
1683 return(GetImageVirtualPixelMethod(constImage()));
1686 void Magick::Image::x11Display(const std::string &display_)
1689 options()->x11Display(display_);
1692 std::string Magick::Image::x11Display(void) const
1694 return(constOptions()->x11Display());
1697 double Magick::Image::xResolution(void) const
1699 return(constImage()->resolution.x);
1702 double Magick::Image::yResolution(void) const
1704 return(constImage()->resolution.y);
1707 void Magick::Image::adaptiveBlur(const double radius_,const double sigma_)
1713 newImage=AdaptiveBlurImage(constImage(),radius_,sigma_,exceptionInfo);
1714 replaceImage(newImage);
1718 void Magick::Image::adaptiveResize(const Geometry &geometry_)
1731 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
1735 newImage=AdaptiveResizeImage(constImage(),width,height,exceptionInfo);
1736 replaceImage(newImage);
1740 void Magick::Image::adaptiveSharpen(const double radius_,const double sigma_)
1746 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1747 replaceImage(newImage);
1751 void Magick::Image::adaptiveSharpenChannel(const ChannelType channel_,
1752 const double radius_,const double sigma_ )
1758 SetPPChannelMask(channel_);
1759 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1760 RestorePPChannelMask;
1761 replaceImage(newImage);
1765 void Magick::Image::adaptiveThreshold(const size_t width_,const size_t height_,
1766 const ssize_t offset_)
1773 newImage=AdaptiveThresholdImage(constImage(),width_,height_,offset_,
1775 replaceImage(newImage);
1779 void Magick::Image::addNoise(const NoiseType noiseType_)
1785 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1786 replaceImage(newImage);
1790 void Magick::Image::addNoiseChannel(const ChannelType channel_,
1791 const NoiseType noiseType_)
1797 SetPPChannelMask(channel_);
1798 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1799 RestorePPChannelMask;
1800 replaceImage(newImage);
1804 void Magick::Image::affineTransform(const DrawableAffine &affine_)
1812 _affine.sx=affine_.sx();
1813 _affine.sy=affine_.sy();
1814 _affine.rx=affine_.rx();
1815 _affine.ry=affine_.ry();
1816 _affine.tx=affine_.tx();
1817 _affine.ty=affine_.ty();
1820 newImage=AffineTransformImage(constImage(),&_affine,exceptionInfo);
1821 replaceImage(newImage);
1825 void Magick::Image::alpha(const unsigned int alpha_)
1829 SetImageAlpha(image(),alpha_,exceptionInfo);
1833 void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
1837 SetImageAlphaChannel(image(),alphaOption_,exceptionInfo);
1841 void Magick::Image::annotate(const std::string &text_,
1842 const Geometry &location_)
1844 annotate(text_,location_,NorthWestGravity,0.0);
1847 void Magick::Image::annotate(const std::string &text_,
1848 const Geometry &boundingArea_,const GravityType gravity_)
1850 annotate(text_,boundingArea_,gravity_,0.0);
1853 void Magick::Image::annotate(const std::string &text_,
1854 const Geometry &boundingArea_,const GravityType gravity_,
1855 const double degrees_)
1861 boundingArea[MaxTextExtent];
1868 drawInfo=options()->drawInfo();
1869 drawInfo->text=const_cast<char *>(text_.c_str());
1870 drawInfo->geometry=0;
1872 if (boundingArea_.isValid())
1874 if (boundingArea_.width() == 0 || boundingArea_.height() == 0)
1876 FormatLocaleString(boundingArea,MaxTextExtent,"%+.20g%+.20g",
1877 (double) boundingArea_.xOff(),(double) boundingArea_.yOff());
1881 (void) CopyMagickString(boundingArea,string(boundingArea_).c_str(),
1884 drawInfo->geometry=boundingArea;
1887 drawInfo->gravity=gravity_;
1889 oaffine=drawInfo->affine;
1890 if (degrees_ != 0.0)
1903 current=drawInfo->affine;
1904 affine.sx=cos(DegreesToRadians(fmod(degrees_,360.0)));
1905 affine.rx=sin(DegreesToRadians(fmod(degrees_,360.0)));
1906 affine.ry=(-sin(DegreesToRadians(fmod(degrees_,360.0))));
1907 affine.sy=cos(DegreesToRadians(fmod(degrees_,360.0)));
1909 drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
1910 drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
1911 drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
1912 drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
1913 drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty
1918 AnnotateImage(image(),drawInfo,exceptionInfo);
1920 // Restore original values
1921 drawInfo->affine=oaffine;
1923 drawInfo->geometry=0;
1928 void Magick::Image::annotate(const std::string &text_,
1929 const GravityType gravity_)
1936 drawInfo=options()->drawInfo();
1937 drawInfo->text=const_cast<char *>(text_.c_str());
1938 drawInfo->gravity=gravity_;
1941 AnnotateImage(image(),drawInfo,exceptionInfo);
1943 drawInfo->gravity=NorthWestGravity;
1949 void Magick::Image::artifact(const std::string &name_,const std::string &value_)
1952 (void) SetImageArtifact(image(),name_.c_str(),value_.c_str());
1955 std::string Magick::Image::artifact(const std::string &name_)
1960 value=GetImageArtifact(constImage(),name_.c_str());
1962 return(std::string(value));
1963 return(std::string());
1966 void Magick::Image::attribute(const std::string name_,const std::string value_)
1970 SetImageProperty(image(),name_.c_str(),value_.c_str(),exceptionInfo);
1974 std::string Magick::Image::attribute(const std::string name_)
1980 value=GetImageProperty(constImage(),name_.c_str(),exceptionInfo);
1984 return(std::string(value));
1986 return(std::string()); // Intentionally no exception
1989 void Magick::Image::autoGamma(void)
1993 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1994 (void) AutoGammaImage(image(),exceptionInfo);
1998 void Magick::Image::autoGammaChannel(const ChannelType channel_)
2002 SetPPChannelMask(channel_);
2003 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2004 (void) AutoGammaImage(image(),exceptionInfo);
2005 RestorePPChannelMask;
2009 void Magick::Image::autoLevel(void)
2013 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2014 (void) AutoLevelImage(image(),exceptionInfo);
2018 void Magick::Image::autoLevelChannel(const ChannelType channel_)
2022 SetPPChannelMask(channel_);
2023 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2024 (void) AutoLevelImage(image(),exceptionInfo);
2025 RestorePPChannelMask;
2029 void Magick::Image::autoOrient(void)
2034 if (image()->orientation == UndefinedOrientation ||
2035 image()->orientation == TopLeftOrientation)
2039 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2040 newImage=AutoOrientImage(constImage(),image()->orientation,exceptionInfo);
2041 replaceImage(newImage);
2045 void Magick::Image::blackThreshold(const std::string &threshold_)
2049 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2053 void Magick::Image::blackThresholdChannel(const ChannelType channel_,
2054 const std::string &threshold_)
2058 SetPPChannelMask(channel_);
2059 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2060 RestorePPChannelMask;
2064 void Magick::Image::blueShift(const double factor_)
2070 newImage=BlueShiftImage(constImage(),factor_,exceptionInfo);
2071 replaceImage(newImage);
2075 void Magick::Image::blur(const double radius_,const double sigma_)
2081 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2082 replaceImage(newImage);
2086 void Magick::Image::blurChannel(const ChannelType channel_,
2087 const double radius_,const double sigma_)
2093 SetPPChannelMask(channel_);
2094 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2095 RestorePPChannelMask;
2096 replaceImage(newImage);
2100 void Magick::Image::border(const Geometry &geometry_)
2106 borderInfo=geometry_;
2109 newImage=BorderImage(constImage(),&borderInfo,image()->compose,
2111 replaceImage(newImage);
2115 void Magick::Image::brightnessContrast(const double brightness_,
2116 const double contrast_)
2120 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2124 void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
2125 const double brightness_,const double contrast_)
2129 SetPPChannelMask(channel_);
2130 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2131 RestorePPChannelMask;
2135 void Magick::Image::cannyEdge(const double radius_,const double sigma_,
2136 const double lowerPercent_,const double upperPercent_)
2143 newImage=CannyEdgeImage(constImage(),radius_,sigma_,lowerPercent_,
2144 upperPercent_,exceptionInfo);
2145 replaceImage(newImage);
2149 void Magick::Image::channel(const ChannelType channel_)
2155 newImage=SeparateImage(image(),channel_,exceptionInfo);
2156 replaceImage(newImage);
2160 void Magick::Image::charcoal(const double radius_,const double sigma_)
2166 newImage=CharcoalImage(image(),radius_,sigma_,exceptionInfo);
2167 replaceImage(newImage);
2171 void Magick::Image::chop(const Geometry &geometry_)
2180 newImage=ChopImage(image(),&chopInfo,exceptionInfo);
2181 replaceImage(newImage);
2185 void Magick::Image::chromaBluePrimary(const double x_,const double y_)
2188 image()->chromaticity.blue_primary.x=x_;
2189 image()->chromaticity.blue_primary.y=y_;
2192 void Magick::Image::chromaBluePrimary(double *x_,double *y_) const
2194 *x_=constImage()->chromaticity.blue_primary.x;
2195 *y_=constImage()->chromaticity.blue_primary.y;
2198 void Magick::Image::chromaGreenPrimary(const double x_,const double y_)
2201 image()->chromaticity.green_primary.x=x_;
2202 image()->chromaticity.green_primary.y=y_;
2205 void Magick::Image::chromaGreenPrimary(double *x_,double *y_) const
2207 *x_=constImage()->chromaticity.green_primary.x;
2208 *y_=constImage()->chromaticity.green_primary.y;
2211 void Magick::Image::chromaRedPrimary(const double x_,const double y_)
2214 image()->chromaticity.red_primary.x=x_;
2215 image()->chromaticity.red_primary.y=y_;
2218 void Magick::Image::chromaRedPrimary(double *x_,double *y_) const
2220 *x_=constImage()->chromaticity.red_primary.x;
2221 *y_=constImage()->chromaticity.red_primary.y;
2224 void Magick::Image::chromaWhitePoint(const double x_,const double y_)
2227 image()->chromaticity.white_point.x=x_;
2228 image()->chromaticity.white_point.y=y_;
2231 void Magick::Image::chromaWhitePoint(double *x_,double *y_) const
2233 *x_=constImage()->chromaticity.white_point.x;
2234 *y_=constImage()->chromaticity.white_point.y;
2237 void Magick::Image::cdl(const std::string &cdl_)
2241 (void) ColorDecisionListImage(image(),cdl_.c_str(),exceptionInfo);
2245 void Magick::Image::clamp(void)
2249 ClampImage(image(),exceptionInfo);
2253 void Magick::Image::clampChannel(const ChannelType channel_)
2257 SetPPChannelMask(channel_);
2258 ClampImage(image(),exceptionInfo);
2259 RestorePPChannelMask;
2263 void Magick::Image::clip(void)
2267 ClipImage(image(),exceptionInfo);
2271 void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
2275 ClipImagePath(image(),pathname_.c_str(),(MagickBooleanType) inside_,
2280 void Magick::Image::clut(const Image &clutImage_,
2281 const PixelInterpolateMethod method)
2285 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2289 void Magick::Image::clutChannel(const ChannelType channel_,
2290 const Image &clutImage_,const PixelInterpolateMethod method)
2294 SetPPChannelMask(channel_);
2295 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2296 RestorePPChannelMask;
2300 void Magick::Image::colorize(const unsigned int alpha_,const Color &penColor_)
2302 colorize(alpha_,alpha_,alpha_,penColor_);
2305 void Magick::Image::colorize(const unsigned int alphaRed_,
2306 const unsigned int alphaGreen_,const unsigned int alphaBlue_,
2307 const Color &penColor_)
2310 blend[MaxTextExtent];
2319 if (!penColor_.isValid())
2320 throwExceptionExplicit(OptionError,"Pen color argument is invalid");
2322 FormatLocaleString(blend,MaxTextExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
2325 GetPixelInfo(image(),&target);
2326 pixel=static_cast<PixelInfo>(penColor_);
2327 target.red=pixel.red;
2328 target.green=pixel.green;
2329 target.blue=pixel.blue;
2330 target.alpha=pixel.alpha;
2332 newImage=ColorizeImage(image(),blend,&target,exceptionInfo);
2333 replaceImage(newImage);
2337 void Magick::Image::colorMap(const size_t index_,const Color &color_)
2344 if (index_ > (MaxColormapSize-1))
2345 throwExceptionExplicit(OptionError,
2346 "Colormap index must be less than MaxColormapSize");
2348 if (!color_.isValid())
2349 throwExceptionExplicit(OptionError,"Color argument is invalid");
2353 // Ensure that colormap size is large enough
2354 if (colorMapSize() < (index_+1))
2355 colorMapSize(index_+1);
2357 // Set color at index in colormap
2358 (imageptr->colormap)[index_]=color_;
2361 Magick::Color Magick::Image::colorMap(const size_t index_) const
2363 if (!constImage()->colormap)
2365 throwExceptionExplicit(OptionError,"Image does not contain a colormap");
2369 if (index_ > constImage()->colors-1)
2370 throwExceptionExplicit(OptionError,"Index out of range");
2372 return(Magick::Color((constImage()->colormap)[index_]));
2375 void Magick::Image::colorMatrix(const size_t order_,
2376 const double *color_matrix_)
2382 kernel_info=AcquireKernelInfo((const char *) NULL);
2383 if (kernel_info != (KernelInfo *) NULL)
2385 kernel_info->width=order_;
2386 kernel_info->height=order_;
2387 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2388 order_*sizeof(*kernel_info->values));
2389 if (kernel_info->values != (MagickRealType *) NULL)
2394 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2395 kernel_info->values[i]=color_matrix_[i];
2396 newImage=ColorMatrixImage(image(),kernel_info,exceptionInfo);
2397 replaceImage(newImage);
2399 kernel_info=DestroyKernelInfo(kernel_info);
2404 bool Magick::Image::compare(const Image &reference_)
2415 status=static_cast<bool>(IsImagesEqual(image(),ref.image(),exceptionInfo));
2420 double Magick::Image::compare(const Image &reference_,const MetricType metric_)
2426 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2432 double Magick::Image::compareChannel(const ChannelType channel_,
2433 const Image &reference_,const MetricType metric_)
2439 SetPPChannelMask(channel_);
2440 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2442 RestorePPChannelMask;
2447 Magick::Image Magick::Image::compare(const Image &reference_,
2448 const MetricType metric_,double *distortion)
2454 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2457 if (newImage == (MagickCore::Image *) NULL)
2458 return(Magick::Image());
2460 return(Magick::Image(newImage));
2463 Magick::Image Magick::Image::compareChannel(const ChannelType channel_,
2464 const Image &reference_,const MetricType metric_,double *distortion)
2470 SetPPChannelMask(channel_);
2471 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2473 RestorePPChannelMask;
2475 if (newImage == (MagickCore::Image *) NULL)
2476 return(Magick::Image());
2478 return(Magick::Image(newImage));
2481 void Magick::Image::composite(const Image &compositeImage_,
2482 const Geometry &offset_,const CompositeOperator compose_)
2492 ParseMetaGeometry(static_cast<std::string>(offset_).c_str(),&x,&y,&width,
2497 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickFalse,
2502 void Magick::Image::composite(const Image &compositeImage_,
2503 const GravityType gravity_,const CompositeOperator compose_)
2509 SetGeometry(compositeImage_.constImage(),&geometry);
2510 GravityAdjustGeometry(columns(),rows(),gravity_,&geometry);
2513 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickFalse,
2514 geometry.x,geometry.y,exceptionInfo);
2518 void Magick::Image::composite(const Image &compositeImage_,
2519 const ssize_t xOffset_,const ssize_t yOffset_,
2520 const CompositeOperator compose_)
2522 // Image supplied as compositeImage is composited with current image and
2523 // results in updating current image.
2526 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickFalse,
2527 xOffset_,yOffset_,exceptionInfo);
2531 void Magick::Image::contrast(const size_t sharpen_)
2535 ContrastImage(image(),(MagickBooleanType) sharpen_,exceptionInfo);
2539 void Magick::Image::contrastStretch(const double blackPoint_,
2540 const double whitePoint_)
2544 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2548 void Magick::Image::contrastStretchChannel(const ChannelType channel_,
2549 const double blackPoint_,const double whitePoint_)
2553 SetPPChannelMask(channel_);
2554 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2555 RestorePPChannelMask;
2559 void Magick::Image::convolve(const size_t order_,const double *kernel_)
2565 kernel_info=AcquireKernelInfo((const char *) NULL);
2566 kernel_info->width=order_;
2567 kernel_info->height=order_;
2568 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2569 order_*sizeof(*kernel_info->values));
2570 if (kernel_info->values != (MagickRealType *) NULL)
2575 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2576 kernel_info->values[i]=kernel_[i];
2577 newImage=ConvolveImage(image(),kernel_info,exceptionInfo);
2578 replaceImage(newImage);
2580 kernel_info=DestroyKernelInfo(kernel_info);
2584 void Magick::Image::crop(const Geometry &geometry_)
2593 newImage=CropImage(constImage(),&cropInfo,exceptionInfo);
2594 replaceImage(newImage);
2598 void Magick::Image::cycleColormap(const ssize_t amount_)
2602 CycleColormapImage(image(),amount_,exceptionInfo);
2606 void Magick::Image::decipher(const std::string &passphrase_)
2610 DecipherImage(image(),passphrase_.c_str(),exceptionInfo);
2614 void Magick::Image::defineSet(const std::string &magick_,
2615 const std::string &key_,bool flag_)
2621 definition=magick_ + ":" + key_;
2623 (void) SetImageOption(imageInfo(),definition.c_str(),"");
2625 DeleteImageOption(imageInfo(),definition.c_str());
2628 bool Magick::Image::defineSet(const std::string &magick_,
2629 const std::string &key_ ) const
2637 key=magick_ + ":" + key_;
2638 option=GetImageOption(constImageInfo(),key.c_str());
2644 void Magick::Image::defineValue(const std::string &magick_,
2645 const std::string &key_,const std::string &value_)
2652 format=magick_ + ":" + key_;
2654 (void) SetImageOption(imageInfo(),format.c_str(),option.c_str());
2657 std::string Magick::Image::defineValue(const std::string &magick_,
2658 const std::string &key_) const
2666 definition=magick_ + ":" + key_;
2667 option=GetImageOption(constImageInfo(),definition.c_str());
2669 return(std::string(option));
2670 return(std::string());
2673 void Magick::Image::deskew(const double threshold_)
2679 newImage=DeskewImage(constImage(),threshold_,exceptionInfo);
2680 replaceImage(newImage);
2684 void Magick::Image::despeckle(void)
2690 newImage=DespeckleImage(constImage(),exceptionInfo);
2691 replaceImage(newImage);
2695 Magick::ImageType Magick::Image::determineType(void) const
2701 image_type=GetImageType(constImage(),exceptionInfo);
2706 void Magick::Image::display(void)
2709 DisplayImages(imageInfo(),image(),exceptionInfo);
2713 void Magick::Image::distort(const DistortImageMethod method_,
2714 const size_t numberArguments_,const double *arguments_,const bool bestfit_)
2720 newImage=DistortImage(constImage(), method_,numberArguments_,arguments_,
2721 bestfit_ == true ? MagickTrue : MagickFalse,exceptionInfo);
2722 replaceImage(newImage);
2726 void Magick::Image::draw(const Magick::Drawable &drawable_)
2733 wand=DrawAllocateWand(options()->drawInfo(),image());
2737 drawable_.operator()(wand);
2741 ClonePPDrawException(wand);
2742 wand=DestroyDrawingWand(wand);
2743 ThrowPPDrawException;
2747 void Magick::Image::draw(const std::list<Magick::Drawable> &drawable_)
2754 wand=DrawAllocateWand(options()->drawInfo(),image());
2758 for (std::list<Magick::Drawable>::const_iterator p = drawable_.begin();
2759 p != drawable_.end(); p++ )
2761 p->operator()(wand);
2762 if (DrawGetExceptionType(wand) != UndefinedException)
2766 if (DrawGetExceptionType(wand) == UndefinedException)
2769 ClonePPDrawException(wand);
2770 wand=DestroyDrawingWand(wand);
2771 ThrowPPDrawException;
2775 void Magick::Image::edge(const double radius_)
2781 newImage=EdgeImage(constImage(),radius_,exceptionInfo);
2782 replaceImage(newImage);
2786 void Magick::Image::emboss(const double radius_,const double sigma_)
2792 newImage=EmbossImage(constImage(),radius_,sigma_,exceptionInfo);
2793 replaceImage(newImage);
2797 void Magick::Image::encipher(const std::string &passphrase_)
2801 EncipherImage(image(),passphrase_.c_str(),exceptionInfo);
2805 void Magick::Image::enhance(void)
2811 newImage=EnhanceImage(constImage(),exceptionInfo);
2812 replaceImage(newImage);
2816 void Magick::Image::equalize(void)
2820 EqualizeImage(image(),exceptionInfo);
2824 void Magick::Image::erase(void)
2828 (void) SetImageBackgroundColor(image(),exceptionInfo);
2832 void Magick::Image::extent(const Geometry &geometry_ )
2838 extentInfo=geometry_;
2841 extentInfo.x=geometry_.xOff();
2842 extentInfo.y=geometry_.yOff();
2844 newImage=ExtentImage(image(),&extentInfo,exceptionInfo);
2845 replaceImage(newImage);
2849 void Magick::Image::extent(const Geometry &geometry_,
2850 const Color &backgroundColor_)
2852 backgroundColor(backgroundColor_);
2856 void Magick::Image::extent(const Geometry &geometry_,
2857 const Color &backgroundColor_,const GravityType gravity_)
2859 backgroundColor(backgroundColor_);
2860 extent(geometry_,gravity_);
2863 void Magick::Image::extent(const Geometry &geometry_,
2864 const GravityType gravity_)
2869 SetGeometry(image(),&geometry);
2870 geometry.width=geometry_.width();
2871 geometry.height=geometry_.height();
2872 GravityAdjustGeometry(image()->columns,image()->rows,gravity_,&geometry);
2876 void Magick::Image::flip(void)
2882 newImage=FlipImage(constImage(),exceptionInfo);
2883 replaceImage(newImage);
2887 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2888 const unsigned int alpha_,const bool invert_)
2896 GetPixelInfo(constImage(),&target);
2897 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2898 target.red=pixel.red;
2899 target.green=pixel.green;
2900 target.blue=pixel.blue;
2901 target.alpha=alpha_;
2903 SetPPChannelMask(AlphaChannel);
2904 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2905 (MagickBooleanType)invert_,exceptionInfo);
2906 RestorePPChannelMask;
2910 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2911 const unsigned int alpha_,const Color &target_,const bool invert_)
2919 GetPixelInfo(constImage(),&target);
2920 pixel=static_cast<PixelInfo>(target_);
2921 target.red=pixel.red;
2922 target.green=pixel.green;
2923 target.blue=pixel.blue;
2924 target.alpha=alpha_;
2926 SetPPChannelMask(AlphaChannel);
2927 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2928 (MagickBooleanType)invert_,exceptionInfo);
2929 RestorePPChannelMask;
2933 void Magick::Image::floodFillColor(const Geometry &point_,
2934 const Magick::Color &fillColor_,const bool invert_)
2936 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,invert_);
2939 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2940 const Magick::Color &fillColor_,const bool invert_)
2947 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2948 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2951 void Magick::Image::floodFillColor(const Geometry &point_,
2952 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2955 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,borderColor_,invert_);
2958 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2959 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2967 pixel=static_cast<PixelInfo>(borderColor_);
2968 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2971 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2972 const Magick::Image &texture_,const bool invert_)
2974 floodFillTexture(point_.xOff(),point_.yOff(),texture_,invert_);
2977 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2978 const Magick::Image &texture_,const bool invert_)
2985 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2986 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
2989 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2990 const Magick::Image &texture_,const Magick::Color &borderColor_,
2993 floodFillTexture(point_.xOff(),point_.yOff(),texture_,borderColor_,invert_);
2996 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2997 const Magick::Image &texture_,const Magick::Color &borderColor_,
3005 pixel=static_cast<PixelInfo>(borderColor_);
3006 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
3009 void Magick::Image::flop(void)
3015 newImage=FlopImage(constImage(),exceptionInfo);
3016 replaceImage(newImage);
3020 void Magick::Image::fontTypeMetrics(const std::string &text_,
3021 TypeMetric *metrics)
3026 drawInfo=options()->drawInfo();
3027 drawInfo->text=const_cast<char *>(text_.c_str());
3029 GetTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3034 void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
3035 TypeMetric *metrics)
3040 drawInfo=options()->drawInfo();
3041 drawInfo->text=const_cast<char *>(text_.c_str());
3043 GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3048 void Magick::Image::frame(const Geometry &geometry_)
3056 info.x=static_cast<ssize_t>(geometry_.width());
3057 info.y=static_cast<ssize_t>(geometry_.height());
3058 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3059 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3060 info.outer_bevel=geometry_.xOff();
3061 info.inner_bevel=geometry_.yOff();
3064 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3065 replaceImage(newImage);
3069 void Magick::Image::frame(const size_t width_,const size_t height_,
3070 const ssize_t outerBevel_,const ssize_t innerBevel_)
3078 info.x=static_cast<ssize_t>(width_);
3079 info.y=static_cast<ssize_t>(height_);
3080 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3081 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3082 info.outer_bevel=static_cast<ssize_t>(outerBevel_);
3083 info.inner_bevel=static_cast<ssize_t>(innerBevel_);
3086 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3087 replaceImage(newImage);
3091 void Magick::Image::fx(const std::string expression_)
3097 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3098 replaceImage(newImage);
3102 void Magick::Image::fx(const std::string expression_,
3103 const Magick::ChannelType channel_)
3109 SetPPChannelMask(channel_);
3110 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3111 RestorePPChannelMask;
3112 replaceImage(newImage);
3116 void Magick::Image::gamma(const double gamma_)
3120 GammaImage(image(),gamma_,exceptionInfo);
3124 void Magick::Image::gamma(const double gammaRed_,const double gammaGreen_,
3125 const double gammaBlue_)
3128 gamma[MaxTextExtent + 1];
3130 FormatLocaleString(gamma,MaxTextExtent,"%3.6f/%3.6f/%3.6f/",gammaRed_,
3131 gammaGreen_,gammaBlue_);
3135 GammaImage(image(),atof(gamma),exceptionInfo);
3139 void Magick::Image::gaussianBlur(const double width_,const double sigma_)
3145 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3146 replaceImage(newImage);
3150 void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
3151 const double width_,const double sigma_)
3157 SetPPChannelMask(channel_);
3158 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3159 RestorePPChannelMask;
3160 replaceImage(newImage);
3164 const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
3165 const ssize_t y_,const size_t columns_,const size_t rows_) const
3171 p=(*GetVirtualPixels)(constImage(),x_, y_,columns_, rows_,exceptionInfo);
3176 const void *Magick::Image::getConstMetacontent(void) const
3181 result=GetVirtualMetacontent(constImage());
3184 throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
3189 void *Magick::Image::getMetacontent(void )
3194 result=GetAuthenticMetacontent(image());
3197 throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
3202 Magick::Quantum *Magick::Image::getPixels(const ssize_t x_,const ssize_t y_,
3203 const size_t columns_,const size_t rows_)
3210 result=(*GetAuthenticPixels)(image(),x_, y_,columns_,rows_,exceptionInfo);
3216 void Magick::Image::grayscale(const PixelIntensityMethod method_)
3220 (void) GrayscaleImage(image(),method_,exceptionInfo);
3224 void Magick::Image::haldClut(const Image &clutImage_)
3228 (void) HaldClutImage(image(),clutImage_.constImage(),exceptionInfo);
3232 void Magick::Image::houghLine(const size_t width_,const size_t height_,
3233 const size_t threshold_)
3239 newImage=HoughLineImage(constImage(),width_,height_,threshold_,
3241 replaceImage(newImage);
3245 void Magick::Image::implode(const double factor_)
3251 newImage=ImplodeImage(constImage(),factor_,image()->interpolate,
3253 replaceImage(newImage);
3257 void Magick::Image::inverseFourierTransform(const Image &phase_)
3259 inverseFourierTransform(phase_,true);
3262 void Magick::Image::inverseFourierTransform(const Image &phase_,
3263 const bool magnitude_)
3269 newImage=InverseFourierTransformImage(constImage(),phase_.constImage(),
3270 magnitude_ == true ? MagickTrue : MagickFalse,exceptionInfo);
3271 replaceImage(newImage);
3275 void Magick::Image::level(const double blackPoint_,const double whitePoint_,
3276 const double gamma_)
3280 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3284 void Magick::Image::levelChannel(const ChannelType channel_,
3285 const double blackPoint_,const double whitePoint_,const double gamma_)
3289 SetPPChannelMask(channel_);
3290 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3291 RestorePPChannelMask;
3295 void Magick::Image::levelColors(const Color &blackColor_,
3296 const Color &whiteColor_,const bool invert_)
3305 GetPixelInfo(image(),&black);
3306 pixel=static_cast<PixelInfo>(blackColor_);
3307 black.red=pixel.red;
3308 black.green=pixel.green;
3309 black.blue=pixel.blue;
3310 black.alpha=pixel.alpha;
3312 GetPixelInfo(image(),&white);
3313 pixel=static_cast<PixelInfo>(whiteColor_);
3314 white.red=pixel.red;
3315 white.green=pixel.green;
3316 white.blue=pixel.blue;
3317 white.alpha=pixel.alpha;
3320 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3321 MagickTrue : MagickFalse,exceptionInfo);
3325 void Magick::Image::levelColorsChannel(const ChannelType channel_,
3326 const Color &blackColor_,const Color &whiteColor_,const bool invert_)
3335 GetPixelInfo(image(),&black);
3336 pixel=static_cast<PixelInfo>(blackColor_);
3337 black.red=pixel.red;
3338 black.green=pixel.green;
3339 black.blue=pixel.blue;
3340 black.alpha=pixel.alpha;
3342 GetPixelInfo(image(),&white);
3343 pixel=static_cast<PixelInfo>(whiteColor_);
3344 white.red=pixel.red;
3345 white.green=pixel.green;
3346 white.blue=pixel.blue;
3347 white.alpha=pixel.alpha;
3350 SetPPChannelMask(channel_);
3351 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3352 MagickTrue : MagickFalse,exceptionInfo);
3353 RestorePPChannelMask;
3357 void Magick::Image::linearStretch(const double blackPoint_,
3358 const double whitePoint_)
3362 LinearStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
3366 void Magick::Image::liquidRescale(const Geometry &geometry_)
3379 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3383 newImage=LiquidRescaleImage(image(),width,height,x,y,exceptionInfo);
3384 replaceImage(newImage);
3388 void Magick::Image::magnify(void)
3394 newImage=MagnifyImage(constImage(),exceptionInfo);
3395 replaceImage(newImage);
3399 void Magick::Image::map(const Image &mapImage_,const bool dither_)
3403 options()->quantizeDither(dither_);
3404 RemapImage(options()->quantizeInfo(),image(),mapImage_.constImage(),
3409 void Magick::Image::medianFilter(const double radius_)
3415 newImage=StatisticImage(image(),MedianStatistic,(size_t) radius_,
3416 (size_t) radius_,exceptionInfo);
3417 replaceImage(newImage);
3421 void Magick::Image::minify(void)
3427 newImage=MinifyImage(constImage(),exceptionInfo);
3428 replaceImage(newImage);
3432 void Magick::Image::modulate(const double brightness_,const double saturation_,
3436 modulate[MaxTextExtent + 1];
3438 FormatLocaleString(modulate,MaxTextExtent,"%3.6f,%3.6f,%3.6f",brightness_,
3443 ModulateImage(image(),modulate,exceptionInfo);
3447 Magick::ImageMoments Magick::Image::moments(void)
3449 return(ImageMoments(constImage()));
3452 void Magick::Image::morphology(const MorphologyMethod method_,
3453 const std::string kernel_,const ssize_t iterations_)
3461 kernel=AcquireKernelInfo(kernel_.c_str());
3462 if (kernel == (KernelInfo *)NULL)
3463 throwExceptionExplicit(OptionError,"Unable to parse kernel.");
3466 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3468 replaceImage(newImage);
3469 kernel=DestroyKernelInfo(kernel);
3473 void Magick::Image::morphology(const MorphologyMethod method_,
3474 const KernelInfoType kernel_,const std::string arguments_,
3475 const ssize_t iterations_)
3483 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3484 if (option == (const char *)NULL)
3485 throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
3487 kernel=std::string(option);
3488 if (!arguments_.empty())
3489 kernel+=":"+arguments_;
3491 morphology(method_,kernel,iterations_);
3494 void Magick::Image::morphologyChannel(const ChannelType channel_,
3495 const MorphologyMethod method_,const std::string kernel_,
3496 const ssize_t iterations_)
3504 kernel=AcquireKernelInfo(kernel_.c_str());
3505 if (kernel == (KernelInfo *)NULL)
3506 throwExceptionExplicit(OptionError,"Unable to parse kernel.");
3509 SetPPChannelMask(channel_);
3510 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3512 RestorePPChannelMask;
3513 replaceImage(newImage);
3514 kernel=DestroyKernelInfo(kernel);
3518 void Magick::Image::morphologyChannel(const ChannelType channel_,
3519 const MorphologyMethod method_,const KernelInfoType kernel_,
3520 const std::string arguments_,const ssize_t iterations_)
3528 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3529 if (option == (const char *)NULL)
3530 throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
3532 kernel=std::string(option);
3533 if (!arguments_.empty())
3534 kernel+=":"+arguments_;
3536 morphologyChannel(channel_,method_,kernel,iterations_);
3539 void Magick::Image::motionBlur(const double radius_,const double sigma_,
3540 const double angle_)
3546 newImage=MotionBlurImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
3547 replaceImage(newImage);
3551 void Magick::Image::negate(const bool grayscale_)
3555 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3559 void Magick::Image::negateChannel(const ChannelType channel_,
3560 const bool grayscale_)
3564 SetPPChannelMask(channel_);
3565 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3566 RestorePPChannelMask;
3570 void Magick::Image::normalize(void)
3574 NormalizeImage(image(),exceptionInfo);
3578 void Magick::Image::oilPaint(const double radius_,const double sigma_)
3584 newImage=OilPaintImage(constImage(),radius_,sigma_,exceptionInfo);
3585 replaceImage(newImage);
3589 void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_,
3600 if (!opaqueColor_.isValid())
3601 throwExceptionExplicit(OptionError,"Opaque color argument is invalid");
3603 if (!penColor_.isValid())
3604 throwExceptionExplicit(OptionError,"Pen color argument is invalid");
3607 opaqueColor=opaqueColor_;
3611 (void) QueryColorCompliance(opaqueColor.c_str(),AllCompliance,&opaque,
3613 (void) QueryColorCompliance(penColor.c_str(),AllCompliance,&pen,
3615 OpaquePaintImage(image(),&opaque,&pen,invert_ ? MagickTrue : MagickFalse,
3620 void Magick::Image::orderedDither(std::string thresholdMap_)
3624 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3628 void Magick::Image::orderedDitherChannel(const ChannelType channel_,
3629 std::string thresholdMap_)
3633 SetPPChannelMask(channel_);
3634 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3635 RestorePPChannelMask;
3639 void Magick::Image::perceptible(const double epsilon_)
3643 PerceptibleImage(image(),epsilon_,exceptionInfo);
3647 void Magick::Image::perceptibleChannel(const ChannelType channel_,
3648 const double epsilon_)
3652 SetPPChannelMask(channel_);
3653 PerceptibleImage(image(),epsilon_,exceptionInfo);
3654 RestorePPChannelMask;
3658 void Magick::Image::ping(const std::string &imageSpec_)
3664 options()->fileName(imageSpec_);
3665 newImage=PingImage(imageInfo(),exceptionInfo);
3666 read(newImage,exceptionInfo);
3669 void Magick::Image::ping(const Blob& blob_)
3675 newImage=PingBlob(imageInfo(),blob_.data(),blob_.length(),exceptionInfo);
3676 read(newImage,exceptionInfo);
3679 void Magick::Image::pixelColor(const ssize_t x_,const ssize_t y_,
3680 const Color &color_)
3688 // Test arguments to ensure they are within the image.
3689 if (y_ > (ssize_t) rows() || x_ > (ssize_t) columns())
3690 throwExceptionExplicit(OptionError,"Access outside of image boundary");
3694 // Set image to DirectClass
3695 classType(DirectClass );
3698 Pixels pixels(*this);
3700 pixel=pixels.get(x_, y_, 1, 1 );
3702 MagickCore::SetPixelInfoPixel(constImage(),&packet,pixel);
3703 // Tell ImageMagick that pixels have been updated
3707 Magick::Color Magick::Image::pixelColor(const ssize_t x_,
3708 const ssize_t y_) const
3713 pixel=getConstPixels(x_,y_,1,1);
3719 MagickCore::GetPixelInfoPixel(constImage(),pixel,&packet);
3720 return(Color(packet));
3723 return(Color()); // invalid
3726 void Magick::Image::polaroid(const std::string &caption_,const double angle_,
3727 const PixelInterpolateMethod method_)
3733 newImage=PolaroidImage(constImage(),options()->drawInfo(),caption_.c_str(),
3734 angle_,method_,exceptionInfo);
3735 replaceImage(newImage);
3739 void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
3743 PosterizeImage(image(),levels_,method_,exceptionInfo);
3747 void Magick::Image::posterizeChannel(const ChannelType channel_,
3748 const size_t levels_,const DitherMethod method_)
3752 SetPPChannelMask(channel_);
3753 PosterizeImage(image(),levels_,method_,exceptionInfo);
3754 RestorePPChannelMask;
3758 void Magick::Image::process(std::string name_,const ssize_t argc,
3764 (void) InvokeDynamicImageFilter(name_.c_str(),&image(),argc,argv,
3769 void Magick::Image::profile(const std::string name_,
3770 const Magick::Blob &profile_)
3774 (void) ProfileImage(image(),name_.c_str(),(unsigned char *)profile_.data(),
3775 profile_.length(),exceptionInfo);
3779 Magick::Blob Magick::Image::profile(const std::string name_) const
3784 profile=GetImageProfile(constImage(),name_.c_str());
3786 if (profile == (StringInfo *) NULL)
3788 return(Blob((void*) GetStringInfoDatum(profile),GetStringInfoLength(
3792 void Magick::Image::quantize(const bool measureError_)
3797 options()->quantizeInfo()->measure_error=MagickTrue;
3799 options()->quantizeInfo()->measure_error=MagickFalse;
3802 QuantizeImage(options()->quantizeInfo(),image(),exceptionInfo);
3806 void Magick::Image::quantumOperator(const ChannelType channel_,
3807 const MagickEvaluateOperator operator_,double rvalue_)
3810 SetPPChannelMask(channel_);
3811 EvaluateImage(image(),operator_,rvalue_,exceptionInfo);
3812 RestorePPChannelMask;
3816 void Magick::Image::quantumOperator(const ssize_t x_,const ssize_t y_,
3817 const size_t columns_,const size_t rows_,const ChannelType channel_,
3818 const MagickEvaluateOperator operator_,const double rvalue_)
3826 geometry.width = columns_;
3827 geometry.height = rows_;
3832 cropImage=CropImage(image(),&geometry,exceptionInfo);
3833 SetPPChannelMask(channel_);
3834 EvaluateImage(cropImage,operator_,rvalue_,exceptionInfo);
3835 RestorePPChannelMask;
3836 (void) CompositeImage(image(),cropImage,image()->alpha_trait ==
3837 BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
3838 geometry.x,geometry.y,exceptionInfo );
3839 cropImage=DestroyImageList(cropImage);
3843 void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
3846 raiseInfo=geometry_;
3850 RaiseImage(image(),&raiseInfo,raisedFlag_ == true ? MagickTrue : MagickFalse,
3855 void Magick::Image::randomThreshold(const Geometry &thresholds_)
3858 (void) RandomThresholdImage(image(),static_cast<std::string>(
3859 thresholds_).c_str(),exceptionInfo);
3863 void Magick::Image::randomThresholdChannel(const ChannelType channel_,
3864 const Geometry &thresholds_)
3868 SetPPChannelMask(channel_);
3869 (void) RandomThresholdImage(image(),static_cast<std::string>(
3870 thresholds_).c_str(),exceptionInfo);
3871 RestorePPChannelMask;
3875 void Magick::Image::read(const Blob &blob_)
3881 newImage=BlobToImage(imageInfo(),static_cast<const void *>(blob_.data()),
3882 blob_.length(),exceptionInfo);
3883 read(newImage,exceptionInfo);
3886 void Magick::Image::read(const Blob &blob_,const Geometry &size_)
3892 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3893 const size_t depth_)
3900 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3901 const size_t depth_,const std::string &magick_)
3906 // Set explicit image format
3907 fileName(magick_ + ':');
3911 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3912 const std::string &magick_)
3916 // Set explicit image format
3917 fileName(magick_ + ':');
3921 void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_)
3927 void Magick::Image::read(const size_t width_,const size_t height_,
3928 const std::string &map_,const StorageType type_,const void *pixels_)
3934 newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
3936 replaceImage(newImage);
3940 void Magick::Image::read(const std::string &imageSpec_)
3946 options()->fileName(imageSpec_);
3947 newImage=ReadImage(imageInfo(),exceptionInfo);
3948 read(newImage,exceptionInfo);
3951 void Magick::Image::readPixels(const Magick::QuantumType quantum_,
3952 const unsigned char *source_)
3957 quantum_info=AcquireQuantumInfo(imageInfo(),image());
3959 ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
3960 quantum_,source_,exceptionInfo);
3961 quantum_info=DestroyQuantumInfo(quantum_info);
3965 void Magick::Image::reduceNoise(void)
3970 void Magick::Image::reduceNoise(const double order_)
3976 newImage=StatisticImage(constImage(),NonpeakStatistic,(size_t) order_,
3977 (size_t) order_,exceptionInfo);
3978 replaceImage(newImage);
3982 void Magick::Image::resample(const Geometry &geometry_)
3995 // Calculate new size. This code should be supported using binary arguments
3996 // in the ImageMagick library.
3997 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4001 newImage=ResampleImage(constImage(),width,height,image()->filter,
4003 replaceImage(newImage);
4007 void Magick::Image::resize(const Geometry &geometry_)
4020 // Calculate new size. This code should be supported using binary arguments
4021 // in the ImageMagick library.
4022 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4026 newImage=ResizeImage(constImage(),width,height,image()->filter,
4028 replaceImage(newImage);
4032 void Magick::Image::roll(const Geometry &roll_)
4038 newImage=RollImage(constImage(),roll_.xOff(),roll_.yOff(),exceptionInfo);
4039 replaceImage(newImage);
4043 void Magick::Image::roll(const size_t columns_,const size_t rows_)
4049 newImage=RollImage(constImage(),static_cast<ssize_t>(columns_),
4050 static_cast<ssize_t>(rows_),exceptionInfo);
4051 replaceImage(newImage);
4055 void Magick::Image::rotate(const double degrees_)
4061 newImage=RotateImage(constImage(),degrees_,exceptionInfo);
4062 replaceImage(newImage);
4066 void Magick::Image::rotationalBlur(const double angle_)
4072 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4073 replaceImage(newImage);
4077 void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
4078 const double angle_)
4084 SetPPChannelMask(channel_);
4085 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4086 RestorePPChannelMask;
4087 replaceImage(newImage);
4091 void Magick::Image::sample(const Geometry &geometry_)
4104 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4108 newImage=SampleImage(constImage(),width,height,exceptionInfo);
4109 replaceImage(newImage);
4113 void Magick::Image::scale(const Geometry &geometry_)
4126 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4130 newImage=ScaleImage(constImage(),width,height,exceptionInfo);
4131 replaceImage(newImage);
4135 void Magick::Image::segment(const double clusterThreshold_,
4136 const double smoothingThreshold_)
4140 SegmentImage(image(),options()->quantizeColorSpace(),
4141 (MagickBooleanType) options()->verbose(),clusterThreshold_,
4142 smoothingThreshold_,exceptionInfo);
4143 SyncImage(image(),exceptionInfo);
4147 void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
4148 const double threshold_)
4154 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4156 replaceImage(newImage);
4160 void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
4161 const double radius_,const double sigma_,const double threshold_)
4167 SetPPChannelMask(channel_);
4168 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4170 RestorePPChannelMask;
4171 replaceImage(newImage);
4175 Magick::Image Magick::Image::separate(const ChannelType channel_)
4181 image=SeparateImage(constImage(),channel_,exceptionInfo);
4183 if (image == (MagickCore::Image *) NULL)
4184 return(Magick::Image());
4186 return(Magick::Image(image));
4189 void Magick::Image::sepiaTone(const double threshold_)
4195 newImage=SepiaToneImage(constImage(),threshold_,exceptionInfo);
4196 replaceImage(newImage);
4200 Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
4201 const size_t columns_,const size_t rows_)
4208 result=(*QueueAuthenticPixels)(image(),x_,y_,columns_,rows_,exceptionInfo);
4213 void Magick::Image::shade(const double azimuth_,const double elevation_,
4214 const bool colorShading_)
4220 newImage=ShadeImage(constImage(),colorShading_ == true ?
4221 MagickTrue : MagickFalse,azimuth_,elevation_,exceptionInfo);
4222 replaceImage(newImage);
4226 void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
4227 const ssize_t x_,const ssize_t y_)
4233 newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
4235 replaceImage(newImage);
4239 void Magick::Image::sharpen(const double radius_,const double sigma_)
4245 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4246 replaceImage(newImage);
4250 void Magick::Image::sharpenChannel(const ChannelType channel_,
4251 const double radius_,const double sigma_)
4257 SetPPChannelMask(channel_);
4258 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4259 RestorePPChannelMask;
4260 replaceImage(newImage);
4264 void Magick::Image::shave(const Geometry &geometry_)
4270 shaveInfo=geometry_;
4273 newImage=ShaveImage(constImage(),&shaveInfo,exceptionInfo);
4274 replaceImage(newImage);
4278 void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
4284 newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,exceptionInfo);
4285 replaceImage(newImage);
4289 void Magick::Image::sigmoidalContrast(const size_t sharpen_,
4290 const double contrast,const double midpoint)
4294 (void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
4295 midpoint,exceptionInfo);
4299 std::string Magick::Image::signature(const bool force_) const
4304 Lock(&_imgRef->_mutexLock);
4306 // Re-calculate image signature if necessary
4308 if (force_ || !GetImageProperty(constImage(),"Signature",exceptionInfo) ||
4309 constImage()->taint)
4310 SignatureImage(const_cast<MagickCore::Image *>(constImage()),
4313 property=GetImageProperty(constImage(),"Signature",exceptionInfo);
4316 return(std::string(property));
4319 void Magick::Image::sketch(const double radius_,const double sigma_,
4320 const double angle_)
4326 newImage=SketchImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
4327 replaceImage(newImage);
4331 void Magick::Image::solarize(const double factor_)
4335 SolarizeImage(image(),factor_,exceptionInfo);
4339 void Magick::Image::sparseColor(const ChannelType channel_,
4340 const SparseColorMethod method_,const size_t numberArguments_,
4341 const double *arguments_)
4347 SetPPChannelMask(channel_);
4348 newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
4350 RestorePPChannelMask;
4351 replaceImage(newImage);
4355 void Magick::Image::splice(const Geometry &geometry_)
4361 spliceInfo=geometry_;
4364 newImage=SpliceImage(constImage(),&spliceInfo,exceptionInfo);
4365 replaceImage(newImage);
4369 void Magick::Image::spread(const size_t amount_)
4375 newImage=SpreadImage(constImage(),amount_,image()->interpolate,
4377 replaceImage(newImage);
4381 Magick::ImageStatistics Magick::Image::statistics()
4383 return(ImageStatistics(constImage()));
4386 void Magick::Image::stegano(const Image &watermark_)
4392 newImage=SteganoImage(constImage(),watermark_.constImage(),exceptionInfo);
4393 replaceImage(newImage);
4397 void Magick::Image::stereo(const Image &rightImage_)
4403 newImage=StereoImage(constImage(),rightImage_.constImage(),exceptionInfo);
4404 replaceImage(newImage);
4408 void Magick::Image::strip(void)
4412 StripImage(image(),exceptionInfo);
4416 Magick::Image Magick::Image::subImageSearch(const Image &reference_,
4417 const MetricType metric_,Geometry *offset_,double *similarityMetric_,
4418 const double similarityThreshold)
4427 newImage=SimilarityImage(image(),reference_.constImage(),metric_,
4428 similarityThreshold,&offset,similarityMetric_,exceptionInfo);
4430 if (offset_ != (Geometry *) NULL)
4432 if (newImage == (MagickCore::Image *) NULL)
4433 return(Magick::Image());
4435 return(Magick::Image(newImage));
4438 void Magick::Image::swirl(const double degrees_)
4444 newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
4446 replaceImage(newImage);
4450 void Magick::Image::syncPixels(void)
4453 (void) (*SyncAuthenticPixels)(image(),exceptionInfo);
4457 void Magick::Image::texture(const Image &texture_)
4461 TextureImage(image(),texture_.constImage(),exceptionInfo);
4465 void Magick::Image::threshold(const double threshold_)
4469 BilevelImage(image(),threshold_,exceptionInfo);
4473 void Magick::Image::thumbnail(const Geometry &geometry_)
4486 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4490 newImage=ThumbnailImage(constImage(),width,height,exceptionInfo);
4491 replaceImage(newImage);
4495 void Magick::Image::tint(const std::string opacity_)
4504 color=static_cast<PixelInfo>(constOptions()->fillColor());
4505 newImage=TintImage(constImage(),opacity_.c_str(),&color,exceptionInfo);
4506 replaceImage(newImage);
4510 void Magick::Image::transform(const Geometry &imageGeometry_)
4514 TransformImage(&(image()),0,std::string(imageGeometry_).c_str(),
4519 void Magick::Image::transform(const Geometry &imageGeometry_,
4520 const Geometry &cropGeometry_)
4524 TransformImage(&(image()),std::string(cropGeometry_).c_str(),std::string(
4525 imageGeometry_).c_str(), exceptionInfo);
4529 void Magick::Image::transformOrigin(const double x_,const double y_)
4532 options()->transformOrigin(x_,y_);
4535 void Magick::Image::transformReset(void)
4538 options()->transformReset();
4541 void Magick::Image::transformScale(const double sx_,const double sy_)
4544 options()->transformScale(sx_,sy_);
4547 void Magick::Image::transparent(const Color &color_)
4555 if (!color_.isValid())
4556 throwExceptionExplicit(OptionError,"Color argument is invalid");
4560 (void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
4563 TransparentPaintImage(image(),&target,TransparentAlpha,MagickFalse,
4568 void Magick::Image::transparentChroma(const Color &colorLow_,
4569 const Color &colorHigh_)
4579 if (!colorLow_.isValid() || !colorHigh_.isValid())
4580 throwExceptionExplicit(OptionError,"Color argument is invalid");
4583 colorHigh=colorHigh_;
4586 (void) QueryColorCompliance(colorLow.c_str(),AllCompliance,&targetLow,
4588 (void) QueryColorCompliance(colorHigh.c_str(),AllCompliance,&targetHigh,
4591 TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
4592 MagickFalse,exceptionInfo);
4596 void Magick::Image::transpose(void)
4602 newImage=TransposeImage(constImage(),exceptionInfo);
4603 replaceImage(newImage);
4607 void Magick::Image::transverse(void)
4613 newImage=TransverseImage(constImage(),exceptionInfo);
4614 replaceImage(newImage);
4618 void Magick::Image::trim(void)
4624 newImage=TrimImage(constImage(),exceptionInfo);
4625 replaceImage(newImage);
4629 Magick::Image Magick::Image::uniqueColors(void)
4635 image=UniqueImageColors(constImage(),exceptionInfo);
4637 if (image == (MagickCore::Image *) NULL)
4638 return(Magick::Image());
4640 return(Magick::Image(image));
4643 void Magick::Image::unsharpmask(const double radius_,const double sigma_,
4644 const double amount_,const double threshold_)
4650 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4652 replaceImage(newImage);
4656 void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
4657 const double radius_,const double sigma_,const double amount_,
4658 const double threshold_)
4664 SetPPChannelMask(channel_);
4665 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4667 RestorePPChannelMask;
4668 replaceImage(newImage);
4672 void Magick::Image::vignette(const double radius_,const double sigma_,
4673 const ssize_t x_,const ssize_t y_)
4679 newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,exceptionInfo);
4680 replaceImage(newImage);
4684 void Magick::Image::wave(const double amplitude_,const double wavelength_)
4690 newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
4692 replaceImage(newImage);
4696 void Magick::Image::whiteThreshold(const std::string &threshold_)
4700 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4704 void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
4705 const std::string &threshold_)
4709 SetPPChannelMask(channel_);
4710 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4711 RestorePPChannelMask;
4715 void Magick::Image::write(Blob *blob_)
4725 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4727 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4731 void Magick::Image::write(Blob *blob_,const std::string &magick_)
4742 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4744 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4748 void Magick::Image::write(Blob *blob_,const std::string &magick_,
4749 const size_t depth_)
4761 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4763 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4767 void Magick::Image::write(const ssize_t x_,const ssize_t y_,
4768 const size_t columns_,const size_t rows_,const std::string &map_,
4769 const StorageType type_,void *pixels_)
4772 ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
4777 void Magick::Image::write(const std::string &imageSpec_)
4780 fileName(imageSpec_);
4782 WriteImage(constImageInfo(),image(),exceptionInfo);
4786 void Magick::Image::writePixels(const Magick::QuantumType quantum_,
4787 unsigned char *destination_)
4792 quantum_info=AcquireQuantumInfo(imageInfo(),image());
4794 ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4795 quantum_,destination_, exceptionInfo);
4796 quantum_info=DestroyQuantumInfo(quantum_info);
4800 void Magick::Image::zoom(const Geometry &geometry_)
4813 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4817 newImage=ResizeImage(constImage(),width,height,image()->filter,exceptionInfo);
4818 replaceImage(newImage);
4822 Magick::Image::Image(MagickCore::Image *image_)
4823 : _imgRef(new ImageRef(image_))
4827 MagickCore::Image *&Magick::Image::image(void)
4829 return(_imgRef->image());
4832 const MagickCore::Image *Magick::Image::constImage(void) const
4834 return(_imgRef->image());
4837 MagickCore::ImageInfo *Magick::Image::imageInfo(void)
4839 return(_imgRef->options()->imageInfo());
4842 const MagickCore::ImageInfo *Magick::Image::constImageInfo(void) const
4844 return(_imgRef->options()->imageInfo());
4847 Magick::Options *Magick::Image::options(void)
4849 return(_imgRef->options());
4852 const Magick::Options *Magick::Image::constOptions(void) const
4854 return(_imgRef->options());
4857 MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)
4859 return(_imgRef->options()->quantizeInfo());
4862 const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
4864 return(_imgRef->options()->quantizeInfo());
4867 void Magick::Image::modifyImage(void)
4870 Lock(&_imgRef->_mutexLock);
4871 if (_imgRef->_refCount == 1)
4873 // De-register image and return
4880 replaceImage(CloneImage(image(),0,0,MagickTrue,exceptionInfo));
4884 ssize_t Magick::Image::registerId(void)
4886 Lock(&_imgRef->_mutexLock);
4887 if ( _imgRef->id() < 0)
4893 _imgRef->id(_imgRef->id()+1);
4894 sprintf(id,"%.20g\n",(double) _imgRef->id());
4895 SetImageRegistry(ImageRegistryType,id,image(),exceptionInfo);
4898 return(_imgRef->id());
4901 MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
4907 image = replacement_;
4911 image=AcquireImage(constImageInfo(),exceptionInfo);
4916 Lock(&_imgRef->_mutexLock);
4918 if (_imgRef->_refCount == 1)
4920 // We own the image, just replace it, and de-register
4922 _imgRef->image(image);
4926 // We don't own the image, dereference and replace with copy
4927 --_imgRef->_refCount;
4928 _imgRef=new ImageRef(image,constOptions());
4932 return(_imgRef->_image);
4935 void Magick::Image::unregisterId(void)
4941 void Magick::Image::read(MagickCore::Image *image,
4942 MagickCore::ExceptionInfo *exceptionInfo)
4944 // Ensure that multiple image frames were not read.
4945 if (image != (MagickCore::Image *) NULL &&
4946 image->next != (MagickCore::Image *) NULL)
4951 // Destroy any extra image frames
4953 image->next=(MagickCore::Image *) NULL;
4954 next->previous=(MagickCore::Image *) NULL;
4955 DestroyImageList(next);
4957 replaceImage(image);
4958 if (exceptionInfo->severity == MagickCore::UndefinedException &&
4959 image == (MagickCore::Image *) NULL)
4961 (void) MagickCore::DestroyExceptionInfo(exceptionInfo);
4962 throwExceptionExplicit(ImageWarning,"No image was loaded.");
4967 void Magick::Image::floodFill(const ssize_t x_,const ssize_t y_,
4968 const Magick::Image *fillPattern_,const Magick::Color &fill_,
4969 const MagickCore::PixelInfo *target_,const bool invert_)
4977 // Set drawing fill pattern or fill color
4978 fillColor=options()->fillColor();
4979 fillPattern=(MagickCore::Image *)NULL;
4980 if (options()->fillPattern() != (MagickCore::Image *)NULL)
4983 fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
4988 if (fillPattern_ == (Magick::Image *)NULL)
4990 options()->fillPattern((MagickCore::Image *)NULL);
4991 options()->fillColor(fill_);
4994 options()->fillPattern(fillPattern_->constImage());
4997 (void) FloodfillPaintImage(image(),options()->drawInfo(),
4998 target_,static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),
4999 (MagickBooleanType) invert_,exceptionInfo);
5001 options()->fillColor(fillColor);
5002 options()->fillPattern(fillPattern);