1 // This may look like C code, but it is really -*- C++ -*-
3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
4 // Copyright Dirk Lemstra 2013-2015
6 // Implementation of Image
9 #define MAGICKCORE_IMPLEMENTATION 1
10 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
12 #include "Magick++/Include.h"
21 #include "Magick++/Image.h"
22 #include "Magick++/Functions.h"
23 #include "Magick++/Pixels.h"
24 #include "Magick++/Options.h"
25 #include "Magick++/ImageRef.h"
27 #define AbsoluteValue(x) ((x) < 0 ? -(x) : (x))
28 #define MagickPI 3.14159265358979323846264338327950288419716939937510
29 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
30 #define ThrowImageException ThrowPPException(quiet())
32 MagickPPExport const char *Magick::borderGeometryDefault="6x6+0+0";
33 MagickPPExport const char *Magick::frameGeometryDefault="25x25+6+6";
34 MagickPPExport const char *Magick::raiseGeometryDefault="6x6+0+0";
36 MagickPPExport int Magick::operator == (const Magick::Image &left_,
37 const Magick::Image &right_)
39 // If image pixels and signature are the same, then the image is identical
40 return((left_.rows() == right_.rows()) &&
41 (left_.columns() == right_.columns()) &&
42 (left_.signature() == right_.signature()));
45 MagickPPExport int Magick::operator != (const Magick::Image &left_,
46 const Magick::Image &right_)
48 return(!(left_ == right_));
51 MagickPPExport int Magick::operator > (const Magick::Image &left_,
52 const Magick::Image &right_)
54 return(!(left_ < right_) && (left_ != right_));
57 MagickPPExport int Magick::operator < (const Magick::Image &left_,
58 const Magick::Image &right_)
60 // If image pixels are less, then image is smaller
61 return((left_.rows() * left_.columns()) <
62 (right_.rows() * right_.columns()));
65 MagickPPExport int Magick::operator >= (const Magick::Image &left_,
66 const Magick::Image &right_)
68 return((left_ > right_) || (left_ == right_));
71 MagickPPExport int Magick::operator <= (const Magick::Image &left_,
72 const Magick::Image &right_)
74 return((left_ < right_) || ( left_ == right_));
77 Magick::Image::Image(void)
78 : _imgRef(new ImageRef)
82 Magick::Image::Image(const Blob &blob_)
83 : _imgRef(new ImageRef)
87 // Initialize, Allocate and Read images
100 Magick::Image::Image(const Blob &blob_,const Geometry &size_)
101 : _imgRef(new ImageRef)
118 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
120 : _imgRef(new ImageRef)
126 read(blob_,size_,depth_);
137 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
138 const size_t depth_,const std::string &magick_)
139 : _imgRef(new ImageRef)
145 read(blob_,size_,depth_,magick_);
156 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
157 const std::string &magick_)
158 : _imgRef(new ImageRef)
164 read(blob_,size_,magick_);
175 Magick::Image::Image(const Geometry &size_,const Color &color_)
176 : _imgRef(new ImageRef)
178 // xc: prefix specifies an X11 color string
179 std::string imageSpec("xc:");
188 // Initialize, Allocate and Read images
200 Magick::Image::Image(const Image &image_)
201 : _imgRef(image_._imgRef)
206 Magick::Image::Image(const size_t width_,const size_t height_,
207 const std::string &map_,const StorageType type_,const void *pixels_)
208 : _imgRef(new ImageRef)
213 read(width_,height_,map_.c_str(),type_,pixels_);
224 Magick::Image::Image(const std::string &imageSpec_)
225 : _imgRef(new ImageRef)
229 // Initialize, Allocate and Read images
242 Magick::Image::~Image()
244 if (_imgRef->decrease() == 0)
247 _imgRef=(Magick::ImageRef *) NULL;
250 Magick::Image& Magick::Image::operator=(const Magick::Image &image_)
254 image_._imgRef->increase();
255 if (_imgRef->decrease() == 0)
258 // Use new image reference
259 _imgRef=image_._imgRef;
264 void Magick::Image::adjoin(const bool flag_)
267 options()->adjoin(flag_);
270 bool Magick::Image::adjoin(void) const
272 return(constOptions()->adjoin());
275 void Magick::Image::alpha(const bool matteFlag_)
279 // If matte channel is requested, but image doesn't already have a
280 // matte channel, then create an opaque matte channel. Likewise, if
281 // the image already has a matte channel but a matte channel is not
282 // desired, then set the matte channel to opaque.
284 if ((matteFlag_ && !constImage()->alpha_trait) ||
285 (constImage()->alpha_trait && !matteFlag_))
286 SetImageAlpha(image(),OpaqueAlpha,exceptionInfo);
289 image()->alpha_trait=matteFlag_ ? BlendPixelTrait : UndefinedPixelTrait;
292 bool Magick::Image::alpha(void) const
294 if (constImage()->alpha_trait == BlendPixelTrait)
300 void Magick::Image::alphaColor(const Color &alphaColor_)
304 if (alphaColor_.isValid())
306 image()->matte_color=alphaColor_;
307 options()->matteColor(alphaColor_);
311 // Set to default matte color
312 Color tmpColor("#BDBDBD");
313 image()->matte_color=tmpColor;
314 options()->matteColor(tmpColor);
318 Magick::Color Magick::Image::alphaColor(void) const
320 return(Color(constImage()->matte_color));
323 void Magick::Image::antiAlias(const bool flag_)
326 options()->antiAlias(flag_);
329 bool Magick::Image::antiAlias(void) const
331 return(constOptions()->antiAlias());
334 void Magick::Image::animationDelay(const size_t delay_)
337 image()->delay=delay_;
340 size_t Magick::Image::animationDelay(void) const
342 return(constImage()->delay);
345 void Magick::Image::animationIterations(const size_t iterations_)
348 image()->iterations=iterations_;
351 size_t Magick::Image::animationIterations(void) const
353 return(constImage()->iterations);
356 void Magick::Image::attenuate(const double attenuate_)
359 value[MagickPathExtent];
362 FormatLocaleString(value,MagickPathExtent,"%.20g",attenuate_);
363 (void) SetImageArtifact(image(),"attenuate",value);
366 void Magick::Image::backgroundColor(const Color &backgroundColor_)
370 if (backgroundColor_.isValid())
371 image()->background_color=backgroundColor_;
373 image()->background_color=Color();
375 options()->backgroundColor(backgroundColor_);
378 Magick::Color Magick::Image::backgroundColor(void) const
380 return(constOptions()->backgroundColor());
383 void Magick::Image::backgroundTexture(const std::string &backgroundTexture_)
386 options()->backgroundTexture(backgroundTexture_);
389 std::string Magick::Image::backgroundTexture(void) const
391 return(constOptions()->backgroundTexture());
394 size_t Magick::Image::baseColumns(void) const
396 return(constImage()->magick_columns);
399 std::string Magick::Image::baseFilename(void) const
401 return(std::string(constImage()->magick_filename));
404 size_t Magick::Image::baseRows(void) const
406 return(constImage()->magick_rows);
409 void Magick::Image::blackPointCompensation(const bool flag_)
411 image()->black_point_compensation=(MagickBooleanType) flag_;
414 bool Magick::Image::blackPointCompensation(void) const
416 return(static_cast<bool>(constImage()->black_point_compensation));
419 void Magick::Image::borderColor(const Color &borderColor_)
423 if (borderColor_.isValid())
424 image()->border_color=borderColor_;
426 image()->border_color=Color();
428 options()->borderColor(borderColor_);
431 Magick::Color Magick::Image::borderColor(void) const
433 return(constOptions()->borderColor());
436 Magick::Geometry Magick::Image::boundingBox(void) const
442 bbox=GetImageBoundingBox(constImage(),exceptionInfo);
444 return(Geometry(bbox));
447 void Magick::Image::boxColor(const Color &boxColor_)
450 options()->boxColor(boxColor_);
453 Magick::Color Magick::Image::boxColor(void) const
455 return(constOptions()->boxColor());
458 void Magick::Image::channelDepth(const ChannelType channel_,
463 GetAndSetPPChannelMask(channel_);
464 SetImageDepth(image(),depth_,exceptionInfo);
465 RestorePPChannelMask;
469 size_t Magick::Image::channelDepth(const ChannelType channel_)
475 GetAndSetPPChannelMask(channel_);
476 channel_depth=GetImageDepth(constImage(),exceptionInfo);
477 RestorePPChannelMask;
479 return(channel_depth);
482 size_t Magick::Image::channels() const
484 return(constImage()->number_channels);
487 void Magick::Image::classType(const ClassType class_)
489 if (classType() == PseudoClass && class_ == DirectClass)
491 // Use SyncImage to synchronize the DirectClass pixels with the
492 // color map and then set to DirectClass type.
495 SyncImage(image(),exceptionInfo);
497 image()->colormap=(PixelInfo *)RelinquishMagickMemory(image()->colormap);
498 image()->storage_class=static_cast<MagickCore::ClassType>(DirectClass);
502 if (classType() == DirectClass && class_ == PseudoClass)
504 // Quantize to create PseudoClass color map
506 quantizeColors(MaxColormapSize);
508 image()->storage_class=static_cast<MagickCore::ClassType>(PseudoClass);
512 Magick::ClassType Magick::Image::classType(void) const
514 return static_cast<Magick::ClassType>(constImage()->storage_class);
517 void Magick::Image::colorFuzz(const double fuzz_)
521 options()->colorFuzz(fuzz_);
524 double Magick::Image::colorFuzz(void) const
526 return(constOptions()->colorFuzz());
529 void Magick::Image::colorMapSize(const size_t entries_)
531 if (entries_ >MaxColormapSize)
532 throwExceptionExplicit(MagickCore::OptionError,
533 "Colormap entries must not exceed MaxColormapSize");
537 (void) AcquireImageColormap(image(),entries_,exceptionInfo);
541 size_t Magick::Image::colorMapSize(void) const
543 if (!constImage()->colormap)
544 throwExceptionExplicit(MagickCore::OptionError,
545 "Image does not contain a colormap");
547 return(constImage()->colors);
550 void Magick::Image::colorSpace(const ColorspaceType colorSpace_)
552 if (image()->colorspace == colorSpace_)
557 TransformImageColorspace(image(),colorSpace_,exceptionInfo);
561 Magick::ColorspaceType Magick::Image::colorSpace(void) const
563 return (constImage()->colorspace);
566 void Magick::Image::colorSpaceType(const ColorspaceType colorSpace_)
570 SetImageColorspace(image(),colorSpace_,exceptionInfo);
572 options()->colorspaceType(colorSpace_);
575 Magick::ColorspaceType Magick::Image::colorSpaceType(void) const
577 return(constOptions()->colorspaceType());
580 size_t Magick::Image::columns(void) const
582 return(constImage()->columns);
585 void Magick::Image::comment(const std::string &comment_)
589 SetImageProperty(image(),"Comment",NULL,exceptionInfo);
590 if (comment_.length() > 0)
591 SetImageProperty(image(),"Comment",comment_.c_str(),exceptionInfo);
595 std::string Magick::Image::comment(void) const
601 value=GetImageProperty(constImage(),"Comment",exceptionInfo);
605 return(std::string(value));
607 return(std::string()); // Intentionally no exception
610 void Magick::Image::compose(const CompositeOperator compose_)
612 image()->compose=compose_;
615 Magick::CompositeOperator Magick::Image::compose(void) const
617 return(constImage()->compose);
620 void Magick::Image::compressType(const CompressionType compressType_)
623 image()->compression=compressType_;
624 options()->compressType(compressType_);
627 Magick::CompressionType Magick::Image::compressType(void) const
629 return(constImage()->compression);
632 void Magick::Image::debug(const bool flag_)
635 options()->debug(flag_);
638 bool Magick::Image::debug(void) const
640 return(constOptions()->debug());
643 void Magick::Image::density(const Point &density_)
646 options()->density(density_);
647 if (density_.isValid())
649 image()->resolution.x=density_.x();
650 if (density_.y() != 0.0)
651 image()->resolution.y=density_.y();
653 image()->resolution.y=density_.x();
658 image()->resolution.x=0.0;
659 image()->resolution.y=0.0;
663 Magick::Point Magick::Image::density(void) const
671 if (constImage()->resolution.x > 0.0)
672 x_resolution=constImage()->resolution.x;
674 if (constImage()->resolution.y > 0.0)
675 y_resolution=constImage()->resolution.y;
677 return(Point(x_resolution,y_resolution));
680 return(constOptions()->density());
683 void Magick::Image::depth(const size_t depth_)
688 if (depth > MAGICKCORE_QUANTUM_DEPTH)
689 depth=MAGICKCORE_QUANTUM_DEPTH;
692 image()->depth=depth;
693 options()->depth(depth);
696 size_t Magick::Image::depth(void) const
698 return(constImage()->depth);
701 std::string Magick::Image::directory(void) const
703 if (constImage()->directory)
704 return(std::string(constImage()->directory));
707 throwExceptionExplicit(MagickCore::CorruptImageWarning,
708 "Image does not contain a directory");
710 return(std::string());
713 void Magick::Image::endian(const Magick::EndianType endian_)
716 options()->endian(endian_);
717 image()->endian=endian_;
720 Magick::EndianType Magick::Image::endian(void) const
722 return(constImage()->endian);
725 void Magick::Image::exifProfile(const Magick::Blob &exifProfile_)
729 if (exifProfile_.data() != 0)
734 exif_profile=AcquireStringInfo(exifProfile_.length());
735 SetStringInfoDatum(exif_profile,(unsigned char *) exifProfile_.data());
737 (void) SetImageProfile(image(),"exif",exif_profile,exceptionInfo);
738 exif_profile=DestroyStringInfo(exif_profile);
743 Magick::Blob Magick::Image::exifProfile(void) const
748 exif_profile=GetImageProfile(constImage(),"exif");
749 if (exif_profile == (StringInfo *) NULL)
751 return(Blob(GetStringInfoDatum(exif_profile),
752 GetStringInfoLength(exif_profile)));
755 void Magick::Image::fileName(const std::string &fileName_)
759 fileName_.copy(image()->filename,sizeof(image()->filename)-1);
760 image()->filename[fileName_.length()]=0; // Null terminate
762 options()->fileName(fileName_);
765 std::string Magick::Image::fileName(void) const
767 return(constOptions()->fileName());
770 MagickCore::MagickSizeType Magick::Image::fileSize(void) const
772 return(GetBlobSize(constImage()));
775 void Magick::Image::fillColor(const Magick::Color &fillColor_)
781 options()->fillColor(fillColor_);
783 artifact("fill",value);
786 Magick::Color Magick::Image::fillColor(void) const
788 return(constOptions()->fillColor());
791 void Magick::Image::fillRule(const Magick::FillRule &fillRule_)
794 options()->fillRule(fillRule_);
797 Magick::FillRule Magick::Image::fillRule(void) const
799 return constOptions()->fillRule();
802 void Magick::Image::fillPattern(const Image &fillPattern_)
805 if (fillPattern_.isValid())
806 options()->fillPattern(fillPattern_.constImage());
808 options()->fillPattern(static_cast<MagickCore::Image*>(NULL));
811 Magick::Image Magick::Image::fillPattern(void) const
813 // FIXME: This is inordinately innefficient
814 const MagickCore::Image
820 tmpTexture=constOptions()->fillPattern();
828 image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
829 texture.replaceImage(image);
835 void Magick::Image::filterType(const Magick::FilterTypes filterType_)
838 image()->filter=filterType_;
841 Magick::FilterTypes Magick::Image::filterType(void) const
843 return(constImage()->filter);
846 void Magick::Image::font(const std::string &font_)
849 options()->font(font_);
852 std::string Magick::Image::font(void) const
854 return(constOptions()->font());
857 void Magick::Image::fontPointsize(const double pointSize_)
860 options()->fontPointsize(pointSize_);
863 double Magick::Image::fontPointsize(void) const
865 return(constOptions()->fontPointsize());
868 std::string Magick::Image::format(void) const
874 magick_info=GetMagickInfo(constImage()->magick,exceptionInfo);
877 if ((magick_info != 0) && (*magick_info->description != '\0'))
878 return(std::string(magick_info->description));
881 throwExceptionExplicit(MagickCore::CorruptImageWarning,
882 "Unrecognized image magick type");
884 return(std::string());
887 std::string Magick::Image::formatExpression(const std::string expression)
897 text=InterpretImageProperties(imageInfo(),image(),expression.c_str(),
899 if (text != (char *) NULL)
901 text_string=std::string(text);
902 text=DestroyString(text);
908 double Magick::Image::gamma(void) const
910 return(constImage()->gamma);
913 Magick::Geometry Magick::Image::geometry(void) const
915 if (constImage()->geometry)
916 return Geometry(constImage()->geometry);
919 throwExceptionExplicit(MagickCore::OptionWarning,
920 "Image does not contain a geometry");
925 void Magick::Image::gifDisposeMethod(
926 const MagickCore::DisposeType disposeMethod_)
929 image()->dispose=disposeMethod_;
932 MagickCore::DisposeType Magick::Image::gifDisposeMethod(void) const
934 return(constImage()->dispose);
937 bool Magick::Image::hasChannel(const PixelChannel channel) const
939 if (GetPixelChannelTraits(constImage(),channel) == UndefinedPixelTrait)
942 if (channel == GreenPixelChannel || channel == BluePixelChannel)
943 return (GetPixelChannelOffset(constImage(),channel) == (ssize_t)channel);
948 void Magick::Image::highlightColor(const Color color_)
954 artifact("highlight-color",value);
957 void Magick::Image::iccColorProfile(const Magick::Blob &colorProfile_)
959 profile("icc",colorProfile_);
962 Magick::Blob Magick::Image::iccColorProfile(void) const
967 color_profile=GetImageProfile(constImage(),"icc");
968 if (color_profile == (StringInfo *) NULL)
970 return(Blob(GetStringInfoDatum(color_profile),GetStringInfoLength(
974 void Magick::Image::interlaceType(const Magick::InterlaceType interlace_)
977 image()->interlace=interlace_;
978 options()->interlaceType(interlace_);
981 Magick::InterlaceType Magick::Image::interlaceType(void) const
983 return(constImage()->interlace);
986 void Magick::Image::interpolate(const PixelInterpolateMethod interpolate_)
989 image()->interpolate=interpolate_;
992 Magick::PixelInterpolateMethod Magick::Image::interpolate(void) const
994 return constImage()->interpolate;
997 void Magick::Image::iptcProfile(const Magick::Blob &iptcProfile_)
1000 if (iptcProfile_.data() != 0)
1005 iptc_profile=AcquireStringInfo(iptcProfile_.length());
1006 SetStringInfoDatum(iptc_profile,(unsigned char *) iptcProfile_.data());
1008 (void) SetImageProfile(image(),"iptc",iptc_profile,exceptionInfo);
1009 iptc_profile=DestroyStringInfo(iptc_profile);
1010 ThrowImageException;
1014 Magick::Blob Magick::Image::iptcProfile(void) const
1019 iptc_profile=GetImageProfile(constImage(),"iptc");
1020 if (iptc_profile == (StringInfo *) NULL)
1022 return(Blob(GetStringInfoDatum(iptc_profile),GetStringInfoLength(
1026 bool Magick::Image::isOpaque(void) const
1032 result=IsImageOpaque(constImage(),exceptionInfo);
1033 ThrowImageException;
1034 return(result != MagickFalse ? true : false);
1037 void Magick::Image::isValid(const bool isValid_)
1042 _imgRef=new ImageRef;
1044 else if (!isValid())
1046 // Construct with single-pixel black image to make
1047 // image valid. This is an obvious hack.
1048 size(Geometry(1,1));
1053 bool Magick::Image::isValid(void) const
1055 return rows() && columns();
1058 void Magick::Image::label(const std::string &label_)
1062 (void) SetImageProperty(image(),"Label",NULL,exceptionInfo);
1063 if (label_.length() > 0)
1064 (void) SetImageProperty(image(),"Label",label_.c_str(),exceptionInfo);
1065 ThrowImageException;
1068 std::string Magick::Image::label(void) const
1074 value=GetImageProperty(constImage(),"Label",exceptionInfo);
1075 ThrowImageException;
1078 return(std::string(value));
1080 return(std::string());
1083 void Magick::Image::lowlightColor(const Color color_)
1089 artifact("lowlight-color",value);
1092 void Magick::Image::mask(const Magick::Image &mask_)
1097 if (mask_.isValid())
1098 SetImageMask(image(),mask_.constImage(),exceptionInfo);
1100 SetImageMask(image(),(MagickCore::Image *) NULL,exceptionInfo);
1101 ThrowImageException;
1104 Magick::Image Magick::Image::mask(void) const
1110 image=GetImageMask(constImage(),exceptionInfo);
1111 ThrowImageException;
1113 if (image == (MagickCore::Image *) NULL)
1114 return(Magick::Image());
1116 return(Magick::Image(image));
1119 void Magick::Image::magick(const std::string &magick_)
1126 length=sizeof(image()->magick)-1;
1127 if (magick_.length() < length)
1128 length=magick_.length();
1130 if (!magick_.empty())
1131 magick_.copy(image()->magick,length);
1132 image()->magick[length]=0;
1134 options()->magick(magick_);
1137 std::string Magick::Image::magick(void) const
1139 if (*(constImage()->magick) != '\0')
1140 return(std::string(constImage()->magick));
1142 return(constOptions()->magick());
1145 double Magick::Image::meanErrorPerPixel(void) const
1147 return(constImage()->error.mean_error_per_pixel);
1150 void Magick::Image::modulusDepth(const size_t depth_)
1154 SetImageDepth(image(),depth_,exceptionInfo);
1155 ThrowImageException;
1156 options()->depth(depth_);
1159 size_t Magick::Image::modulusDepth(void) const
1165 depth=GetImageDepth(constImage(),exceptionInfo);
1166 ThrowImageException;
1170 void Magick::Image::monochrome(const bool monochromeFlag_)
1173 options()->monochrome(monochromeFlag_);
1176 bool Magick::Image::monochrome(void) const
1178 return(constOptions()->monochrome());
1181 Magick::Geometry Magick::Image::montageGeometry(void) const
1183 if (constImage()->montage)
1184 return Magick::Geometry(constImage()->montage);
1187 throwExceptionExplicit(MagickCore::CorruptImageWarning,
1188 "Image does not contain a montage");
1190 return(Magick::Geometry());
1193 double Magick::Image::normalizedMaxError(void) const
1195 return(constImage()->error.normalized_maximum_error);
1198 double Magick::Image::normalizedMeanError(void) const
1200 return(constImage()->error.normalized_mean_error);
1203 void Magick::Image::orientation(const Magick::OrientationType orientation_)
1206 image()->orientation=orientation_;
1209 Magick::OrientationType Magick::Image::orientation(void) const
1211 return(constImage()->orientation);
1214 void Magick::Image::page(const Magick::Geometry &pageSize_)
1217 options()->page(pageSize_);
1218 image()->page=pageSize_;
1221 Magick::Geometry Magick::Image::page(void) const
1223 return(Geometry(constImage()->page.width,constImage()->page.height,
1224 constImage()->page.x,constImage()->page.y));
1227 void Magick::Image::quality(const size_t quality_)
1230 image()->quality=quality_;
1231 options()->quality(quality_);
1234 size_t Magick::Image::quality(void) const
1236 return(constImage()->quality);
1239 void Magick::Image::quantizeColors(const size_t colors_)
1242 options()->quantizeColors(colors_);
1245 size_t Magick::Image::quantizeColors(void) const
1247 return(constOptions()->quantizeColors());
1250 void Magick::Image::quantizeColorSpace(
1251 const Magick::ColorspaceType colorSpace_)
1254 options()->quantizeColorSpace(colorSpace_);
1257 Magick::ColorspaceType Magick::Image::quantizeColorSpace(void) const
1259 return(constOptions()->quantizeColorSpace());
1262 void Magick::Image::quantizeDither(const bool ditherFlag_)
1265 options()->quantizeDither(ditherFlag_);
1268 bool Magick::Image::quantizeDither(void) const
1270 return(constOptions()->quantizeDither());
1273 void Magick::Image::quantizeDitherMethod(const DitherMethod ditherMethod_)
1276 options()->quantizeDitherMethod(ditherMethod_);
1279 MagickCore::DitherMethod Magick::Image::quantizeDitherMethod(void) const
1281 return(constOptions()->quantizeDitherMethod());
1284 void Magick::Image::quantizeTreeDepth(const size_t treeDepth_)
1287 options()->quantizeTreeDepth(treeDepth_);
1290 size_t Magick::Image::quantizeTreeDepth() const
1292 return(constOptions()->quantizeTreeDepth());
1295 void Magick::Image::quiet(const bool quiet_)
1298 options()->quiet(quiet_);
1301 bool Magick::Image::quiet(void) const
1303 return(constOptions()->quiet());
1306 void Magick::Image::renderingIntent(
1307 const Magick::RenderingIntent renderingIntent_)
1310 image()->rendering_intent=renderingIntent_;
1313 Magick::RenderingIntent Magick::Image::renderingIntent(void) const
1315 return(static_cast<Magick::RenderingIntent>(constImage()->rendering_intent));
1318 void Magick::Image::resolutionUnits(
1319 const Magick::ResolutionType resolutionUnits_)
1322 image()->units=resolutionUnits_;
1323 options()->resolutionUnits(resolutionUnits_);
1326 Magick::ResolutionType Magick::Image::resolutionUnits(void) const
1328 return(static_cast<Magick::ResolutionType>(constImage()->units));
1331 size_t Magick::Image::rows(void) const
1333 return(constImage()->rows);
1336 void Magick::Image::scene(const size_t scene_)
1339 image()->scene=scene_;
1342 size_t Magick::Image::scene(void) const
1344 return(constImage()->scene);
1347 void Magick::Image::size(const Geometry &geometry_)
1350 options()->size(geometry_);
1351 image()->rows=geometry_.height();
1352 image()->columns=geometry_.width();
1355 Magick::Geometry Magick::Image::size(void) const
1357 return(Magick::Geometry(constImage()->columns,constImage()->rows));
1360 void Magick::Image::strokeAntiAlias(const bool flag_)
1363 options()->strokeAntiAlias(flag_);
1366 bool Magick::Image::strokeAntiAlias(void) const
1368 return(constOptions()->strokeAntiAlias());
1371 void Magick::Image::strokeColor(const Magick::Color &strokeColor_)
1377 options()->strokeColor(strokeColor_);
1379 artifact("stroke",value);
1382 Magick::Color Magick::Image::strokeColor(void) const
1384 return(constOptions()->strokeColor());
1387 void Magick::Image::strokeDashArray(const double *strokeDashArray_)
1390 options()->strokeDashArray(strokeDashArray_);
1393 const double* Magick::Image::strokeDashArray(void) const
1395 return(constOptions()->strokeDashArray());
1398 void Magick::Image::strokeDashOffset(const double strokeDashOffset_)
1401 options()->strokeDashOffset(strokeDashOffset_);
1404 double Magick::Image::strokeDashOffset(void) const
1406 return(constOptions()->strokeDashOffset());
1409 void Magick::Image::strokeLineCap(const Magick::LineCap lineCap_)
1412 options()->strokeLineCap(lineCap_);
1415 Magick::LineCap Magick::Image::strokeLineCap(void) const
1417 return(constOptions()->strokeLineCap());
1420 void Magick::Image::strokeLineJoin(const Magick::LineJoin lineJoin_)
1423 options()->strokeLineJoin(lineJoin_);
1426 Magick::LineJoin Magick::Image::strokeLineJoin(void) const
1428 return(constOptions()->strokeLineJoin());
1431 void Magick::Image::strokeMiterLimit(const size_t strokeMiterLimit_)
1434 options()->strokeMiterLimit(strokeMiterLimit_);
1437 size_t Magick::Image::strokeMiterLimit(void) const
1439 return(constOptions()->strokeMiterLimit());
1442 void Magick::Image::strokePattern(const Image &strokePattern_)
1445 if(strokePattern_.isValid())
1446 options()->strokePattern(strokePattern_.constImage());
1448 options()->strokePattern(static_cast<MagickCore::Image*>(NULL));
1451 Magick::Image Magick::Image::strokePattern(void) const
1453 // FIXME: This is inordinately innefficient
1454 const MagickCore::Image
1460 tmpTexture=constOptions()->strokePattern();
1468 image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
1469 texture.replaceImage(image);
1470 ThrowImageException;
1475 void Magick::Image::strokeWidth(const double strokeWidth_)
1478 value[MagickPathExtent];
1481 options()->strokeWidth(strokeWidth_);
1482 FormatLocaleString(value,MagickPathExtent,"%.20g",strokeWidth_);
1483 (void) SetImageArtifact(image(),"strokewidth",value);
1486 double Magick::Image::strokeWidth(void) const
1488 return(constOptions()->strokeWidth());
1491 void Magick::Image::subImage(const size_t subImage_)
1494 options()->subImage(subImage_);
1497 size_t Magick::Image::subImage(void) const
1499 return(constOptions()->subImage());
1502 void Magick::Image::subRange(const size_t subRange_)
1505 options()->subRange(subRange_);
1508 size_t Magick::Image::subRange(void) const
1510 return(constOptions()->subRange());
1513 void Magick::Image::textDirection(DirectionType direction_)
1516 options()->textDirection(direction_);
1519 Magick::DirectionType Magick::Image::textDirection(void) const
1521 return(constOptions()->textDirection());
1524 void Magick::Image::textEncoding(const std::string &encoding_)
1527 options()->textEncoding(encoding_);
1530 std::string Magick::Image::textEncoding(void) const
1532 return(constOptions()->textEncoding());
1535 void Magick::Image::textGravity(GravityType gravity_)
1538 options()->textGravity(gravity_);
1541 Magick::GravityType Magick::Image::textGravity(void) const
1543 return(constOptions()->textGravity());
1546 void Magick::Image::textInterlineSpacing(double spacing_)
1549 options()->textInterlineSpacing(spacing_);
1552 double Magick::Image::textInterlineSpacing(void) const
1554 return(constOptions()->textInterlineSpacing());
1557 void Magick::Image::textInterwordSpacing(double spacing_)
1560 options()->textInterwordSpacing(spacing_);
1563 double Magick::Image::textInterwordSpacing(void) const
1565 return(constOptions()->textInterwordSpacing());
1568 void Magick::Image::textKerning(double kerning_)
1571 options()->textKerning(kerning_);
1574 double Magick::Image::textKerning(void) const
1576 return(constOptions()->textKerning());
1579 size_t Magick::Image::totalColors(void) const
1585 colors=GetNumberColors(constImage(),(FILE *) NULL,exceptionInfo);
1586 ThrowImageException;
1590 void Magick::Image::transformRotation(const double angle_)
1593 options()->transformRotation(angle_);
1596 void Magick::Image::transformSkewX(const double skewx_)
1599 options()->transformSkewX(skewx_);
1602 void Magick::Image::transformSkewY(const double skewy_)
1605 options()->transformSkewY(skewy_);
1608 Magick::ImageType Magick::Image::type(void) const
1610 if (constOptions()->type() != UndefinedType)
1611 return(constOptions()->type());
1612 else if (constImage()->type != UndefinedType)
1613 return(constImage()->type);
1615 return(determineType());
1618 void Magick::Image::type(const Magick::ImageType type_)
1621 options()->type(type_);
1623 SetImageType(image(),type_,exceptionInfo);
1624 ThrowImageException;
1627 void Magick::Image::verbose(const bool verboseFlag_)
1630 options()->verbose(verboseFlag_);
1633 bool Magick::Image::verbose(void) const
1635 return(constOptions()->verbose());
1638 void Magick::Image::view(const std::string &view_)
1641 options()->view(view_);
1644 std::string Magick::Image::view(void) const
1646 return(constOptions()->view());
1649 void Magick::Image::virtualPixelMethod(
1650 const VirtualPixelMethod virtualPixelMethod_)
1654 SetImageVirtualPixelMethod(image(),virtualPixelMethod_,exceptionInfo);
1655 ThrowImageException;
1658 Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod(void) const
1660 return(GetImageVirtualPixelMethod(constImage()));
1663 void Magick::Image::x11Display(const std::string &display_)
1666 options()->x11Display(display_);
1669 std::string Magick::Image::x11Display(void) const
1671 return(constOptions()->x11Display());
1674 double Magick::Image::xResolution(void) const
1676 return(constImage()->resolution.x);
1679 double Magick::Image::yResolution(void) const
1681 return(constImage()->resolution.y);
1684 void Magick::Image::adaptiveBlur(const double radius_,const double sigma_)
1690 newImage=AdaptiveBlurImage(constImage(),radius_,sigma_,exceptionInfo);
1691 replaceImage(newImage);
1692 ThrowImageException;
1695 void Magick::Image::adaptiveResize(const Geometry &geometry_)
1708 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
1712 newImage=AdaptiveResizeImage(constImage(),width,height,exceptionInfo);
1713 replaceImage(newImage);
1714 ThrowImageException;
1717 void Magick::Image::adaptiveSharpen(const double radius_,const double sigma_)
1723 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1724 replaceImage(newImage);
1725 ThrowImageException;
1728 void Magick::Image::adaptiveSharpenChannel(const ChannelType channel_,
1729 const double radius_,const double sigma_ )
1735 GetAndSetPPChannelMask(channel_);
1736 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1737 RestorePPChannelMask;
1738 replaceImage(newImage);
1739 ThrowImageException;
1742 void Magick::Image::adaptiveThreshold(const size_t width_,const size_t height_,
1750 newImage=AdaptiveThresholdImage(constImage(),width_,height_,bias_,
1752 replaceImage(newImage);
1753 ThrowImageException;
1756 void Magick::Image::addNoise(const NoiseType noiseType_)
1762 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1763 replaceImage(newImage);
1764 ThrowImageException;
1767 void Magick::Image::addNoiseChannel(const ChannelType channel_,
1768 const NoiseType noiseType_)
1774 GetAndSetPPChannelMask(channel_);
1775 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1776 RestorePPChannelMask;
1777 replaceImage(newImage);
1778 ThrowImageException;
1781 void Magick::Image::affineTransform(const DrawableAffine &affine_)
1789 _affine.sx=affine_.sx();
1790 _affine.sy=affine_.sy();
1791 _affine.rx=affine_.rx();
1792 _affine.ry=affine_.ry();
1793 _affine.tx=affine_.tx();
1794 _affine.ty=affine_.ty();
1797 newImage=AffineTransformImage(constImage(),&_affine,exceptionInfo);
1798 replaceImage(newImage);
1799 ThrowImageException;
1802 void Magick::Image::alpha(const unsigned int alpha_)
1806 SetImageAlpha(image(),alpha_,exceptionInfo);
1807 ThrowImageException;
1810 void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
1814 SetImageAlphaChannel(image(),alphaOption_,exceptionInfo);
1815 ThrowImageException;
1818 void Magick::Image::annotate(const std::string &text_,
1819 const Geometry &location_)
1821 annotate(text_,location_,NorthWestGravity,0.0);
1824 void Magick::Image::annotate(const std::string &text_,
1825 const Geometry &boundingArea_,const GravityType gravity_)
1827 annotate(text_,boundingArea_,gravity_,0.0);
1830 void Magick::Image::annotate(const std::string &text_,
1831 const Geometry &boundingArea_,const GravityType gravity_,
1832 const double degrees_)
1838 boundingArea[MagickPathExtent];
1845 drawInfo=options()->drawInfo();
1846 drawInfo->text=const_cast<char *>(text_.c_str());
1847 drawInfo->geometry=0;
1849 if (boundingArea_.isValid())
1851 if (boundingArea_.width() == 0 || boundingArea_.height() == 0)
1853 FormatLocaleString(boundingArea,MagickPathExtent,"%+.20g%+.20g",
1854 (double) boundingArea_.xOff(),(double) boundingArea_.yOff());
1858 (void) CopyMagickString(boundingArea,
1859 std::string(boundingArea_).c_str(), MagickPathExtent);
1861 drawInfo->geometry=boundingArea;
1864 drawInfo->gravity=gravity_;
1866 oaffine=drawInfo->affine;
1867 if (degrees_ != 0.0)
1880 current=drawInfo->affine;
1881 affine.sx=cos(DegreesToRadians(fmod(degrees_,360.0)));
1882 affine.rx=sin(DegreesToRadians(fmod(degrees_,360.0)));
1883 affine.ry=(-sin(DegreesToRadians(fmod(degrees_,360.0))));
1884 affine.sy=cos(DegreesToRadians(fmod(degrees_,360.0)));
1886 drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
1887 drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
1888 drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
1889 drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
1890 drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty
1895 AnnotateImage(image(),drawInfo,exceptionInfo);
1897 // Restore original values
1898 drawInfo->affine=oaffine;
1900 drawInfo->geometry=0;
1902 ThrowImageException;
1905 void Magick::Image::annotate(const std::string &text_,
1906 const GravityType gravity_)
1913 drawInfo=options()->drawInfo();
1914 drawInfo->text=const_cast<char *>(text_.c_str());
1915 drawInfo->gravity=gravity_;
1918 AnnotateImage(image(),drawInfo,exceptionInfo);
1920 drawInfo->gravity=NorthWestGravity;
1923 ThrowImageException;
1926 void Magick::Image::artifact(const std::string &name_,const std::string &value_)
1929 (void) SetImageArtifact(image(),name_.c_str(),value_.c_str());
1932 std::string Magick::Image::artifact(const std::string &name_) const
1937 value=GetImageArtifact(constImage(),name_.c_str());
1939 return(std::string(value));
1940 return(std::string());
1943 void Magick::Image::attribute(const std::string name_,const std::string value_)
1947 SetImageProperty(image(),name_.c_str(),value_.c_str(),exceptionInfo);
1948 ThrowImageException;
1951 std::string Magick::Image::attribute(const std::string name_) const
1957 value=GetImageProperty(constImage(),name_.c_str(),exceptionInfo);
1958 ThrowImageException;
1961 return(std::string(value));
1963 return(std::string()); // Intentionally no exception
1966 void Magick::Image::autoGamma(void)
1970 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1971 (void) AutoGammaImage(image(),exceptionInfo);
1972 ThrowImageException;
1975 void Magick::Image::autoGammaChannel(const ChannelType channel_)
1979 GetAndSetPPChannelMask(channel_);
1980 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1981 (void) AutoGammaImage(image(),exceptionInfo);
1982 RestorePPChannelMask;
1983 ThrowImageException;
1986 void Magick::Image::autoLevel(void)
1990 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1991 (void) AutoLevelImage(image(),exceptionInfo);
1992 ThrowImageException;
1995 void Magick::Image::autoLevelChannel(const ChannelType channel_)
1999 GetAndSetPPChannelMask(channel_);
2000 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2001 (void) AutoLevelImage(image(),exceptionInfo);
2002 RestorePPChannelMask;
2003 ThrowImageException;
2006 void Magick::Image::autoOrient(void)
2011 if (image()->orientation == UndefinedOrientation ||
2012 image()->orientation == TopLeftOrientation)
2016 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2017 newImage=AutoOrientImage(constImage(),image()->orientation,exceptionInfo);
2018 replaceImage(newImage);
2019 ThrowImageException;
2022 void Magick::Image::blackThreshold(const std::string &threshold_)
2026 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2027 ThrowImageException;
2030 void Magick::Image::blackThresholdChannel(const ChannelType channel_,
2031 const std::string &threshold_)
2035 GetAndSetPPChannelMask(channel_);
2036 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2037 RestorePPChannelMask;
2038 ThrowImageException;
2041 void Magick::Image::blueShift(const double factor_)
2047 newImage=BlueShiftImage(constImage(),factor_,exceptionInfo);
2048 replaceImage(newImage);
2049 ThrowImageException;
2052 void Magick::Image::blur(const double radius_,const double sigma_)
2058 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2059 replaceImage(newImage);
2060 ThrowImageException;
2063 void Magick::Image::blurChannel(const ChannelType channel_,
2064 const double radius_,const double sigma_)
2070 GetAndSetPPChannelMask(channel_);
2071 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2072 RestorePPChannelMask;
2073 replaceImage(newImage);
2074 ThrowImageException;
2077 void Magick::Image::border(const Geometry &geometry_)
2083 borderInfo=geometry_;
2086 newImage=BorderImage(constImage(),&borderInfo,image()->compose,
2088 replaceImage(newImage);
2089 ThrowImageException;
2092 void Magick::Image::brightnessContrast(const double brightness_,
2093 const double contrast_)
2097 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2098 ThrowImageException;
2101 void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
2102 const double brightness_,const double contrast_)
2106 GetAndSetPPChannelMask(channel_);
2107 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2108 RestorePPChannelMask;
2109 ThrowImageException;
2112 void Magick::Image::cannyEdge(const double radius_,const double sigma_,
2113 const double lowerPercent_,const double upperPercent_)
2120 newImage=CannyEdgeImage(constImage(),radius_,sigma_,lowerPercent_,
2121 upperPercent_,exceptionInfo);
2122 replaceImage(newImage);
2123 ThrowImageException;
2126 void Magick::Image::cdl(const std::string &cdl_)
2130 (void) ColorDecisionListImage(image(),cdl_.c_str(),exceptionInfo);
2131 ThrowImageException;
2134 void Magick::Image::channel(const ChannelType channel_)
2140 newImage=SeparateImage(image(),channel_,exceptionInfo);
2141 replaceImage(newImage);
2142 ThrowImageException;
2145 void Magick::Image::charcoal(const double radius_,const double sigma_)
2151 newImage=CharcoalImage(image(),radius_,sigma_,exceptionInfo);
2152 replaceImage(newImage);
2153 ThrowImageException;
2156 void Magick::Image::chop(const Geometry &geometry_)
2165 newImage=ChopImage(image(),&chopInfo,exceptionInfo);
2166 replaceImage(newImage);
2167 ThrowImageException;
2170 void Magick::Image::chromaBluePrimary(const double x_,const double y_)
2173 image()->chromaticity.blue_primary.x=x_;
2174 image()->chromaticity.blue_primary.y=y_;
2177 void Magick::Image::chromaBluePrimary(double *x_,double *y_) const
2179 *x_=constImage()->chromaticity.blue_primary.x;
2180 *y_=constImage()->chromaticity.blue_primary.y;
2183 void Magick::Image::chromaGreenPrimary(const double x_,const double y_)
2186 image()->chromaticity.green_primary.x=x_;
2187 image()->chromaticity.green_primary.y=y_;
2190 void Magick::Image::chromaGreenPrimary(double *x_,double *y_) const
2192 *x_=constImage()->chromaticity.green_primary.x;
2193 *y_=constImage()->chromaticity.green_primary.y;
2196 void Magick::Image::chromaRedPrimary(const double x_,const double y_)
2199 image()->chromaticity.red_primary.x=x_;
2200 image()->chromaticity.red_primary.y=y_;
2203 void Magick::Image::chromaRedPrimary(double *x_,double *y_) const
2205 *x_=constImage()->chromaticity.red_primary.x;
2206 *y_=constImage()->chromaticity.red_primary.y;
2209 void Magick::Image::chromaWhitePoint(const double x_,const double y_)
2212 image()->chromaticity.white_point.x=x_;
2213 image()->chromaticity.white_point.y=y_;
2216 void Magick::Image::chromaWhitePoint(double *x_,double *y_) const
2218 *x_=constImage()->chromaticity.white_point.x;
2219 *y_=constImage()->chromaticity.white_point.y;
2222 void Magick::Image::clamp(void)
2226 ClampImage(image(),exceptionInfo);
2227 ThrowImageException;
2230 void Magick::Image::clampChannel(const ChannelType channel_)
2234 GetAndSetPPChannelMask(channel_);
2235 ClampImage(image(),exceptionInfo);
2236 RestorePPChannelMask;
2237 ThrowImageException;
2240 void Magick::Image::clip(void)
2244 ClipImage(image(),exceptionInfo);
2245 ThrowImageException;
2248 void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
2252 ClipImagePath(image(),pathname_.c_str(),(MagickBooleanType) inside_,
2254 ThrowImageException;
2257 void Magick::Image::clut(const Image &clutImage_,
2258 const PixelInterpolateMethod method)
2262 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2263 ThrowImageException;
2266 void Magick::Image::clutChannel(const ChannelType channel_,
2267 const Image &clutImage_,const PixelInterpolateMethod method)
2271 GetAndSetPPChannelMask(channel_);
2272 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2273 RestorePPChannelMask;
2274 ThrowImageException;
2277 void Magick::Image::colorize(const unsigned int alpha_,const Color &penColor_)
2279 colorize(alpha_,alpha_,alpha_,penColor_);
2282 void Magick::Image::colorize(const unsigned int alphaRed_,
2283 const unsigned int alphaGreen_,const unsigned int alphaBlue_,
2284 const Color &penColor_)
2287 blend[MagickPathExtent];
2295 if (!penColor_.isValid())
2296 throwExceptionExplicit(MagickCore::OptionError,
2297 "Pen color argument is invalid");
2299 FormatLocaleString(blend,MagickPathExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
2302 target=static_cast<PixelInfo>(penColor_);
2304 newImage=ColorizeImage(image(),blend,&target,exceptionInfo);
2305 replaceImage(newImage);
2306 ThrowImageException;
2309 void Magick::Image::colorMap(const size_t index_,const Color &color_)
2316 if (index_ > (MaxColormapSize-1))
2317 throwExceptionExplicit(MagickCore::OptionError,
2318 "Colormap index must be less than MaxColormapSize");
2320 if (!color_.isValid())
2321 throwExceptionExplicit(MagickCore::OptionError,
2322 "Color argument is invalid");
2326 // Ensure that colormap size is large enough
2327 if (colorMapSize() < (index_+1))
2328 colorMapSize(index_+1);
2330 // Set color at index in colormap
2331 (imageptr->colormap)[index_]=color_;
2334 Magick::Color Magick::Image::colorMap(const size_t index_) const
2336 if (!constImage()->colormap)
2338 throwExceptionExplicit(MagickCore::OptionError,
2339 "Image does not contain a colormap");
2343 if (index_ > constImage()->colors-1)
2344 throwExceptionExplicit(MagickCore::OptionError,"Index out of range");
2346 return(Magick::Color((constImage()->colormap)[index_]));
2349 void Magick::Image::colorMatrix(const size_t order_,
2350 const double *color_matrix_)
2356 kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2357 if (kernel_info != (KernelInfo *) NULL)
2359 kernel_info->width=order_;
2360 kernel_info->height=order_;
2361 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2362 order_*sizeof(*kernel_info->values));
2363 if (kernel_info->values != (MagickRealType *) NULL)
2368 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2369 kernel_info->values[i]=color_matrix_[i];
2370 newImage=ColorMatrixImage(image(),kernel_info,exceptionInfo);
2371 replaceImage(newImage);
2373 kernel_info=DestroyKernelInfo(kernel_info);
2375 ThrowImageException;
2378 bool Magick::Image::compare(const Image &reference_)
2388 status=static_cast<bool>(IsImagesEqual(image(),ref.constImage(),
2390 ThrowImageException;
2394 double Magick::Image::compare(const Image &reference_,const MetricType metric_)
2400 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2402 ThrowImageException;
2406 double Magick::Image::compareChannel(const ChannelType channel_,
2407 const Image &reference_,const MetricType metric_)
2413 GetAndSetPPChannelMask(channel_);
2414 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2416 RestorePPChannelMask;
2417 ThrowImageException;
2421 Magick::Image Magick::Image::compare(const Image &reference_,
2422 const MetricType metric_,double *distortion)
2428 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2430 ThrowImageException;
2431 if (newImage == (MagickCore::Image *) NULL)
2432 return(Magick::Image());
2434 return(Magick::Image(newImage));
2437 Magick::Image Magick::Image::compareChannel(const ChannelType channel_,
2438 const Image &reference_,const MetricType metric_,double *distortion)
2444 GetAndSetPPChannelMask(channel_);
2445 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2447 RestorePPChannelMask;
2448 ThrowImageException;
2449 if (newImage == (MagickCore::Image *) NULL)
2450 return(Magick::Image());
2452 return(Magick::Image(newImage));
2455 void Magick::Image::composite(const Image &compositeImage_,
2456 const Geometry &offset_,const CompositeOperator compose_)
2466 ParseMetaGeometry(static_cast<std::string>(offset_).c_str(),&x,&y,&width,
2471 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2473 ThrowImageException;
2476 void Magick::Image::composite(const Image &compositeImage_,
2477 const GravityType gravity_,const CompositeOperator compose_)
2483 SetGeometry(compositeImage_.constImage(),&geometry);
2484 GravityAdjustGeometry(columns(),rows(),gravity_,&geometry);
2487 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2488 geometry.x,geometry.y,exceptionInfo);
2489 ThrowImageException;
2492 void Magick::Image::composite(const Image &compositeImage_,
2493 const ssize_t xOffset_,const ssize_t yOffset_,
2494 const CompositeOperator compose_)
2496 // Image supplied as compositeImage is composited with current image and
2497 // results in updating current image.
2500 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2501 xOffset_,yOffset_,exceptionInfo);
2502 ThrowImageException;
2505 void Magick::Image::connectedComponents(const size_t connectivity_)
2511 newImage=ConnectedComponentsImage(constImage(),connectivity_,exceptionInfo);
2512 replaceImage(newImage);
2513 ThrowImageException;
2516 void Magick::Image::contrast(const bool sharpen_)
2520 ContrastImage(image(),(MagickBooleanType) sharpen_,exceptionInfo);
2521 ThrowImageException;
2524 void Magick::Image::contrastStretch(const double blackPoint_,
2525 const double whitePoint_)
2529 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2530 ThrowImageException;
2533 void Magick::Image::contrastStretchChannel(const ChannelType channel_,
2534 const double blackPoint_,const double whitePoint_)
2538 GetAndSetPPChannelMask(channel_);
2539 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2540 RestorePPChannelMask;
2541 ThrowImageException;
2544 void Magick::Image::convolve(const size_t order_,const double *kernel_)
2550 kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2551 kernel_info->width=order_;
2552 kernel_info->height=order_;
2553 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2554 order_*sizeof(*kernel_info->values));
2555 if (kernel_info->values != (MagickRealType *) NULL)
2560 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2561 kernel_info->values[i]=kernel_[i];
2562 newImage=ConvolveImage(image(),kernel_info,exceptionInfo);
2563 replaceImage(newImage);
2565 kernel_info=DestroyKernelInfo(kernel_info);
2566 ThrowImageException;
2569 void Magick::Image::copyPixels(const Image &source_,const Geometry &geometry_,
2570 const Offset &offset_)
2579 (void) CopyImagePixels(image(),source_.constImage(),&geometry,&offset,
2581 ThrowImageException;
2584 void Magick::Image::crop(const Geometry &geometry_)
2593 newImage=CropImage(constImage(),&cropInfo,exceptionInfo);
2594 replaceImage(newImage);
2595 ThrowImageException;
2598 void Magick::Image::cycleColormap(const ssize_t amount_)
2602 CycleColormapImage(image(),amount_,exceptionInfo);
2603 ThrowImageException;
2606 void Magick::Image::decipher(const std::string &passphrase_)
2610 DecipherImage(image(),passphrase_.c_str(),exceptionInfo);
2611 ThrowImageException;
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);
2681 ThrowImageException;
2684 void Magick::Image::despeckle(void)
2690 newImage=DespeckleImage(constImage(),exceptionInfo);
2691 replaceImage(newImage);
2692 ThrowImageException;
2695 Magick::ImageType Magick::Image::determineType(void) const
2701 image_type=GetImageType(constImage(),exceptionInfo);
2702 ThrowImageException;
2706 void Magick::Image::display(void)
2709 DisplayImages(imageInfo(),image(),exceptionInfo);
2710 ThrowImageException;
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);
2723 ThrowImageException;
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(quiet());
2747 void Magick::Image::draw(const std::vector<Magick::Drawable> &drawable_)
2754 wand=DrawAllocateWand(options()->drawInfo(),image());
2758 for (std::vector<Magick::Drawable>::const_iterator p = drawable_.begin();
2759 p != drawable_.end(); p++ )
2761 p->operator()(wand);
2762 if (DrawGetExceptionType(wand) != MagickCore::UndefinedException)
2766 if (DrawGetExceptionType(wand) == MagickCore::UndefinedException)
2769 ClonePPDrawException(wand);
2770 wand=DestroyDrawingWand(wand);
2771 ThrowPPDrawException(quiet());
2775 void Magick::Image::edge(const double radius_)
2781 newImage=EdgeImage(constImage(),radius_,exceptionInfo);
2782 replaceImage(newImage);
2783 ThrowImageException;
2786 void Magick::Image::emboss(const double radius_,const double sigma_)
2792 newImage=EmbossImage(constImage(),radius_,sigma_,exceptionInfo);
2793 replaceImage(newImage);
2794 ThrowImageException;
2797 void Magick::Image::encipher(const std::string &passphrase_)
2801 EncipherImage(image(),passphrase_.c_str(),exceptionInfo);
2802 ThrowImageException;
2805 void Magick::Image::enhance(void)
2811 newImage=EnhanceImage(constImage(),exceptionInfo);
2812 replaceImage(newImage);
2813 ThrowImageException;
2816 void Magick::Image::equalize(void)
2820 EqualizeImage(image(),exceptionInfo);
2821 ThrowImageException;
2824 void Magick::Image::erase(void)
2828 (void) SetImageBackgroundColor(image(),exceptionInfo);
2829 ThrowImageException;
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);
2846 ThrowImageException;
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);
2884 ThrowImageException;
2887 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2888 const unsigned int alpha_,const bool invert_)
2895 target=static_cast<PixelInfo>(pixelColor(x_,y_));
2896 target.alpha=alpha_;
2898 GetAndSetPPChannelMask(AlphaChannel);
2899 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2900 (MagickBooleanType)invert_,exceptionInfo);
2901 RestorePPChannelMask;
2902 ThrowImageException;
2905 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2906 const unsigned int alpha_,const Color &target_,const bool invert_)
2913 target=static_cast<PixelInfo>(target_);
2914 target.alpha=alpha_;
2916 GetAndSetPPChannelMask(AlphaChannel);
2917 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2918 (MagickBooleanType)invert_,exceptionInfo);
2919 RestorePPChannelMask;
2920 ThrowImageException;
2923 void Magick::Image::floodFillColor(const Geometry &point_,
2924 const Magick::Color &fillColor_,const bool invert_)
2926 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,invert_);
2929 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2930 const Magick::Color &fillColor_,const bool invert_)
2937 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2938 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2941 void Magick::Image::floodFillColor(const Geometry &point_,
2942 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2945 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,borderColor_,invert_);
2948 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2949 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2957 pixel=static_cast<PixelInfo>(borderColor_);
2958 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2961 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2962 const Magick::Image &texture_,const bool invert_)
2964 floodFillTexture(point_.xOff(),point_.yOff(),texture_,invert_);
2967 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2968 const Magick::Image &texture_,const bool invert_)
2975 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2976 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
2979 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2980 const Magick::Image &texture_,const Magick::Color &borderColor_,
2983 floodFillTexture(point_.xOff(),point_.yOff(),texture_,borderColor_,invert_);
2986 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2987 const Magick::Image &texture_,const Magick::Color &borderColor_,
2995 pixel=static_cast<PixelInfo>(borderColor_);
2996 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
2999 void Magick::Image::flop(void)
3005 newImage=FlopImage(constImage(),exceptionInfo);
3006 replaceImage(newImage);
3007 ThrowImageException;
3010 void Magick::Image::fontTypeMetrics(const std::string &text_,
3011 TypeMetric *metrics)
3016 drawInfo=options()->drawInfo();
3017 drawInfo->text=const_cast<char *>(text_.c_str());
3019 GetTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3021 ThrowImageException;
3024 void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
3025 TypeMetric *metrics)
3030 drawInfo=options()->drawInfo();
3031 drawInfo->text=const_cast<char *>(text_.c_str());
3033 GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3035 ThrowImageException;
3038 void Magick::Image::frame(const Geometry &geometry_)
3046 info.x=static_cast<ssize_t>(geometry_.width());
3047 info.y=static_cast<ssize_t>(geometry_.height());
3048 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3049 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3050 info.outer_bevel=geometry_.xOff();
3051 info.inner_bevel=geometry_.yOff();
3054 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3055 replaceImage(newImage);
3056 ThrowImageException;
3059 void Magick::Image::frame(const size_t width_,const size_t height_,
3060 const ssize_t innerBevel_,const ssize_t outerBevel_)
3068 info.x=static_cast<ssize_t>(width_);
3069 info.y=static_cast<ssize_t>(height_);
3070 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3071 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3072 info.outer_bevel=static_cast<ssize_t>(outerBevel_);
3073 info.inner_bevel=static_cast<ssize_t>(innerBevel_);
3076 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3077 replaceImage(newImage);
3078 ThrowImageException;
3081 void Magick::Image::fx(const std::string expression_)
3087 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3088 replaceImage(newImage);
3089 ThrowImageException;
3092 void Magick::Image::fx(const std::string expression_,
3093 const Magick::ChannelType channel_)
3099 GetAndSetPPChannelMask(channel_);
3100 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3101 RestorePPChannelMask;
3102 replaceImage(newImage);
3103 ThrowImageException;
3106 void Magick::Image::gamma(const double gamma_)
3110 GammaImage(image(),gamma_,exceptionInfo);
3111 ThrowImageException;
3114 void Magick::Image::gamma(const double gammaRed_,const double gammaGreen_,
3115 const double gammaBlue_)
3119 GetAndSetPPChannelMask(RedChannel);
3120 (void) GammaImage(image(),gammaRed_,exceptionInfo);
3121 SetPPChannelMask(GreenChannel);
3122 (void) GammaImage(image(),gammaGreen_,exceptionInfo);
3123 SetPPChannelMask(BlueChannel);
3124 (void) GammaImage(image(),gammaBlue_,exceptionInfo);
3125 RestorePPChannelMask;
3126 ThrowImageException;
3129 void Magick::Image::gaussianBlur(const double width_,const double sigma_)
3135 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3136 replaceImage(newImage);
3137 ThrowImageException;
3140 void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
3141 const double width_,const double sigma_)
3147 GetAndSetPPChannelMask(channel_);
3148 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3149 RestorePPChannelMask;
3150 replaceImage(newImage);
3151 ThrowImageException;
3154 const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
3155 const ssize_t y_,const size_t columns_,const size_t rows_) const
3161 p=GetVirtualPixels(constImage(),x_, y_,columns_, rows_,exceptionInfo);
3162 ThrowImageException;
3166 const void *Magick::Image::getConstMetacontent(void) const
3171 result=GetVirtualMetacontent(constImage());
3174 throwExceptionExplicit(MagickCore::OptionError,
3175 "Unable to retrieve meta content.");
3180 void *Magick::Image::getMetacontent(void )
3185 result=GetAuthenticMetacontent(image());
3188 throwExceptionExplicit(MagickCore::OptionError,
3189 "Unable to retrieve meta content.");
3194 Magick::Quantum *Magick::Image::getPixels(const ssize_t x_,const ssize_t y_,
3195 const size_t columns_,const size_t rows_)
3202 result=GetAuthenticPixels(image(),x_, y_,columns_,rows_,exceptionInfo);
3203 ThrowImageException;
3208 void Magick::Image::grayscale(const PixelIntensityMethod method_)
3212 (void) GrayscaleImage(image(),method_,exceptionInfo);
3213 ThrowImageException;
3216 void Magick::Image::haldClut(const Image &clutImage_)
3220 (void) HaldClutImage(image(),clutImage_.constImage(),exceptionInfo);
3221 ThrowImageException;
3224 void Magick::Image::houghLine(const size_t width_,const size_t height_,
3225 const size_t threshold_)
3231 newImage=HoughLineImage(constImage(),width_,height_,threshold_,
3233 replaceImage(newImage);
3234 ThrowImageException;
3237 void Magick::Image::implode(const double factor_)
3243 newImage=ImplodeImage(constImage(),factor_,image()->interpolate,
3245 replaceImage(newImage);
3246 ThrowImageException;
3249 void Magick::Image::inverseFourierTransform(const Image &phase_)
3251 inverseFourierTransform(phase_,true);
3254 void Magick::Image::inverseFourierTransform(const Image &phase_,
3255 const bool magnitude_)
3261 newImage=InverseFourierTransformImage(constImage(),phase_.constImage(),
3262 magnitude_ == true ? MagickTrue : MagickFalse,exceptionInfo);
3263 replaceImage(newImage);
3264 ThrowImageException;
3267 void Magick::Image::kuwahara(const double radius_,const double sigma_)
3273 newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3274 replaceImage(newImage);
3275 ThrowImageException;
3278 void Magick::Image::kuwaharaChannel(const ChannelType channel_,
3279 const double radius_,const double sigma_)
3285 GetAndSetPPChannelMask(channel_);
3286 newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3287 replaceImage(newImage);
3288 RestorePPChannelMask;
3289 ThrowImageException;
3292 void Magick::Image::level(const double blackPoint_,const double whitePoint_,
3293 const double gamma_)
3297 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3298 ThrowImageException;
3301 void Magick::Image::levelChannel(const ChannelType channel_,
3302 const double blackPoint_,const double whitePoint_,const double gamma_)
3306 GetAndSetPPChannelMask(channel_);
3307 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3308 RestorePPChannelMask;
3309 ThrowImageException;
3312 void Magick::Image::levelColors(const Color &blackColor_,
3313 const Color &whiteColor_,const bool invert_)
3321 black=static_cast<PixelInfo>(blackColor_);
3322 white=static_cast<PixelInfo>(whiteColor_);
3324 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3325 MagickTrue : MagickFalse,exceptionInfo);
3326 ThrowImageException;
3329 void Magick::Image::levelColorsChannel(const ChannelType channel_,
3330 const Color &blackColor_,const Color &whiteColor_,const bool invert_)
3338 black=static_cast<PixelInfo>(blackColor_);
3339 white=static_cast<PixelInfo>(whiteColor_);
3341 GetAndSetPPChannelMask(channel_);
3342 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3343 MagickTrue : MagickFalse,exceptionInfo);
3344 RestorePPChannelMask;
3345 ThrowImageException;
3348 void Magick::Image::linearStretch(const double blackPoint_,
3349 const double whitePoint_)
3353 LinearStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
3354 ThrowImageException;
3357 void Magick::Image::liquidRescale(const Geometry &geometry_)
3370 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3374 newImage=LiquidRescaleImage(image(),width,height,x,y,exceptionInfo);
3375 replaceImage(newImage);
3376 ThrowImageException;
3379 void Magick::Image::magnify(void)
3385 newImage=MagnifyImage(constImage(),exceptionInfo);
3386 replaceImage(newImage);
3387 ThrowImageException;
3390 void Magick::Image::map(const Image &mapImage_,const bool dither_)
3394 options()->quantizeDither(dither_);
3395 RemapImage(options()->quantizeInfo(),image(),mapImage_.constImage(),
3397 ThrowImageException;
3400 void Magick::Image::medianFilter(const double radius_)
3406 newImage=StatisticImage(image(),MedianStatistic,(size_t) radius_,
3407 (size_t) radius_,exceptionInfo);
3408 replaceImage(newImage);
3409 ThrowImageException;
3412 void Magick::Image::minify(void)
3418 newImage=MinifyImage(constImage(),exceptionInfo);
3419 replaceImage(newImage);
3420 ThrowImageException;
3423 void Magick::Image::modulate(const double brightness_,const double saturation_,
3427 modulate[MagickPathExtent + 1];
3429 FormatLocaleString(modulate,MagickPathExtent,"%3.6f,%3.6f,%3.6f",brightness_,
3434 ModulateImage(image(),modulate,exceptionInfo);
3435 ThrowImageException;
3438 Magick::ImageMoments Magick::Image::moments(void) const
3440 return(ImageMoments(*this));
3443 void Magick::Image::morphology(const MorphologyMethod method_,
3444 const std::string kernel_,const ssize_t iterations_)
3453 kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3454 if (kernel == (KernelInfo *) NULL)
3455 throwExceptionExplicit(MagickCore::OptionError,"Unable to parse kernel.");
3456 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3458 replaceImage(newImage);
3459 kernel=DestroyKernelInfo(kernel);
3460 ThrowImageException;
3463 void Magick::Image::morphology(const MorphologyMethod method_,
3464 const KernelInfoType kernel_,const std::string arguments_,
3465 const ssize_t iterations_)
3473 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3474 if (option == (const char *)NULL)
3475 throwExceptionExplicit(MagickCore::OptionError,
3476 "Unable to determine kernel type.");
3478 kernel=std::string(option);
3479 if (!arguments_.empty())
3480 kernel+=":"+arguments_;
3482 morphology(method_,kernel,iterations_);
3485 void Magick::Image::morphologyChannel(const ChannelType channel_,
3486 const MorphologyMethod method_,const std::string kernel_,
3487 const ssize_t iterations_)
3497 kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3498 if (kernel == (KernelInfo *)NULL)
3500 throwExceptionExplicit(MagickCore::OptionError,
3501 "Unable to parse kernel.");
3504 GetAndSetPPChannelMask(channel_);
3505 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3507 RestorePPChannelMask;
3508 replaceImage(newImage);
3509 kernel=DestroyKernelInfo(kernel);
3510 ThrowImageException;
3513 void Magick::Image::morphologyChannel(const ChannelType channel_,
3514 const MorphologyMethod method_,const KernelInfoType kernel_,
3515 const std::string arguments_,const ssize_t iterations_)
3523 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3524 if (option == (const char *)NULL)
3526 throwExceptionExplicit(MagickCore::OptionError,
3527 "Unable to determine kernel type.");
3531 kernel=std::string(option);
3532 if (!arguments_.empty())
3533 kernel+=":"+arguments_;
3535 morphologyChannel(channel_,method_,kernel,iterations_);
3538 void Magick::Image::motionBlur(const double radius_,const double sigma_,
3539 const double angle_)
3545 newImage=MotionBlurImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
3546 replaceImage(newImage);
3547 ThrowImageException;
3550 void Magick::Image::negate(const bool grayscale_)
3554 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3555 ThrowImageException;
3558 void Magick::Image::negateChannel(const ChannelType channel_,
3559 const bool grayscale_)
3563 GetAndSetPPChannelMask(channel_);
3564 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3565 RestorePPChannelMask;
3566 ThrowImageException;
3569 void Magick::Image::normalize(void)
3573 NormalizeImage(image(),exceptionInfo);
3574 ThrowImageException;
3577 void Magick::Image::oilPaint(const double radius_,const double sigma_)
3583 newImage=OilPaintImage(constImage(),radius_,sigma_,exceptionInfo);
3584 replaceImage(newImage);
3585 ThrowImageException;
3588 void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_,
3599 if (!opaqueColor_.isValid())
3600 throwExceptionExplicit(MagickCore::OptionError,
3601 "Opaque color argument is invalid");
3603 if (!penColor_.isValid())
3604 throwExceptionExplicit(MagickCore::OptionError,
3605 "Pen color argument is invalid");
3608 opaqueColor=opaqueColor_;
3612 (void) QueryColorCompliance(opaqueColor.c_str(),AllCompliance,&opaque,
3614 (void) QueryColorCompliance(penColor.c_str(),AllCompliance,&pen,
3616 OpaquePaintImage(image(),&opaque,&pen,invert_ ? MagickTrue : MagickFalse,
3618 ThrowImageException;
3621 void Magick::Image::orderedDither(std::string thresholdMap_)
3625 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3626 ThrowImageException;
3629 void Magick::Image::orderedDitherChannel(const ChannelType channel_,
3630 std::string thresholdMap_)
3634 GetAndSetPPChannelMask(channel_);
3635 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3636 RestorePPChannelMask;
3637 ThrowImageException;
3640 void Magick::Image::perceptible(const double epsilon_)
3644 PerceptibleImage(image(),epsilon_,exceptionInfo);
3645 ThrowImageException;
3648 void Magick::Image::perceptibleChannel(const ChannelType channel_,
3649 const double epsilon_)
3653 GetAndSetPPChannelMask(channel_);
3654 PerceptibleImage(image(),epsilon_,exceptionInfo);
3655 RestorePPChannelMask;
3656 ThrowImageException;
3659 Magick::ImagePerceptualHash Magick::Image::perceptualHash() const
3661 return(ImagePerceptualHash(*this));
3664 void Magick::Image::ping(const std::string &imageSpec_)
3670 options()->fileName(imageSpec_);
3671 newImage=PingImage(imageInfo(),exceptionInfo);
3672 read(newImage,exceptionInfo);
3675 void Magick::Image::ping(const Blob& blob_)
3681 newImage=PingBlob(imageInfo(),blob_.data(),blob_.length(),exceptionInfo);
3682 read(newImage,exceptionInfo);
3685 void Magick::Image::pixelColor(const ssize_t x_,const ssize_t y_,
3686 const Color &color_)
3694 // Test arguments to ensure they are within the image.
3695 if (y_ > (ssize_t) rows() || x_ > (ssize_t) columns())
3696 throwExceptionExplicit(MagickCore::OptionError,
3697 "Access outside of image boundary");
3701 // Set image to DirectClass
3702 classType(DirectClass );
3705 Pixels pixels(*this);
3707 pixel=pixels.get(x_, y_, 1, 1 );
3709 MagickCore::SetPixelViaPixelInfo(constImage(),&packet,pixel);
3710 // Tell ImageMagick that pixels have been updated
3714 Magick::Color Magick::Image::pixelColor(const ssize_t x_,
3715 const ssize_t y_) const
3720 pixel=getConstPixels(x_,y_,1,1);
3726 MagickCore::GetPixelInfoPixel(constImage(),pixel,&packet);
3727 return(Color(packet));
3730 return(Color()); // invalid
3733 void Magick::Image::polaroid(const std::string &caption_,const double angle_,
3734 const PixelInterpolateMethod method_)
3740 newImage=PolaroidImage(constImage(),options()->drawInfo(),caption_.c_str(),
3741 angle_,method_,exceptionInfo);
3742 replaceImage(newImage);
3743 ThrowImageException;
3746 void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
3750 PosterizeImage(image(),levels_,method_,exceptionInfo);
3751 ThrowImageException;
3754 void Magick::Image::posterizeChannel(const ChannelType channel_,
3755 const size_t levels_,const DitherMethod method_)
3759 GetAndSetPPChannelMask(channel_);
3760 PosterizeImage(image(),levels_,method_,exceptionInfo);
3761 RestorePPChannelMask;
3762 ThrowImageException;
3765 void Magick::Image::process(std::string name_,const ssize_t argc,
3771 (void) InvokeDynamicImageFilter(name_.c_str(),&image(),argc,argv,
3773 ThrowImageException;
3776 void Magick::Image::profile(const std::string name_,
3777 const Magick::Blob &profile_)
3781 (void) ProfileImage(image(),name_.c_str(),(unsigned char *)profile_.data(),
3782 profile_.length(),exceptionInfo);
3783 ThrowImageException;
3786 Magick::Blob Magick::Image::profile(const std::string name_) const
3791 profile=GetImageProfile(constImage(),name_.c_str());
3793 if (profile == (StringInfo *) NULL)
3795 return(Blob((void*) GetStringInfoDatum(profile),GetStringInfoLength(
3799 void Magick::Image::quantize(const bool measureError_)
3804 options()->quantizeInfo()->measure_error=MagickTrue;
3806 options()->quantizeInfo()->measure_error=MagickFalse;
3809 QuantizeImage(options()->quantizeInfo(),image(),exceptionInfo);
3810 ThrowImageException;
3813 void Magick::Image::quantumOperator(const ChannelType channel_,
3814 const MagickEvaluateOperator operator_,double rvalue_)
3817 GetAndSetPPChannelMask(channel_);
3818 EvaluateImage(image(),operator_,rvalue_,exceptionInfo);
3819 RestorePPChannelMask;
3820 ThrowImageException;
3823 void Magick::Image::quantumOperator(const ssize_t x_,const ssize_t y_,
3824 const size_t columns_,const size_t rows_,const ChannelType channel_,
3825 const MagickEvaluateOperator operator_,const double rvalue_)
3833 geometry.width = columns_;
3834 geometry.height = rows_;
3839 cropImage=CropImage(image(),&geometry,exceptionInfo);
3840 GetAndSetPPChannelMask(channel_);
3841 EvaluateImage(cropImage,operator_,rvalue_,exceptionInfo);
3842 RestorePPChannelMask;
3843 (void) CompositeImage(image(),cropImage,image()->alpha_trait ==
3844 BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
3845 geometry.x,geometry.y,exceptionInfo );
3846 cropImage=DestroyImageList(cropImage);
3847 ThrowImageException;
3850 void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
3853 raiseInfo=geometry_;
3857 RaiseImage(image(),&raiseInfo,raisedFlag_ == true ? MagickTrue : MagickFalse,
3859 ThrowImageException;
3862 void Magick::Image::randomThreshold(const Geometry &thresholds_)
3865 (void) RandomThresholdImage(image(),static_cast<std::string>(
3866 thresholds_).c_str(),exceptionInfo);
3867 ThrowImageException;
3870 void Magick::Image::randomThresholdChannel(const ChannelType channel_,
3871 const Geometry &thresholds_)
3875 GetAndSetPPChannelMask(channel_);
3876 (void) RandomThresholdImage(image(),static_cast<std::string>(
3877 thresholds_).c_str(),exceptionInfo);
3878 RestorePPChannelMask;
3879 ThrowImageException;
3882 void Magick::Image::read(const Blob &blob_)
3888 newImage=BlobToImage(imageInfo(),static_cast<const void *>(blob_.data()),
3889 blob_.length(),exceptionInfo);
3890 read(newImage,exceptionInfo);
3893 void Magick::Image::read(const Blob &blob_,const Geometry &size_)
3899 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3900 const size_t depth_)
3907 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3908 const size_t depth_,const std::string &magick_)
3913 // Set explicit image format
3914 fileName(magick_ + ':');
3918 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3919 const std::string &magick_)
3923 // Set explicit image format
3924 fileName(magick_ + ':');
3928 void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_)
3934 void Magick::Image::read(const size_t width_,const size_t height_,
3935 const std::string &map_,const StorageType type_,const void *pixels_)
3941 newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
3943 replaceImage(newImage);
3944 ThrowImageException;
3947 void Magick::Image::read(const std::string &imageSpec_)
3953 options()->fileName(imageSpec_);
3954 newImage=ReadImage(imageInfo(),exceptionInfo);
3955 read(newImage,exceptionInfo);
3958 void Magick::Image::readPixels(const Magick::QuantumType quantum_,
3959 const unsigned char *source_)
3964 quantum_info=AcquireQuantumInfo(imageInfo(),image());
3966 ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
3967 quantum_,source_,exceptionInfo);
3968 quantum_info=DestroyQuantumInfo(quantum_info);
3969 ThrowImageException;
3972 void Magick::Image::reduceNoise(void)
3977 void Magick::Image::reduceNoise(const size_t order_)
3983 newImage=StatisticImage(constImage(),NonpeakStatistic,order_,
3984 order_,exceptionInfo);
3985 replaceImage(newImage);
3986 ThrowImageException;
3989 void Magick::Image::repage()
3992 options()->page(Geometry());
3993 image()->page.width = 0;
3994 image()->page.height = 0;
3995 image()->page.x = 0;
3996 image()->page.y = 0;
3999 void Magick::Image::resample(const Point &density_)
4005 newImage=ResampleImage(constImage(),density_.x(),density_.y(),
4006 image()->filter,exceptionInfo);
4007 replaceImage(newImage);
4008 ThrowImageException;
4011 void Magick::Image::resize(const Geometry &geometry_)
4024 // Calculate new size. This code should be supported using binary arguments
4025 // in the ImageMagick library.
4026 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4030 newImage=ResizeImage(constImage(),width,height,image()->filter,
4032 replaceImage(newImage);
4033 ThrowImageException;
4036 void Magick::Image::roll(const Geometry &roll_)
4042 newImage=RollImage(constImage(),roll_.xOff(),roll_.yOff(),exceptionInfo);
4043 replaceImage(newImage);
4044 ThrowImageException;
4047 void Magick::Image::roll(const size_t columns_,const size_t rows_)
4053 newImage=RollImage(constImage(),static_cast<ssize_t>(columns_),
4054 static_cast<ssize_t>(rows_),exceptionInfo);
4055 replaceImage(newImage);
4056 ThrowImageException;
4059 void Magick::Image::rotate(const double degrees_)
4065 newImage=RotateImage(constImage(),degrees_,exceptionInfo);
4066 replaceImage(newImage);
4067 ThrowImageException;
4070 void Magick::Image::rotationalBlur(const double angle_)
4076 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4077 replaceImage(newImage);
4078 ThrowImageException;
4081 void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
4082 const double angle_)
4088 GetAndSetPPChannelMask(channel_);
4089 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4090 RestorePPChannelMask;
4091 replaceImage(newImage);
4092 ThrowImageException;
4095 void Magick::Image::sample(const Geometry &geometry_)
4108 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4112 newImage=SampleImage(constImage(),width,height,exceptionInfo);
4113 replaceImage(newImage);
4114 ThrowImageException;
4117 void Magick::Image::scale(const Geometry &geometry_)
4130 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4134 newImage=ScaleImage(constImage(),width,height,exceptionInfo);
4135 replaceImage(newImage);
4136 ThrowImageException;
4139 void Magick::Image::segment(const double clusterThreshold_,
4140 const double smoothingThreshold_)
4144 SegmentImage(image(),options()->quantizeColorSpace(),
4145 (MagickBooleanType) options()->verbose(),clusterThreshold_,
4146 smoothingThreshold_,exceptionInfo);
4147 SyncImage(image(),exceptionInfo);
4148 ThrowImageException;
4151 void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
4152 const double threshold_)
4158 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4160 replaceImage(newImage);
4161 ThrowImageException;
4164 void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
4165 const double radius_,const double sigma_,const double threshold_)
4171 GetAndSetPPChannelMask(channel_);
4172 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4174 RestorePPChannelMask;
4175 replaceImage(newImage);
4176 ThrowImageException;
4179 Magick::Image Magick::Image::separate(const ChannelType channel_) const
4185 image=SeparateImage(constImage(),channel_,exceptionInfo);
4186 ThrowImageException;
4187 if (image == (MagickCore::Image *) NULL)
4188 return(Magick::Image());
4190 return(Magick::Image(image));
4193 void Magick::Image::sepiaTone(const double threshold_)
4199 newImage=SepiaToneImage(constImage(),threshold_,exceptionInfo);
4200 replaceImage(newImage);
4201 ThrowImageException;
4204 Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
4205 const size_t columns_,const size_t rows_)
4212 result=QueueAuthenticPixels(image(),x_,y_,columns_,rows_,exceptionInfo);
4213 ThrowImageException;
4217 void Magick::Image::shade(const double azimuth_,const double elevation_,
4218 const bool colorShading_)
4224 newImage=ShadeImage(constImage(),colorShading_ == true ?
4225 MagickTrue : MagickFalse,azimuth_,elevation_,exceptionInfo);
4226 replaceImage(newImage);
4227 ThrowImageException;
4230 void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
4231 const ssize_t x_,const ssize_t y_)
4237 newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
4239 replaceImage(newImage);
4240 ThrowImageException;
4243 void Magick::Image::sharpen(const double radius_,const double sigma_)
4249 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4250 replaceImage(newImage);
4251 ThrowImageException;
4254 void Magick::Image::sharpenChannel(const ChannelType channel_,
4255 const double radius_,const double sigma_)
4261 GetAndSetPPChannelMask(channel_);
4262 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4263 RestorePPChannelMask;
4264 replaceImage(newImage);
4265 ThrowImageException;
4268 void Magick::Image::shave(const Geometry &geometry_)
4274 shaveInfo=geometry_;
4277 newImage=ShaveImage(constImage(),&shaveInfo,exceptionInfo);
4278 replaceImage(newImage);
4279 ThrowImageException;
4282 void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
4288 newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,exceptionInfo);
4289 replaceImage(newImage);
4290 ThrowImageException;
4293 void Magick::Image::sigmoidalContrast(const bool sharpen_,
4294 const double contrast,const double midpoint)
4298 (void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
4299 midpoint,exceptionInfo);
4300 ThrowImageException;
4303 std::string Magick::Image::signature(const bool force_) const
4305 return(_imgRef->signature());
4308 void Magick::Image::sketch(const double radius_,const double sigma_,
4309 const double angle_)
4315 newImage=SketchImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
4316 replaceImage(newImage);
4317 ThrowImageException;
4320 void Magick::Image::solarize(const double factor_)
4324 SolarizeImage(image(),factor_,exceptionInfo);
4325 ThrowImageException;
4328 void Magick::Image::sparseColor(const ChannelType channel_,
4329 const SparseColorMethod method_,const size_t numberArguments_,
4330 const double *arguments_)
4336 GetAndSetPPChannelMask(channel_);
4337 newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
4339 RestorePPChannelMask;
4340 replaceImage(newImage);
4341 ThrowImageException;
4344 void Magick::Image::splice(const Geometry &geometry_)
4350 spliceInfo=geometry_;
4353 newImage=SpliceImage(constImage(),&spliceInfo,exceptionInfo);
4354 replaceImage(newImage);
4355 ThrowImageException;
4358 void Magick::Image::splice(const Geometry &geometry_,
4359 const Color &backgroundColor_)
4361 backgroundColor(backgroundColor_);
4365 void Magick::Image::splice(const Geometry &geometry_,
4366 const Color &backgroundColor_,const GravityType gravity_)
4368 backgroundColor(backgroundColor_);
4369 image()->gravity=gravity_;
4373 void Magick::Image::spread(const size_t amount_)
4379 newImage=SpreadImage(constImage(),amount_,image()->interpolate,
4381 replaceImage(newImage);
4382 ThrowImageException;
4385 Magick::ImageStatistics Magick::Image::statistics() const
4387 return(ImageStatistics(*this));
4390 void Magick::Image::stegano(const Image &watermark_)
4396 newImage=SteganoImage(constImage(),watermark_.constImage(),exceptionInfo);
4397 replaceImage(newImage);
4398 ThrowImageException;
4401 void Magick::Image::stereo(const Image &rightImage_)
4407 newImage=StereoImage(constImage(),rightImage_.constImage(),exceptionInfo);
4408 replaceImage(newImage);
4409 ThrowImageException;
4412 void Magick::Image::strip(void)
4416 StripImage(image(),exceptionInfo);
4417 ThrowImageException;
4420 Magick::Image Magick::Image::subImageSearch(const Image &reference_,
4421 const MetricType metric_,Geometry *offset_,double *similarityMetric_,
4422 const double similarityThreshold)
4431 newImage=SimilarityImage(image(),reference_.constImage(),metric_,
4432 similarityThreshold,&offset,similarityMetric_,exceptionInfo);
4433 ThrowImageException;
4434 if (offset_ != (Geometry *) NULL)
4436 if (newImage == (MagickCore::Image *) NULL)
4437 return(Magick::Image());
4439 return(Magick::Image(newImage));
4442 void Magick::Image::swirl(const double degrees_)
4448 newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
4450 replaceImage(newImage);
4451 ThrowImageException;
4454 void Magick::Image::syncPixels(void)
4457 (void) SyncAuthenticPixels(image(),exceptionInfo);
4458 ThrowImageException;
4461 void Magick::Image::texture(const Image &texture_)
4465 TextureImage(image(),texture_.constImage(),exceptionInfo);
4466 ThrowImageException;
4469 void Magick::Image::threshold(const double threshold_)
4473 BilevelImage(image(),threshold_,exceptionInfo);
4474 ThrowImageException;
4477 void Magick::Image::thumbnail(const Geometry &geometry_)
4490 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4494 newImage=ThumbnailImage(constImage(),width,height,exceptionInfo);
4495 replaceImage(newImage);
4496 ThrowImageException;
4499 void Magick::Image::tint(const std::string opacity_)
4508 color=static_cast<PixelInfo>(constOptions()->fillColor());
4509 newImage=TintImage(constImage(),opacity_.c_str(),&color,exceptionInfo);
4510 replaceImage(newImage);
4511 ThrowImageException;
4514 void Magick::Image::transform(const Geometry &imageGeometry_)
4518 TransformImage(&(image()),0,std::string(imageGeometry_).c_str(),
4520 ThrowImageException;
4523 void Magick::Image::transform(const Geometry &imageGeometry_,
4524 const Geometry &cropGeometry_)
4528 TransformImage(&(image()),std::string(cropGeometry_).c_str(),std::string(
4529 imageGeometry_).c_str(), exceptionInfo);
4530 ThrowImageException;
4533 void Magick::Image::transformOrigin(const double x_,const double y_)
4536 options()->transformOrigin(x_,y_);
4539 void Magick::Image::transformReset(void)
4542 options()->transformReset();
4545 void Magick::Image::transformScale(const double sx_,const double sy_)
4548 options()->transformScale(sx_,sy_);
4551 void Magick::Image::transparent(const Color &color_)
4559 if (!color_.isValid())
4560 throwExceptionExplicit(MagickCore::OptionError,
4561 "Color argument is invalid");
4565 (void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
4568 TransparentPaintImage(image(),&target,TransparentAlpha,MagickFalse,
4570 ThrowImageException;
4573 void Magick::Image::transparentChroma(const Color &colorLow_,
4574 const Color &colorHigh_)
4584 if (!colorLow_.isValid() || !colorHigh_.isValid())
4585 throwExceptionExplicit(MagickCore::OptionError,
4586 "Color argument is invalid");
4589 colorHigh=colorHigh_;
4592 (void) QueryColorCompliance(colorLow.c_str(),AllCompliance,&targetLow,
4594 (void) QueryColorCompliance(colorHigh.c_str(),AllCompliance,&targetHigh,
4597 TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
4598 MagickFalse,exceptionInfo);
4599 ThrowImageException;
4602 void Magick::Image::transpose(void)
4608 newImage=TransposeImage(constImage(),exceptionInfo);
4609 replaceImage(newImage);
4610 ThrowImageException;
4613 void Magick::Image::transverse(void)
4619 newImage=TransverseImage(constImage(),exceptionInfo);
4620 replaceImage(newImage);
4621 ThrowImageException;
4624 void Magick::Image::trim(void)
4630 newImage=TrimImage(constImage(),exceptionInfo);
4631 replaceImage(newImage);
4632 ThrowImageException;
4635 Magick::Image Magick::Image::uniqueColors(void) const
4641 image=UniqueImageColors(constImage(),exceptionInfo);
4642 ThrowImageException;
4643 if (image == (MagickCore::Image *) NULL)
4644 return(Magick::Image());
4646 return(Magick::Image(image));
4649 void Magick::Image::unsharpmask(const double radius_,const double sigma_,
4650 const double amount_,const double threshold_)
4656 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4658 replaceImage(newImage);
4659 ThrowImageException;
4662 void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
4663 const double radius_,const double sigma_,const double amount_,
4664 const double threshold_)
4670 GetAndSetPPChannelMask(channel_);
4671 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4673 RestorePPChannelMask;
4674 replaceImage(newImage);
4675 ThrowImageException;
4678 void Magick::Image::vignette(const double radius_,const double sigma_,
4679 const ssize_t x_,const ssize_t y_)
4685 newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,exceptionInfo);
4686 replaceImage(newImage);
4687 ThrowImageException;
4690 void Magick::Image::wave(const double amplitude_,const double wavelength_)
4696 newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
4698 replaceImage(newImage);
4699 ThrowImageException;
4702 void Magick::Image::whiteThreshold(const std::string &threshold_)
4706 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4707 ThrowImageException;
4710 void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
4711 const std::string &threshold_)
4715 GetAndSetPPChannelMask(channel_);
4716 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4717 RestorePPChannelMask;
4718 ThrowImageException;
4721 void Magick::Image::write(Blob *blob_)
4731 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4733 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4734 ThrowImageException;
4737 void Magick::Image::write(Blob *blob_,const std::string &magick_)
4748 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4750 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4751 ThrowImageException;
4754 void Magick::Image::write(Blob *blob_,const std::string &magick_,
4755 const size_t depth_)
4767 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4769 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4770 ThrowImageException;
4773 void Magick::Image::write(const ssize_t x_,const ssize_t y_,
4774 const size_t columns_,const size_t rows_,const std::string &map_,
4775 const StorageType type_,void *pixels_)
4778 ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
4780 ThrowImageException;
4783 void Magick::Image::write(const std::string &imageSpec_)
4786 fileName(imageSpec_);
4788 WriteImage(constImageInfo(),image(),exceptionInfo);
4789 ThrowImageException;
4792 void Magick::Image::writePixels(const Magick::QuantumType quantum_,
4793 unsigned char *destination_)
4798 quantum_info=AcquireQuantumInfo(imageInfo(),image());
4800 ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4801 quantum_,destination_, exceptionInfo);
4802 quantum_info=DestroyQuantumInfo(quantum_info);
4803 ThrowImageException;
4806 void Magick::Image::zoom(const Geometry &geometry_)
4819 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4823 newImage=ResizeImage(constImage(),width,height,image()->filter,exceptionInfo);
4824 replaceImage(newImage);
4825 ThrowImageException;
4828 Magick::Image::Image(MagickCore::Image *image_)
4829 : _imgRef(new ImageRef(image_))
4833 MagickCore::Image *&Magick::Image::image(void)
4835 return(_imgRef->image());
4838 const MagickCore::Image *Magick::Image::constImage(void) const
4840 return(_imgRef->image());
4843 MagickCore::ImageInfo *Magick::Image::imageInfo(void)
4845 return(_imgRef->options()->imageInfo());
4848 const MagickCore::ImageInfo *Magick::Image::constImageInfo(void) const
4850 return(_imgRef->options()->imageInfo());
4853 Magick::Options *Magick::Image::options(void)
4855 return(_imgRef->options());
4858 const Magick::Options *Magick::Image::constOptions(void) const
4860 return(_imgRef->options());
4863 MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)
4865 return(_imgRef->options()->quantizeInfo());
4868 const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
4870 return(_imgRef->options()->quantizeInfo());
4873 void Magick::Image::modifyImage(void)
4875 if (!_imgRef->isShared())
4879 replaceImage(CloneImage(image(),0,0,MagickTrue,exceptionInfo));
4880 ThrowImageException;
4883 MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
4893 image=AcquireImage(constImageInfo(),exceptionInfo);
4894 ThrowImageException;
4897 _imgRef=ImageRef::replaceImage(_imgRef,image);
4901 void Magick::Image::read(MagickCore::Image *image,
4902 MagickCore::ExceptionInfo *exceptionInfo)
4904 // Ensure that multiple image frames were not read.
4905 if (image != (MagickCore::Image *) NULL &&
4906 image->next != (MagickCore::Image *) NULL)
4911 // Destroy any extra image frames
4913 image->next=(MagickCore::Image *) NULL;
4914 next->previous=(MagickCore::Image *) NULL;
4915 DestroyImageList(next);
4917 replaceImage(image);
4918 if (exceptionInfo->severity == MagickCore::UndefinedException &&
4919 image == (MagickCore::Image *) NULL)
4921 (void) MagickCore::DestroyExceptionInfo(exceptionInfo);
4923 throwExceptionExplicit(MagickCore::ImageWarning,
4924 "No image was loaded.");
4926 ThrowImageException;
4929 void Magick::Image::floodFill(const ssize_t x_,const ssize_t y_,
4930 const Magick::Image *fillPattern_,const Magick::Color &fill_,
4931 const MagickCore::PixelInfo *target_,const bool invert_)
4939 // Set drawing fill pattern or fill color
4940 fillColor=options()->fillColor();
4941 fillPattern=(MagickCore::Image *)NULL;
4942 if (options()->fillPattern() != (MagickCore::Image *)NULL)
4945 fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
4947 ThrowImageException;
4950 if (fillPattern_ == (Magick::Image *)NULL)
4952 options()->fillPattern((MagickCore::Image *)NULL);
4953 options()->fillColor(fill_);
4956 options()->fillPattern(fillPattern_->constImage());
4959 (void) FloodfillPaintImage(image(),options()->drawInfo(),
4960 target_,static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),
4961 (MagickBooleanType) invert_,exceptionInfo);
4963 options()->fillColor(fillColor);
4964 options()->fillPattern(fillPattern);
4965 ThrowImageException;