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)));
1259 void Magick::Image::quality(const size_t quality_)
1262 image()->quality=quality_;
1263 options()->quality(quality_);
1266 size_t Magick::Image::quality(void) const
1268 return(constImage()->quality);
1271 void Magick::Image::quantizeColors(const size_t colors_)
1274 options()->quantizeColors(colors_);
1277 size_t Magick::Image::quantizeColors(void) const
1279 return(constOptions()->quantizeColors());
1282 void Magick::Image::quantizeColorSpace(
1283 const Magick::ColorspaceType colorSpace_)
1286 options()->quantizeColorSpace(colorSpace_);
1289 Magick::ColorspaceType Magick::Image::quantizeColorSpace(void) const
1291 return(constOptions()->quantizeColorSpace());
1294 void Magick::Image::quantizeDither(const bool ditherFlag_)
1297 options()->quantizeDither(ditherFlag_);
1300 bool Magick::Image::quantizeDither(void) const
1302 return(constOptions()->quantizeDither());
1305 void Magick::Image::quantizeDitherMethod(const DitherMethod ditherMethod_)
1308 options()->quantizeDitherMethod(ditherMethod_);
1311 MagickCore::DitherMethod Magick::Image::quantizeDitherMethod(void) const
1313 return(constOptions()->quantizeDitherMethod());
1316 void Magick::Image::quantizeTreeDepth(const size_t treeDepth_)
1319 options()->quantizeTreeDepth(treeDepth_);
1322 size_t Magick::Image::quantizeTreeDepth() const
1324 return(constOptions()->quantizeTreeDepth());
1327 void Magick::Image::renderingIntent(
1328 const Magick::RenderingIntent renderingIntent_)
1331 image()->rendering_intent=renderingIntent_;
1334 Magick::RenderingIntent Magick::Image::renderingIntent(void) const
1336 return(static_cast<Magick::RenderingIntent>(constImage()->rendering_intent));
1339 void Magick::Image::resolutionUnits(
1340 const Magick::ResolutionType resolutionUnits_)
1343 image()->units=resolutionUnits_;
1344 options()->resolutionUnits(resolutionUnits_);
1347 Magick::ResolutionType Magick::Image::resolutionUnits(void) const
1349 return(constOptions()->resolutionUnits());
1352 size_t Magick::Image::rows(void) const
1354 return(constImage()->rows);
1357 void Magick::Image::scene(const size_t scene_)
1360 image()->scene=scene_;
1363 size_t Magick::Image::scene(void) const
1365 return(constImage()->scene);
1368 void Magick::Image::size(const Geometry &geometry_)
1371 options()->size(geometry_);
1372 image()->rows=geometry_.height();
1373 image()->columns=geometry_.width();
1376 Magick::Geometry Magick::Image::size(void) const
1378 return(Magick::Geometry(constImage()->columns,constImage()->rows));
1381 void Magick::Image::strokeAntiAlias(const bool flag_)
1384 options()->strokeAntiAlias(flag_);
1387 bool Magick::Image::strokeAntiAlias(void) const
1389 return(constOptions()->strokeAntiAlias());
1392 void Magick::Image::strokeColor(const Magick::Color &strokeColor_)
1398 options()->strokeColor(strokeColor_);
1400 artifact("stroke",value);
1403 Magick::Color Magick::Image::strokeColor(void) const
1405 return(constOptions()->strokeColor());
1408 void Magick::Image::strokeDashArray(const double *strokeDashArray_)
1411 options()->strokeDashArray(strokeDashArray_);
1414 const double* Magick::Image::strokeDashArray(void) const
1416 return(constOptions()->strokeDashArray());
1419 void Magick::Image::strokeDashOffset(const double strokeDashOffset_)
1422 options()->strokeDashOffset(strokeDashOffset_);
1425 double Magick::Image::strokeDashOffset(void) const
1427 return(constOptions()->strokeDashOffset());
1430 void Magick::Image::strokeLineCap(const Magick::LineCap lineCap_)
1433 options()->strokeLineCap(lineCap_);
1436 Magick::LineCap Magick::Image::strokeLineCap(void) const
1438 return(constOptions()->strokeLineCap());
1441 void Magick::Image::strokeLineJoin(const Magick::LineJoin lineJoin_)
1444 options()->strokeLineJoin(lineJoin_);
1447 Magick::LineJoin Magick::Image::strokeLineJoin(void) const
1449 return(constOptions()->strokeLineJoin());
1452 void Magick::Image::strokeMiterLimit(const size_t strokeMiterLimit_)
1455 options()->strokeMiterLimit(strokeMiterLimit_);
1458 size_t Magick::Image::strokeMiterLimit(void) const
1460 return(constOptions()->strokeMiterLimit());
1463 void Magick::Image::strokePattern(const Image &strokePattern_)
1466 if(strokePattern_.isValid())
1467 options()->strokePattern(strokePattern_.constImage());
1469 options()->strokePattern(static_cast<MagickCore::Image*>(NULL));
1472 Magick::Image Magick::Image::strokePattern(void) const
1474 // FIXME: This is inordinately innefficient
1475 const MagickCore::Image
1481 tmpTexture=constOptions()->strokePattern();
1489 image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
1490 texture.replaceImage(image);
1496 void Magick::Image::strokeWidth(const double strokeWidth_)
1499 value[MaxTextExtent];
1502 options()->strokeWidth(strokeWidth_);
1503 FormatLocaleString(value,MaxTextExtent,"%.20g",strokeWidth_);
1504 (void) SetImageArtifact(image(),"strokewidth",value);
1507 double Magick::Image::strokeWidth(void) const
1509 return(constOptions()->strokeWidth());
1512 void Magick::Image::subImage(const size_t subImage_)
1515 options()->subImage(subImage_);
1518 size_t Magick::Image::subImage(void) const
1520 return(constOptions()->subImage());
1523 void Magick::Image::subRange(const size_t subRange_)
1526 options()->subRange(subRange_);
1529 size_t Magick::Image::subRange(void) const
1531 return(constOptions()->subRange());
1534 void Magick::Image::textDirection(DirectionType direction_)
1537 options()->textDirection(direction_);
1540 Magick::DirectionType Magick::Image::textDirection(void) const
1542 return(constOptions()->textDirection());
1545 void Magick::Image::textEncoding(const std::string &encoding_)
1548 options()->textEncoding(encoding_);
1551 std::string Magick::Image::textEncoding(void) const
1553 return(constOptions()->textEncoding());
1556 void Magick::Image::textGravity(GravityType gravity_)
1559 options()->textGravity(gravity_);
1562 Magick::GravityType Magick::Image::textGravity(void) const
1564 return(constOptions()->textGravity());
1567 void Magick::Image::textInterlineSpacing(double spacing_)
1570 options()->textInterlineSpacing(spacing_);
1573 double Magick::Image::textInterlineSpacing(void) const
1575 return(constOptions()->textInterlineSpacing());
1578 void Magick::Image::textInterwordSpacing(double spacing_)
1581 options()->textInterwordSpacing(spacing_);
1584 double Magick::Image::textInterwordSpacing(void) const
1586 return(constOptions()->textInterwordSpacing());
1589 void Magick::Image::textKerning(double kerning_)
1592 options()->textKerning(kerning_);
1595 double Magick::Image::textKerning(void) const
1597 return(constOptions()->textKerning());
1600 size_t Magick::Image::totalColors(void) const
1606 colors=GetNumberColors(constImage(),0,exceptionInfo);
1611 void Magick::Image::transformRotation(const double angle_)
1614 options()->transformRotation(angle_);
1617 void Magick::Image::transformSkewX(const double skewx_)
1620 options()->transformSkewX(skewx_);
1623 void Magick::Image::transformSkewY(const double skewy_)
1626 options()->transformSkewY(skewy_);
1629 Magick::ImageType Magick::Image::type(void) const
1631 if (constOptions()->type() != UndefinedType)
1632 return(constOptions()->type());
1633 else if (constImage()->type != UndefinedType)
1634 return(constImage()->type);
1636 return(determineType());
1639 void Magick::Image::type(const Magick::ImageType type_)
1642 options()->type(type_);
1644 SetImageType(image(),type_,exceptionInfo);
1648 void Magick::Image::verbose(const bool verboseFlag_)
1651 options()->verbose(verboseFlag_);
1654 bool Magick::Image::verbose(void) const
1656 return(constOptions()->verbose());
1659 void Magick::Image::view(const std::string &view_)
1662 options()->view(view_);
1665 std::string Magick::Image::view(void) const
1667 return(constOptions()->view());
1670 void Magick::Image::virtualPixelMethod(
1671 const VirtualPixelMethod virtualPixelMethod_)
1675 SetImageVirtualPixelMethod(image(),virtualPixelMethod_,exceptionInfo);
1679 Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod(void) const
1681 return(GetImageVirtualPixelMethod(constImage()));
1684 void Magick::Image::x11Display(const std::string &display_)
1687 options()->x11Display(display_);
1690 std::string Magick::Image::x11Display(void) const
1692 return(constOptions()->x11Display());
1695 double Magick::Image::xResolution(void) const
1697 return(constImage()->resolution.x);
1700 double Magick::Image::yResolution(void) const
1702 return(constImage()->resolution.y);
1705 void Magick::Image::adaptiveBlur(const double radius_,const double sigma_)
1711 newImage=AdaptiveBlurImage(constImage(),radius_,sigma_,exceptionInfo);
1712 replaceImage(newImage);
1716 void Magick::Image::adaptiveResize(const Geometry &geometry_)
1729 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
1733 newImage=AdaptiveResizeImage(constImage(),width,height,exceptionInfo);
1734 replaceImage(newImage);
1738 void Magick::Image::adaptiveSharpen(const double radius_,const double sigma_)
1744 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1745 replaceImage(newImage);
1749 void Magick::Image::adaptiveSharpenChannel(const ChannelType channel_,
1750 const double radius_,const double sigma_ )
1756 SetPPChannelMask(channel_);
1757 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1758 RestorePPChannelMask;
1759 replaceImage(newImage);
1763 void Magick::Image::adaptiveThreshold(const size_t width_,const size_t height_,
1764 const ssize_t offset_)
1771 newImage=AdaptiveThresholdImage(constImage(),width_,height_,offset_,
1773 replaceImage(newImage);
1777 void Magick::Image::addNoise(const NoiseType noiseType_)
1783 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1784 replaceImage(newImage);
1788 void Magick::Image::addNoiseChannel(const ChannelType channel_,
1789 const NoiseType noiseType_)
1795 SetPPChannelMask(channel_);
1796 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1797 RestorePPChannelMask;
1798 replaceImage(newImage);
1802 void Magick::Image::affineTransform(const DrawableAffine &affine_)
1810 _affine.sx=affine_.sx();
1811 _affine.sy=affine_.sy();
1812 _affine.rx=affine_.rx();
1813 _affine.ry=affine_.ry();
1814 _affine.tx=affine_.tx();
1815 _affine.ty=affine_.ty();
1818 newImage=AffineTransformImage(constImage(),&_affine,exceptionInfo);
1819 replaceImage(newImage);
1823 void Magick::Image::alpha(const unsigned int alpha_)
1827 SetImageAlpha(image(),alpha_,exceptionInfo);
1831 void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
1835 SetImageAlphaChannel(image(),alphaOption_,exceptionInfo);
1839 void Magick::Image::annotate(const std::string &text_,
1840 const Geometry &location_)
1842 annotate(text_,location_,NorthWestGravity,0.0);
1845 void Magick::Image::annotate(const std::string &text_,
1846 const Geometry &boundingArea_,const GravityType gravity_)
1848 annotate(text_,boundingArea_,gravity_,0.0);
1851 void Magick::Image::annotate(const std::string &text_,
1852 const Geometry &boundingArea_,const GravityType gravity_,
1853 const double degrees_)
1859 boundingArea[MaxTextExtent];
1866 drawInfo=options()->drawInfo();
1867 drawInfo->text=const_cast<char *>(text_.c_str());
1868 drawInfo->geometry=0;
1870 if (boundingArea_.isValid())
1872 if (boundingArea_.width() == 0 || boundingArea_.height() == 0)
1874 FormatLocaleString(boundingArea,MaxTextExtent,"%+.20g%+.20g",
1875 (double) boundingArea_.xOff(),(double) boundingArea_.yOff());
1879 (void) CopyMagickString(boundingArea,string(boundingArea_).c_str(),
1882 drawInfo->geometry=boundingArea;
1885 drawInfo->gravity=gravity_;
1887 oaffine=drawInfo->affine;
1888 if (degrees_ != 0.0)
1901 current=drawInfo->affine;
1902 affine.sx=cos(DegreesToRadians(fmod(degrees_,360.0)));
1903 affine.rx=sin(DegreesToRadians(fmod(degrees_,360.0)));
1904 affine.ry=(-sin(DegreesToRadians(fmod(degrees_,360.0))));
1905 affine.sy=cos(DegreesToRadians(fmod(degrees_,360.0)));
1907 drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
1908 drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
1909 drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
1910 drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
1911 drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty
1916 AnnotateImage(image(),drawInfo,exceptionInfo);
1918 // Restore original values
1919 drawInfo->affine=oaffine;
1921 drawInfo->geometry=0;
1926 void Magick::Image::annotate(const std::string &text_,
1927 const GravityType gravity_)
1934 drawInfo=options()->drawInfo();
1935 drawInfo->text=const_cast<char *>(text_.c_str());
1936 drawInfo->gravity=gravity_;
1939 AnnotateImage(image(),drawInfo,exceptionInfo);
1941 drawInfo->gravity=NorthWestGravity;
1947 void Magick::Image::artifact(const std::string &name_,const std::string &value_)
1950 (void) SetImageArtifact(image(),name_.c_str(),value_.c_str());
1953 std::string Magick::Image::artifact(const std::string &name_)
1958 value=GetImageArtifact(constImage(),name_.c_str());
1960 return(std::string(value));
1961 return(std::string());
1964 void Magick::Image::attribute(const std::string name_,const std::string value_)
1968 SetImageProperty(image(),name_.c_str(),value_.c_str(),exceptionInfo);
1972 std::string Magick::Image::attribute(const std::string name_)
1978 value=GetImageProperty(constImage(),name_.c_str(),exceptionInfo);
1982 return(std::string(value));
1984 return(std::string()); // Intentionally no exception
1987 void Magick::Image::autoGamma(void)
1991 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1992 (void) AutoGammaImage(image(),exceptionInfo);
1996 void Magick::Image::autoGammaChannel(const ChannelType channel_)
2000 SetPPChannelMask(channel_);
2001 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2002 (void) AutoGammaImage(image(),exceptionInfo);
2003 RestorePPChannelMask;
2007 void Magick::Image::autoLevel(void)
2011 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2012 (void) AutoLevelImage(image(),exceptionInfo);
2016 void Magick::Image::autoLevelChannel(const ChannelType channel_)
2020 SetPPChannelMask(channel_);
2021 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2022 (void) AutoLevelImage(image(),exceptionInfo);
2023 RestorePPChannelMask;
2027 void Magick::Image::autoOrient(void)
2032 if (image()->orientation == UndefinedOrientation ||
2033 image()->orientation == TopLeftOrientation)
2037 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2038 newImage=AutoOrientImage(constImage(),image()->orientation,exceptionInfo);
2039 replaceImage(newImage);
2043 void Magick::Image::blackThreshold(const std::string &threshold_)
2047 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2051 void Magick::Image::blackThresholdChannel(const ChannelType channel_,
2052 const std::string &threshold_)
2056 SetPPChannelMask(channel_);
2057 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2058 RestorePPChannelMask;
2062 void Magick::Image::blueShift(const double factor_)
2068 newImage=BlueShiftImage(constImage(),factor_,exceptionInfo);
2069 replaceImage(newImage);
2073 void Magick::Image::blur(const double radius_,const double sigma_)
2079 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2080 replaceImage(newImage);
2084 void Magick::Image::blurChannel(const ChannelType channel_,
2085 const double radius_,const double sigma_)
2091 SetPPChannelMask(channel_);
2092 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2093 RestorePPChannelMask;
2094 replaceImage(newImage);
2098 void Magick::Image::border(const Geometry &geometry_)
2104 borderInfo=geometry_;
2107 newImage=BorderImage(constImage(),&borderInfo,image()->compose,
2109 replaceImage(newImage);
2113 void Magick::Image::brightnessContrast(const double brightness_,
2114 const double contrast_)
2118 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2122 void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
2123 const double brightness_,const double contrast_)
2127 SetPPChannelMask(channel_);
2128 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2129 RestorePPChannelMask;
2133 void Magick::Image::cannyEdge(const double radius_,const double sigma_,
2134 const double lowerPercent_,const double upperPercent_)
2141 newImage=CannyEdgeImage(constImage(),radius_,sigma_,lowerPercent_,
2142 upperPercent_,exceptionInfo);
2143 replaceImage(newImage);
2147 void Magick::Image::channel(const ChannelType channel_)
2153 newImage=SeparateImage(image(),channel_,exceptionInfo);
2154 replaceImage(newImage);
2158 void Magick::Image::charcoal(const double radius_,const double sigma_)
2164 newImage=CharcoalImage(image(),radius_,sigma_,exceptionInfo);
2165 replaceImage(newImage);
2169 void Magick::Image::chop(const Geometry &geometry_)
2178 newImage=ChopImage(image(),&chopInfo,exceptionInfo);
2179 replaceImage(newImage);
2183 void Magick::Image::chromaBluePrimary(const double x_,const double y_)
2186 image()->chromaticity.blue_primary.x=x_;
2187 image()->chromaticity.blue_primary.y=y_;
2190 void Magick::Image::chromaBluePrimary(double *x_,double *y_) const
2192 *x_=constImage()->chromaticity.blue_primary.x;
2193 *y_=constImage()->chromaticity.blue_primary.y;
2196 void Magick::Image::chromaGreenPrimary(const double x_,const double y_)
2199 image()->chromaticity.green_primary.x=x_;
2200 image()->chromaticity.green_primary.y=y_;
2203 void Magick::Image::chromaGreenPrimary(double *x_,double *y_) const
2205 *x_=constImage()->chromaticity.green_primary.x;
2206 *y_=constImage()->chromaticity.green_primary.y;
2209 void Magick::Image::chromaRedPrimary(const double x_,const double y_)
2212 image()->chromaticity.red_primary.x=x_;
2213 image()->chromaticity.red_primary.y=y_;
2216 void Magick::Image::chromaRedPrimary(double *x_,double *y_) const
2218 *x_=constImage()->chromaticity.red_primary.x;
2219 *y_=constImage()->chromaticity.red_primary.y;
2222 void Magick::Image::chromaWhitePoint(const double x_,const double y_)
2225 image()->chromaticity.white_point.x=x_;
2226 image()->chromaticity.white_point.y=y_;
2229 void Magick::Image::chromaWhitePoint(double *x_,double *y_) const
2231 *x_=constImage()->chromaticity.white_point.x;
2232 *y_=constImage()->chromaticity.white_point.y;
2235 void Magick::Image::cdl(const std::string &cdl_)
2239 (void) ColorDecisionListImage(image(),cdl_.c_str(),exceptionInfo);
2243 void Magick::Image::clamp(void)
2247 ClampImage(image(),exceptionInfo);
2251 void Magick::Image::clampChannel(const ChannelType channel_)
2255 SetPPChannelMask(channel_);
2256 ClampImage(image(),exceptionInfo);
2257 RestorePPChannelMask;
2261 void Magick::Image::clip(void)
2265 ClipImage(image(),exceptionInfo);
2269 void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
2273 ClipImagePath(image(),pathname_.c_str(),(MagickBooleanType) inside_,
2278 void Magick::Image::clut(const Image &clutImage_,
2279 const PixelInterpolateMethod method)
2283 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2287 void Magick::Image::clutChannel(const ChannelType channel_,
2288 const Image &clutImage_,const PixelInterpolateMethod method)
2292 SetPPChannelMask(channel_);
2293 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2294 RestorePPChannelMask;
2298 void Magick::Image::colorize(const unsigned int alpha_,const Color &penColor_)
2300 colorize(alpha_,alpha_,alpha_,penColor_);
2303 void Magick::Image::colorize(const unsigned int alphaRed_,
2304 const unsigned int alphaGreen_,const unsigned int alphaBlue_,
2305 const Color &penColor_)
2308 blend[MaxTextExtent];
2317 if (!penColor_.isValid())
2318 throwExceptionExplicit(OptionError,"Pen color argument is invalid");
2320 FormatLocaleString(blend,MaxTextExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
2323 GetPixelInfo(image(),&target);
2324 pixel=static_cast<PixelInfo>(penColor_);
2325 target.red=pixel.red;
2326 target.green=pixel.green;
2327 target.blue=pixel.blue;
2328 target.alpha=pixel.alpha;
2330 newImage=ColorizeImage(image(),blend,&target,exceptionInfo);
2331 replaceImage(newImage);
2335 void Magick::Image::colorMap(const size_t index_,const Color &color_)
2342 if (index_ > (MaxColormapSize-1))
2343 throwExceptionExplicit(OptionError,
2344 "Colormap index must be less than MaxColormapSize");
2346 if (!color_.isValid())
2347 throwExceptionExplicit(OptionError,"Color argument is invalid");
2351 // Ensure that colormap size is large enough
2352 if (colorMapSize() < (index_+1))
2353 colorMapSize(index_+1);
2355 // Set color at index in colormap
2356 (imageptr->colormap)[index_]=color_;
2359 Magick::Color Magick::Image::colorMap(const size_t index_) const
2361 if (!constImage()->colormap)
2363 throwExceptionExplicit(OptionError,"Image does not contain a colormap");
2367 if (index_ > constImage()->colors-1)
2368 throwExceptionExplicit(OptionError,"Index out of range");
2370 return(Magick::Color((constImage()->colormap)[index_]));
2373 void Magick::Image::colorMatrix(const size_t order_,
2374 const double *color_matrix_)
2380 kernel_info=AcquireKernelInfo((const char *) NULL);
2381 if (kernel_info != (KernelInfo *) NULL)
2383 kernel_info->width=order_;
2384 kernel_info->height=order_;
2385 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2386 order_*sizeof(*kernel_info->values));
2387 if (kernel_info->values != (MagickRealType *) NULL)
2392 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2393 kernel_info->values[i]=color_matrix_[i];
2394 newImage=ColorMatrixImage(image(),kernel_info,exceptionInfo);
2395 replaceImage(newImage);
2397 kernel_info=DestroyKernelInfo(kernel_info);
2402 bool Magick::Image::compare(const Image &reference_)
2413 status=static_cast<bool>(IsImagesEqual(image(),ref.image(),exceptionInfo));
2418 double Magick::Image::compare(const Image &reference_,const MetricType metric_)
2424 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2430 double Magick::Image::compareChannel(const ChannelType channel_,
2431 const Image &reference_,const MetricType metric_)
2437 SetPPChannelMask(channel_);
2438 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2440 RestorePPChannelMask;
2445 Magick::Image Magick::Image::compare(const Image &reference_,
2446 const MetricType metric_,double *distortion)
2452 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2455 if (newImage == (MagickCore::Image *) NULL)
2456 return(Magick::Image());
2458 return(Magick::Image(newImage));
2461 Magick::Image Magick::Image::compareChannel(const ChannelType channel_,
2462 const Image &reference_,const MetricType metric_,double *distortion)
2468 SetPPChannelMask(channel_);
2469 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2471 RestorePPChannelMask;
2473 if (newImage == (MagickCore::Image *) NULL)
2474 return(Magick::Image());
2476 return(Magick::Image(newImage));
2479 void Magick::Image::composite(const Image &compositeImage_,
2480 const Geometry &offset_,const CompositeOperator compose_)
2490 ParseMetaGeometry(static_cast<std::string>(offset_).c_str(),&x,&y,&width,
2495 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2500 void Magick::Image::composite(const Image &compositeImage_,
2501 const GravityType gravity_,const CompositeOperator compose_)
2507 SetGeometry(compositeImage_.constImage(),&geometry);
2508 GravityAdjustGeometry(columns(),rows(),gravity_,&geometry);
2511 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2512 geometry.x,geometry.y,exceptionInfo);
2516 void Magick::Image::composite(const Image &compositeImage_,
2517 const ssize_t xOffset_,const ssize_t yOffset_,
2518 const CompositeOperator compose_)
2520 // Image supplied as compositeImage is composited with current image and
2521 // results in updating current image.
2524 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2525 xOffset_,yOffset_,exceptionInfo);
2529 void Magick::Image::contrast(const size_t sharpen_)
2533 ContrastImage(image(),(MagickBooleanType) sharpen_,exceptionInfo);
2537 void Magick::Image::contrastStretch(const double blackPoint_,
2538 const double whitePoint_)
2542 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2546 void Magick::Image::contrastStretchChannel(const ChannelType channel_,
2547 const double blackPoint_,const double whitePoint_)
2551 SetPPChannelMask(channel_);
2552 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2553 RestorePPChannelMask;
2557 void Magick::Image::convolve(const size_t order_,const double *kernel_)
2563 kernel_info=AcquireKernelInfo((const char *) NULL);
2564 kernel_info->width=order_;
2565 kernel_info->height=order_;
2566 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2567 order_*sizeof(*kernel_info->values));
2568 if (kernel_info->values != (MagickRealType *) NULL)
2573 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2574 kernel_info->values[i]=kernel_[i];
2575 newImage=ConvolveImage(image(),kernel_info,exceptionInfo);
2576 replaceImage(newImage);
2578 kernel_info=DestroyKernelInfo(kernel_info);
2582 void Magick::Image::crop(const Geometry &geometry_)
2591 newImage=CropImage(constImage(),&cropInfo,exceptionInfo);
2592 replaceImage(newImage);
2596 void Magick::Image::cycleColormap(const ssize_t amount_)
2600 CycleColormapImage(image(),amount_,exceptionInfo);
2604 void Magick::Image::decipher(const std::string &passphrase_)
2608 DecipherImage(image(),passphrase_.c_str(),exceptionInfo);
2612 void Magick::Image::defineSet(const std::string &magick_,
2613 const std::string &key_,bool flag_)
2619 definition=magick_ + ":" + key_;
2621 (void) SetImageOption(imageInfo(),definition.c_str(),"");
2623 DeleteImageOption(imageInfo(),definition.c_str());
2626 bool Magick::Image::defineSet(const std::string &magick_,
2627 const std::string &key_ ) const
2635 key=magick_ + ":" + key_;
2636 option=GetImageOption(constImageInfo(),key.c_str());
2642 void Magick::Image::defineValue(const std::string &magick_,
2643 const std::string &key_,const std::string &value_)
2650 format=magick_ + ":" + key_;
2652 (void) SetImageOption(imageInfo(),format.c_str(),option.c_str());
2655 std::string Magick::Image::defineValue(const std::string &magick_,
2656 const std::string &key_) const
2664 definition=magick_ + ":" + key_;
2665 option=GetImageOption(constImageInfo(),definition.c_str());
2667 return(std::string(option));
2668 return(std::string());
2671 void Magick::Image::deskew(const double threshold_)
2677 newImage=DeskewImage(constImage(),threshold_,exceptionInfo);
2678 replaceImage(newImage);
2682 void Magick::Image::despeckle(void)
2688 newImage=DespeckleImage(constImage(),exceptionInfo);
2689 replaceImage(newImage);
2693 Magick::ImageType Magick::Image::determineType(void) const
2699 image_type=GetImageType(constImage(),exceptionInfo);
2704 void Magick::Image::display(void)
2707 DisplayImages(imageInfo(),image(),exceptionInfo);
2711 void Magick::Image::distort(const DistortImageMethod method_,
2712 const size_t numberArguments_,const double *arguments_,const bool bestfit_)
2718 newImage=DistortImage(constImage(), method_,numberArguments_,arguments_,
2719 bestfit_ == true ? MagickTrue : MagickFalse,exceptionInfo);
2720 replaceImage(newImage);
2724 void Magick::Image::draw(const Magick::Drawable &drawable_)
2731 wand=DrawAllocateWand(options()->drawInfo(),image());
2735 drawable_.operator()(wand);
2739 ClonePPDrawException(wand);
2740 wand=DestroyDrawingWand(wand);
2741 ThrowPPDrawException;
2745 void Magick::Image::draw(const std::list<Magick::Drawable> &drawable_)
2752 wand=DrawAllocateWand(options()->drawInfo(),image());
2756 for (std::list<Magick::Drawable>::const_iterator p = drawable_.begin();
2757 p != drawable_.end(); p++ )
2759 p->operator()(wand);
2760 if (DrawGetExceptionType(wand) != UndefinedException)
2764 if (DrawGetExceptionType(wand) == UndefinedException)
2767 ClonePPDrawException(wand);
2768 wand=DestroyDrawingWand(wand);
2769 ThrowPPDrawException;
2773 void Magick::Image::edge(const double radius_)
2779 newImage=EdgeImage(constImage(),radius_,exceptionInfo);
2780 replaceImage(newImage);
2784 void Magick::Image::emboss(const double radius_,const double sigma_)
2790 newImage=EmbossImage(constImage(),radius_,sigma_,exceptionInfo);
2791 replaceImage(newImage);
2795 void Magick::Image::encipher(const std::string &passphrase_)
2799 EncipherImage(image(),passphrase_.c_str(),exceptionInfo);
2803 void Magick::Image::enhance(void)
2809 newImage=EnhanceImage(constImage(),exceptionInfo);
2810 replaceImage(newImage);
2814 void Magick::Image::equalize(void)
2818 EqualizeImage(image(),exceptionInfo);
2822 void Magick::Image::erase(void)
2826 (void) SetImageBackgroundColor(image(),exceptionInfo);
2830 void Magick::Image::extent(const Geometry &geometry_ )
2836 extentInfo=geometry_;
2839 extentInfo.x=geometry_.xOff();
2840 extentInfo.y=geometry_.yOff();
2842 newImage=ExtentImage(image(),&extentInfo,exceptionInfo);
2843 replaceImage(newImage);
2847 void Magick::Image::extent(const Geometry &geometry_,
2848 const Color &backgroundColor_)
2850 backgroundColor(backgroundColor_);
2854 void Magick::Image::extent(const Geometry &geometry_,
2855 const Color &backgroundColor_,const GravityType gravity_)
2857 backgroundColor(backgroundColor_);
2858 extent(geometry_,gravity_);
2861 void Magick::Image::extent(const Geometry &geometry_,
2862 const GravityType gravity_)
2867 SetGeometry(image(),&geometry);
2868 geometry.width=geometry_.width();
2869 geometry.height=geometry_.height();
2870 GravityAdjustGeometry(image()->columns,image()->rows,gravity_,&geometry);
2874 void Magick::Image::flip(void)
2880 newImage=FlipImage(constImage(),exceptionInfo);
2881 replaceImage(newImage);
2885 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2886 const unsigned int alpha_,const bool invert_)
2894 GetPixelInfo(constImage(),&target);
2895 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2896 target.red=pixel.red;
2897 target.green=pixel.green;
2898 target.blue=pixel.blue;
2899 target.alpha=alpha_;
2901 SetPPChannelMask(AlphaChannel);
2902 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2903 (MagickBooleanType)invert_,exceptionInfo);
2904 RestorePPChannelMask;
2908 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2909 const unsigned int alpha_,const Color &target_,const bool invert_)
2917 GetPixelInfo(constImage(),&target);
2918 pixel=static_cast<PixelInfo>(target_);
2919 target.red=pixel.red;
2920 target.green=pixel.green;
2921 target.blue=pixel.blue;
2922 target.alpha=alpha_;
2924 SetPPChannelMask(AlphaChannel);
2925 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2926 (MagickBooleanType)invert_,exceptionInfo);
2927 RestorePPChannelMask;
2931 void Magick::Image::floodFillColor(const Geometry &point_,
2932 const Magick::Color &fillColor_,const bool invert_)
2934 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,invert_);
2937 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2938 const Magick::Color &fillColor_,const bool invert_)
2945 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2946 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2949 void Magick::Image::floodFillColor(const Geometry &point_,
2950 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2953 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,borderColor_,invert_);
2956 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2957 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2965 pixel=static_cast<PixelInfo>(borderColor_);
2966 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2969 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2970 const Magick::Image &texture_,const bool invert_)
2972 floodFillTexture(point_.xOff(),point_.yOff(),texture_,invert_);
2975 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2976 const Magick::Image &texture_,const bool invert_)
2983 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2984 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
2987 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2988 const Magick::Image &texture_,const Magick::Color &borderColor_,
2991 floodFillTexture(point_.xOff(),point_.yOff(),texture_,borderColor_,invert_);
2994 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2995 const Magick::Image &texture_,const Magick::Color &borderColor_,
3003 pixel=static_cast<PixelInfo>(borderColor_);
3004 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
3007 void Magick::Image::flop(void)
3013 newImage=FlopImage(constImage(),exceptionInfo);
3014 replaceImage(newImage);
3018 void Magick::Image::fontTypeMetrics(const std::string &text_,
3019 TypeMetric *metrics)
3024 drawInfo=options()->drawInfo();
3025 drawInfo->text=const_cast<char *>(text_.c_str());
3027 GetTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3032 void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
3033 TypeMetric *metrics)
3038 drawInfo=options()->drawInfo();
3039 drawInfo->text=const_cast<char *>(text_.c_str());
3041 GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3046 void Magick::Image::frame(const Geometry &geometry_)
3054 info.x=static_cast<ssize_t>(geometry_.width());
3055 info.y=static_cast<ssize_t>(geometry_.height());
3056 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3057 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3058 info.outer_bevel=geometry_.xOff();
3059 info.inner_bevel=geometry_.yOff();
3062 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3063 replaceImage(newImage);
3067 void Magick::Image::frame(const size_t width_,const size_t height_,
3068 const ssize_t outerBevel_,const ssize_t innerBevel_)
3076 info.x=static_cast<ssize_t>(width_);
3077 info.y=static_cast<ssize_t>(height_);
3078 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3079 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3080 info.outer_bevel=static_cast<ssize_t>(outerBevel_);
3081 info.inner_bevel=static_cast<ssize_t>(innerBevel_);
3084 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3085 replaceImage(newImage);
3089 void Magick::Image::fx(const std::string expression_)
3095 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3096 replaceImage(newImage);
3100 void Magick::Image::fx(const std::string expression_,
3101 const Magick::ChannelType channel_)
3107 SetPPChannelMask(channel_);
3108 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3109 RestorePPChannelMask;
3110 replaceImage(newImage);
3114 void Magick::Image::gamma(const double gamma_)
3118 GammaImage(image(),gamma_,exceptionInfo);
3122 void Magick::Image::gamma(const double gammaRed_,const double gammaGreen_,
3123 const double gammaBlue_)
3126 gamma[MaxTextExtent + 1];
3128 FormatLocaleString(gamma,MaxTextExtent,"%3.6f/%3.6f/%3.6f/",gammaRed_,
3129 gammaGreen_,gammaBlue_);
3133 GammaImage(image(),atof(gamma),exceptionInfo);
3137 void Magick::Image::gaussianBlur(const double width_,const double sigma_)
3143 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3144 replaceImage(newImage);
3148 void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
3149 const double width_,const double sigma_)
3155 SetPPChannelMask(channel_);
3156 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3157 RestorePPChannelMask;
3158 replaceImage(newImage);
3162 const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
3163 const ssize_t y_,const size_t columns_,const size_t rows_) const
3169 p=(*GetVirtualPixels)(constImage(),x_, y_,columns_, rows_,exceptionInfo);
3174 const void *Magick::Image::getConstMetacontent(void) const
3179 result=GetVirtualMetacontent(constImage());
3182 throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
3187 void *Magick::Image::getMetacontent(void )
3192 result=GetAuthenticMetacontent(image());
3195 throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
3200 Magick::Quantum *Magick::Image::getPixels(const ssize_t x_,const ssize_t y_,
3201 const size_t columns_,const size_t rows_)
3208 result=(*GetAuthenticPixels)(image(),x_, y_,columns_,rows_,exceptionInfo);
3214 void Magick::Image::grayscale(const PixelIntensityMethod method_)
3218 (void) GrayscaleImage(image(),method_,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_,
3598 if (!opaqueColor_.isValid())
3599 throwExceptionExplicit(OptionError,"Opaque color argument is invalid");
3601 if (!penColor_.isValid())
3602 throwExceptionExplicit(OptionError,"Pen color argument is invalid");
3605 opaqueColor=opaqueColor_;
3609 (void) QueryColorCompliance(opaqueColor.c_str(),AllCompliance,&opaque,
3611 (void) QueryColorCompliance(penColor.c_str(),AllCompliance,&pen,
3613 OpaquePaintImage(image(),&opaque,&pen,invert_ ? MagickTrue : MagickFalse,
3618 void Magick::Image::orderedDither(std::string thresholdMap_)
3622 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3626 void Magick::Image::orderedDitherChannel(const ChannelType channel_,
3627 std::string thresholdMap_)
3631 SetPPChannelMask(channel_);
3632 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3633 RestorePPChannelMask;
3637 void Magick::Image::perceptible(const double epsilon_)
3641 PerceptibleImage(image(),epsilon_,exceptionInfo);
3645 void Magick::Image::perceptibleChannel(const ChannelType channel_,
3646 const double epsilon_)
3650 SetPPChannelMask(channel_);
3651 PerceptibleImage(image(),epsilon_,exceptionInfo);
3652 RestorePPChannelMask;
3656 void Magick::Image::ping(const std::string &imageSpec_)
3662 options()->fileName(imageSpec_);
3663 newImage=PingImage(imageInfo(),exceptionInfo);
3664 read(newImage,exceptionInfo);
3667 void Magick::Image::ping(const Blob& blob_)
3673 newImage=PingBlob(imageInfo(),blob_.data(),blob_.length(),exceptionInfo);
3674 read(newImage,exceptionInfo);
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 read(newImage,exceptionInfo);
3884 void Magick::Image::read(const Blob &blob_,const Geometry &size_)
3890 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3891 const size_t depth_)
3898 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3899 const size_t depth_,const std::string &magick_)
3904 // Set explicit image format
3905 fileName(magick_ + ':');
3909 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3910 const std::string &magick_)
3914 // Set explicit image format
3915 fileName(magick_ + ':');
3919 void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_)
3925 void Magick::Image::read(const size_t width_,const size_t height_,
3926 const std::string &map_,const StorageType type_,const void *pixels_)
3932 newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
3934 replaceImage(newImage);
3938 void Magick::Image::read(const std::string &imageSpec_)
3944 options()->fileName(imageSpec_);
3945 newImage=ReadImage(imageInfo(),exceptionInfo);
3946 read(newImage,exceptionInfo);
3949 void Magick::Image::readPixels(const Magick::QuantumType quantum_,
3950 const unsigned char *source_)
3955 quantum_info=AcquireQuantumInfo(imageInfo(),image());
3957 ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
3958 quantum_,source_,exceptionInfo);
3959 quantum_info=DestroyQuantumInfo(quantum_info);
3963 void Magick::Image::reduceNoise(void)
3968 void Magick::Image::reduceNoise(const double order_)
3974 newImage=StatisticImage(constImage(),NonpeakStatistic,(size_t) order_,
3975 (size_t) order_,exceptionInfo);
3976 replaceImage(newImage);
3980 void Magick::Image::resample(const Geometry &geometry_)
3993 // Calculate new size. This code should be supported using binary arguments
3994 // in the ImageMagick library.
3995 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3999 newImage=ResampleImage(constImage(),width,height,image()->filter,
4001 replaceImage(newImage);
4005 void Magick::Image::resize(const Geometry &geometry_)
4018 // Calculate new size. This code should be supported using binary arguments
4019 // in the ImageMagick library.
4020 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4024 newImage=ResizeImage(constImage(),width,height,image()->filter,
4026 replaceImage(newImage);
4030 void Magick::Image::roll(const Geometry &roll_)
4036 newImage=RollImage(constImage(),roll_.xOff(),roll_.yOff(),exceptionInfo);
4037 replaceImage(newImage);
4041 void Magick::Image::roll(const size_t columns_,const size_t rows_)
4047 newImage=RollImage(constImage(),static_cast<ssize_t>(columns_),
4048 static_cast<ssize_t>(rows_),exceptionInfo);
4049 replaceImage(newImage);
4053 void Magick::Image::rotate(const double degrees_)
4059 newImage=RotateImage(constImage(),degrees_,exceptionInfo);
4060 replaceImage(newImage);
4064 void Magick::Image::rotationalBlur(const double angle_)
4070 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4071 replaceImage(newImage);
4075 void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
4076 const double angle_)
4082 SetPPChannelMask(channel_);
4083 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4084 RestorePPChannelMask;
4085 replaceImage(newImage);
4089 void Magick::Image::sample(const Geometry &geometry_)
4102 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4106 newImage=SampleImage(constImage(),width,height,exceptionInfo);
4107 replaceImage(newImage);
4111 void Magick::Image::scale(const Geometry &geometry_)
4124 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4128 newImage=ScaleImage(constImage(),width,height,exceptionInfo);
4129 replaceImage(newImage);
4133 void Magick::Image::segment(const double clusterThreshold_,
4134 const double smoothingThreshold_)
4138 SegmentImage(image(),options()->quantizeColorSpace(),
4139 (MagickBooleanType) options()->verbose(),clusterThreshold_,
4140 smoothingThreshold_,exceptionInfo);
4141 SyncImage(image(),exceptionInfo);
4145 void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
4146 const double threshold_)
4152 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4154 replaceImage(newImage);
4158 void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
4159 const double radius_,const double sigma_,const double threshold_)
4165 SetPPChannelMask(channel_);
4166 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4168 RestorePPChannelMask;
4169 replaceImage(newImage);
4173 Magick::Image Magick::Image::separate(const ChannelType channel_)
4179 image=SeparateImage(constImage(),channel_,exceptionInfo);
4181 if (image == (MagickCore::Image *) NULL)
4182 return(Magick::Image());
4184 return(Magick::Image(image));
4187 void Magick::Image::sepiaTone(const double threshold_)
4193 newImage=SepiaToneImage(constImage(),threshold_,exceptionInfo);
4194 replaceImage(newImage);
4198 Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
4199 const size_t columns_,const size_t rows_)
4206 result=(*QueueAuthenticPixels)(image(),x_,y_,columns_,rows_,exceptionInfo);
4211 void Magick::Image::shade(const double azimuth_,const double elevation_,
4212 const bool colorShading_)
4218 newImage=ShadeImage(constImage(),colorShading_ == true ?
4219 MagickTrue : MagickFalse,azimuth_,elevation_,exceptionInfo);
4220 replaceImage(newImage);
4224 void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
4225 const ssize_t x_,const ssize_t y_)
4231 newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
4233 replaceImage(newImage);
4237 void Magick::Image::sharpen(const double radius_,const double sigma_)
4243 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4244 replaceImage(newImage);
4248 void Magick::Image::sharpenChannel(const ChannelType channel_,
4249 const double radius_,const double sigma_)
4255 SetPPChannelMask(channel_);
4256 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4257 RestorePPChannelMask;
4258 replaceImage(newImage);
4262 void Magick::Image::shave(const Geometry &geometry_)
4268 shaveInfo=geometry_;
4271 newImage=ShaveImage(constImage(),&shaveInfo,exceptionInfo);
4272 replaceImage(newImage);
4276 void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
4282 newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,exceptionInfo);
4283 replaceImage(newImage);
4287 void Magick::Image::sigmoidalContrast(const size_t sharpen_,
4288 const double contrast,const double midpoint)
4292 (void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
4293 midpoint,exceptionInfo);
4297 std::string Magick::Image::signature(const bool force_) const
4302 Lock(&_imgRef->_mutexLock);
4304 // Re-calculate image signature if necessary
4306 if (force_ || !GetImageProperty(constImage(),"Signature",exceptionInfo) ||
4307 constImage()->taint)
4308 SignatureImage(const_cast<MagickCore::Image *>(constImage()),
4311 property=GetImageProperty(constImage(),"Signature",exceptionInfo);
4314 return(std::string(property));
4317 void Magick::Image::sketch(const double radius_,const double sigma_,
4318 const double angle_)
4324 newImage=SketchImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
4325 replaceImage(newImage);
4329 void Magick::Image::solarize(const double factor_)
4333 SolarizeImage(image(),factor_,exceptionInfo);
4337 void Magick::Image::sparseColor(const ChannelType channel_,
4338 const SparseColorMethod method_,const size_t numberArguments_,
4339 const double *arguments_)
4345 SetPPChannelMask(channel_);
4346 newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
4348 RestorePPChannelMask;
4349 replaceImage(newImage);
4353 void Magick::Image::splice(const Geometry &geometry_)
4359 spliceInfo=geometry_;
4362 newImage=SpliceImage(constImage(),&spliceInfo,exceptionInfo);
4363 replaceImage(newImage);
4367 void Magick::Image::spread(const size_t amount_)
4373 newImage=SpreadImage(constImage(),amount_,image()->interpolate,
4375 replaceImage(newImage);
4379 Magick::ImageStatistics Magick::Image::statistics()
4381 return(ImageStatistics(constImage()));
4384 void Magick::Image::stegano(const Image &watermark_)
4390 newImage=SteganoImage(constImage(),watermark_.constImage(),exceptionInfo);
4391 replaceImage(newImage);
4395 void Magick::Image::stereo(const Image &rightImage_)
4401 newImage=StereoImage(constImage(),rightImage_.constImage(),exceptionInfo);
4402 replaceImage(newImage);
4406 void Magick::Image::strip(void)
4410 StripImage(image(),exceptionInfo);
4414 Magick::Image Magick::Image::subImageSearch(const Image &reference_,
4415 const MetricType metric_,Geometry *offset_,double *similarityMetric_,
4416 const double similarityThreshold)
4425 newImage=SimilarityImage(image(),reference_.constImage(),metric_,
4426 similarityThreshold,&offset,similarityMetric_,exceptionInfo);
4428 if (offset_ != (Geometry *) NULL)
4430 if (newImage == (MagickCore::Image *) NULL)
4431 return(Magick::Image());
4433 return(Magick::Image(newImage));
4436 void Magick::Image::swirl(const double degrees_)
4442 newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
4444 replaceImage(newImage);
4448 void Magick::Image::syncPixels(void)
4451 (void) (*SyncAuthenticPixels)(image(),exceptionInfo);
4455 void Magick::Image::texture(const Image &texture_)
4459 TextureImage(image(),texture_.constImage(),exceptionInfo);
4463 void Magick::Image::threshold(const double threshold_)
4467 BilevelImage(image(),threshold_,exceptionInfo);
4471 void Magick::Image::thumbnail(const Geometry &geometry_)
4484 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4488 newImage=ThumbnailImage(constImage(),width,height,exceptionInfo);
4489 replaceImage(newImage);
4493 void Magick::Image::tint(const std::string opacity_)
4502 color=static_cast<PixelInfo>(constOptions()->fillColor());
4503 newImage=TintImage(constImage(),opacity_.c_str(),&color,exceptionInfo);
4504 replaceImage(newImage);
4508 void Magick::Image::transform(const Geometry &imageGeometry_)
4512 TransformImage(&(image()),0,std::string(imageGeometry_).c_str(),
4517 void Magick::Image::transform(const Geometry &imageGeometry_,
4518 const Geometry &cropGeometry_)
4522 TransformImage(&(image()),std::string(cropGeometry_).c_str(),std::string(
4523 imageGeometry_).c_str(), exceptionInfo);
4527 void Magick::Image::transformOrigin(const double x_,const double y_)
4530 options()->transformOrigin(x_,y_);
4533 void Magick::Image::transformReset(void)
4536 options()->transformReset();
4539 void Magick::Image::transformScale(const double sx_,const double sy_)
4542 options()->transformScale(sx_,sy_);
4545 void Magick::Image::transparent(const Color &color_)
4553 if (!color_.isValid())
4554 throwExceptionExplicit(OptionError,"Color argument is invalid");
4558 (void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
4561 TransparentPaintImage(image(),&target,TransparentAlpha,MagickFalse,
4566 void Magick::Image::transparentChroma(const Color &colorLow_,
4567 const Color &colorHigh_)
4577 if (!colorLow_.isValid() || !colorHigh_.isValid())
4578 throwExceptionExplicit(OptionError,"Color argument is invalid");
4581 colorHigh=colorHigh_;
4584 (void) QueryColorCompliance(colorLow.c_str(),AllCompliance,&targetLow,
4586 (void) QueryColorCompliance(colorHigh.c_str(),AllCompliance,&targetHigh,
4589 TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
4590 MagickFalse,exceptionInfo);
4594 void Magick::Image::transpose(void)
4600 newImage=TransposeImage(constImage(),exceptionInfo);
4601 replaceImage(newImage);
4605 void Magick::Image::transverse(void)
4611 newImage=TransverseImage(constImage(),exceptionInfo);
4612 replaceImage(newImage);
4616 void Magick::Image::trim(void)
4622 newImage=TrimImage(constImage(),exceptionInfo);
4623 replaceImage(newImage);
4627 Magick::Image Magick::Image::uniqueColors(void)
4633 image=UniqueImageColors(constImage(),exceptionInfo);
4635 if (image == (MagickCore::Image *) NULL)
4636 return(Magick::Image());
4638 return(Magick::Image(image));
4641 void Magick::Image::unsharpmask(const double radius_,const double sigma_,
4642 const double amount_,const double threshold_)
4648 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4650 replaceImage(newImage);
4654 void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
4655 const double radius_,const double sigma_,const double amount_,
4656 const double threshold_)
4662 SetPPChannelMask(channel_);
4663 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4665 RestorePPChannelMask;
4666 replaceImage(newImage);
4670 void Magick::Image::vignette(const double radius_,const double sigma_,
4671 const ssize_t x_,const ssize_t y_)
4677 newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,exceptionInfo);
4678 replaceImage(newImage);
4682 void Magick::Image::wave(const double amplitude_,const double wavelength_)
4688 newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
4690 replaceImage(newImage);
4694 void Magick::Image::whiteThreshold(const std::string &threshold_)
4698 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4702 void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
4703 const std::string &threshold_)
4707 SetPPChannelMask(channel_);
4708 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4709 RestorePPChannelMask;
4713 void Magick::Image::write(Blob *blob_)
4723 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4725 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4729 void Magick::Image::write(Blob *blob_,const std::string &magick_)
4740 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4742 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4746 void Magick::Image::write(Blob *blob_,const std::string &magick_,
4747 const size_t depth_)
4759 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4761 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4765 void Magick::Image::write(const ssize_t x_,const ssize_t y_,
4766 const size_t columns_,const size_t rows_,const std::string &map_,
4767 const StorageType type_,void *pixels_)
4770 ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
4775 void Magick::Image::write(const std::string &imageSpec_)
4778 fileName(imageSpec_);
4780 WriteImage(constImageInfo(),image(),exceptionInfo);
4784 void Magick::Image::writePixels(const Magick::QuantumType quantum_,
4785 unsigned char *destination_)
4790 quantum_info=AcquireQuantumInfo(imageInfo(),image());
4792 ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4793 quantum_,destination_, exceptionInfo);
4794 quantum_info=DestroyQuantumInfo(quantum_info);
4798 void Magick::Image::zoom(const Geometry &geometry_)
4811 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4815 newImage=ResizeImage(constImage(),width,height,image()->filter,exceptionInfo);
4816 replaceImage(newImage);
4820 Magick::Image::Image(MagickCore::Image *image_)
4821 : _imgRef(new ImageRef(image_))
4825 MagickCore::Image *&Magick::Image::image(void)
4827 return(_imgRef->image());
4830 const MagickCore::Image *Magick::Image::constImage(void) const
4832 return(_imgRef->image());
4835 MagickCore::ImageInfo *Magick::Image::imageInfo(void)
4837 return(_imgRef->options()->imageInfo());
4840 const MagickCore::ImageInfo *Magick::Image::constImageInfo(void) const
4842 return(_imgRef->options()->imageInfo());
4845 Magick::Options *Magick::Image::options(void)
4847 return(_imgRef->options());
4850 const Magick::Options *Magick::Image::constOptions(void) const
4852 return(_imgRef->options());
4855 MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)
4857 return(_imgRef->options()->quantizeInfo());
4860 const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
4862 return(_imgRef->options()->quantizeInfo());
4865 void Magick::Image::modifyImage(void)
4868 Lock(&_imgRef->_mutexLock);
4869 if (_imgRef->_refCount == 1)
4871 // De-register image and return
4878 replaceImage(CloneImage(image(),0,0,MagickTrue,exceptionInfo));
4882 ssize_t Magick::Image::registerId(void)
4884 Lock(&_imgRef->_mutexLock);
4885 if ( _imgRef->id() < 0)
4891 _imgRef->id(_imgRef->id()+1);
4892 sprintf(id,"%.20g\n",(double) _imgRef->id());
4893 SetImageRegistry(ImageRegistryType,id,image(),exceptionInfo);
4896 return(_imgRef->id());
4899 MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
4905 image = replacement_;
4909 image=AcquireImage(constImageInfo(),exceptionInfo);
4914 Lock(&_imgRef->_mutexLock);
4916 if (_imgRef->_refCount == 1)
4918 // We own the image, just replace it, and de-register
4920 _imgRef->image(image);
4924 // We don't own the image, dereference and replace with copy
4925 --_imgRef->_refCount;
4926 _imgRef=new ImageRef(image,constOptions());
4930 return(_imgRef->_image);
4933 void Magick::Image::unregisterId(void)
4939 void Magick::Image::read(MagickCore::Image *image,
4940 MagickCore::ExceptionInfo *exceptionInfo)
4942 // Ensure that multiple image frames were not read.
4943 if (image != (MagickCore::Image *) NULL &&
4944 image->next != (MagickCore::Image *) NULL)
4949 // Destroy any extra image frames
4951 image->next=(MagickCore::Image *) NULL;
4952 next->previous=(MagickCore::Image *) NULL;
4953 DestroyImageList(next);
4955 replaceImage(image);
4956 if (exceptionInfo->severity == MagickCore::UndefinedException &&
4957 image == (MagickCore::Image *) NULL)
4959 (void) MagickCore::DestroyExceptionInfo(exceptionInfo);
4960 throwExceptionExplicit(ImageWarning,"No image was loaded.");
4965 void Magick::Image::floodFill(const ssize_t x_,const ssize_t y_,
4966 const Magick::Image *fillPattern_,const Magick::Color &fill_,
4967 const MagickCore::PixelInfo *target_,const bool invert_)
4975 // Set drawing fill pattern or fill color
4976 fillColor=options()->fillColor();
4977 fillPattern=(MagickCore::Image *)NULL;
4978 if (options()->fillPattern() != (MagickCore::Image *)NULL)
4981 fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
4986 if (fillPattern_ == (Magick::Image *)NULL)
4988 options()->fillPattern((MagickCore::Image *)NULL);
4989 options()->fillColor(fill_);
4992 options()->fillPattern(fillPattern_->constImage());
4995 (void) FloodfillPaintImage(image(),options()->drawInfo(),
4996 target_,static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),
4997 (MagickBooleanType) invert_,exceptionInfo);
4999 options()->fillColor(fillColor);
5000 options()->fillPattern(fillPattern);