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[MaxTextExtent];
362 FormatLocaleString(value,MaxTextExtent,"%.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 void Magick::Image::isValid(const bool isValid_)
1031 _imgRef=new ImageRef;
1033 else if (!isValid())
1035 // Construct with single-pixel black image to make
1036 // image valid. This is an obvious hack.
1037 size(Geometry(1,1));
1042 bool Magick::Image::isValid(void) const
1044 return rows() && columns();
1047 void Magick::Image::label(const std::string &label_)
1051 (void) SetImageProperty(image(),"Label",NULL,exceptionInfo);
1052 if (label_.length() > 0)
1053 (void) SetImageProperty(image(),"Label",label_.c_str(),exceptionInfo);
1054 ThrowImageException;
1057 std::string Magick::Image::label(void) const
1063 value=GetImageProperty(constImage(),"Label",exceptionInfo);
1064 ThrowImageException;
1067 return(std::string(value));
1069 return(std::string());
1072 void Magick::Image::lowlightColor(const Color color_)
1078 artifact("lowlight-color",value);
1081 void Magick::Image::mask(const Magick::Image &mask_)
1086 if (mask_.isValid())
1087 SetImageMask(image(),mask_.constImage(),exceptionInfo);
1089 SetImageMask(image(),(MagickCore::Image *) NULL,exceptionInfo);
1090 ThrowImageException;
1093 Magick::Image Magick::Image::mask(void) const
1099 image=GetImageMask(constImage(),exceptionInfo);
1100 ThrowImageException;
1102 if (image == (MagickCore::Image *) NULL)
1103 return(Magick::Image());
1105 return(Magick::Image(image));
1108 void Magick::Image::magick(const std::string &magick_)
1115 length=sizeof(image()->magick)-1;
1116 if (magick_.length() < length)
1117 length=magick_.length();
1119 if (!magick_.empty())
1120 magick_.copy(image()->magick,length);
1121 image()->magick[length]=0;
1123 options()->magick(magick_);
1126 std::string Magick::Image::magick(void) const
1128 if (*(constImage()->magick) != '\0')
1129 return(std::string(constImage()->magick));
1131 return(constOptions()->magick());
1134 double Magick::Image::meanErrorPerPixel(void) const
1136 return(constImage()->error.mean_error_per_pixel);
1139 void Magick::Image::modulusDepth(const size_t depth_)
1143 SetImageDepth(image(),depth_,exceptionInfo);
1144 ThrowImageException;
1145 options()->depth(depth_);
1148 size_t Magick::Image::modulusDepth(void) const
1154 depth=GetImageDepth(constImage(),exceptionInfo);
1155 ThrowImageException;
1159 void Magick::Image::monochrome(const bool monochromeFlag_)
1162 options()->monochrome(monochromeFlag_);
1165 bool Magick::Image::monochrome(void) const
1167 return(constOptions()->monochrome());
1170 Magick::Geometry Magick::Image::montageGeometry(void) const
1172 if (constImage()->montage)
1173 return Magick::Geometry(constImage()->montage);
1176 throwExceptionExplicit(MagickCore::CorruptImageWarning,
1177 "Image does not contain a montage");
1179 return(Magick::Geometry());
1182 double Magick::Image::normalizedMaxError(void) const
1184 return(constImage()->error.normalized_maximum_error);
1187 double Magick::Image::normalizedMeanError(void) const
1189 return(constImage()->error.normalized_mean_error);
1192 void Magick::Image::orientation(const Magick::OrientationType orientation_)
1195 image()->orientation=orientation_;
1198 Magick::OrientationType Magick::Image::orientation(void) const
1200 return(constImage()->orientation);
1203 void Magick::Image::page(const Magick::Geometry &pageSize_)
1206 options()->page(pageSize_);
1207 image()->page=pageSize_;
1210 Magick::Geometry Magick::Image::page(void) const
1212 return(Geometry(constImage()->page.width,constImage()->page.height,
1213 constImage()->page.x,constImage()->page.y));
1216 void Magick::Image::quality(const size_t quality_)
1219 image()->quality=quality_;
1220 options()->quality(quality_);
1223 size_t Magick::Image::quality(void) const
1225 return(constImage()->quality);
1228 void Magick::Image::quantizeColors(const size_t colors_)
1231 options()->quantizeColors(colors_);
1234 size_t Magick::Image::quantizeColors(void) const
1236 return(constOptions()->quantizeColors());
1239 void Magick::Image::quantizeColorSpace(
1240 const Magick::ColorspaceType colorSpace_)
1243 options()->quantizeColorSpace(colorSpace_);
1246 Magick::ColorspaceType Magick::Image::quantizeColorSpace(void) const
1248 return(constOptions()->quantizeColorSpace());
1251 void Magick::Image::quantizeDither(const bool ditherFlag_)
1254 options()->quantizeDither(ditherFlag_);
1257 bool Magick::Image::quantizeDither(void) const
1259 return(constOptions()->quantizeDither());
1262 void Magick::Image::quantizeDitherMethod(const DitherMethod ditherMethod_)
1265 options()->quantizeDitherMethod(ditherMethod_);
1268 MagickCore::DitherMethod Magick::Image::quantizeDitherMethod(void) const
1270 return(constOptions()->quantizeDitherMethod());
1273 void Magick::Image::quantizeTreeDepth(const size_t treeDepth_)
1276 options()->quantizeTreeDepth(treeDepth_);
1279 size_t Magick::Image::quantizeTreeDepth() const
1281 return(constOptions()->quantizeTreeDepth());
1284 void Magick::Image::quiet(const bool quiet_)
1287 options()->quiet(quiet_);
1290 bool Magick::Image::quiet(void) const
1292 return(constOptions()->quiet());
1295 void Magick::Image::renderingIntent(
1296 const Magick::RenderingIntent renderingIntent_)
1299 image()->rendering_intent=renderingIntent_;
1302 Magick::RenderingIntent Magick::Image::renderingIntent(void) const
1304 return(static_cast<Magick::RenderingIntent>(constImage()->rendering_intent));
1307 void Magick::Image::resolutionUnits(
1308 const Magick::ResolutionType resolutionUnits_)
1311 image()->units=resolutionUnits_;
1312 options()->resolutionUnits(resolutionUnits_);
1315 Magick::ResolutionType Magick::Image::resolutionUnits(void) const
1317 return(static_cast<Magick::ResolutionType>(constImage()->units));
1320 size_t Magick::Image::rows(void) const
1322 return(constImage()->rows);
1325 void Magick::Image::scene(const size_t scene_)
1328 image()->scene=scene_;
1331 size_t Magick::Image::scene(void) const
1333 return(constImage()->scene);
1336 void Magick::Image::size(const Geometry &geometry_)
1339 options()->size(geometry_);
1340 image()->rows=geometry_.height();
1341 image()->columns=geometry_.width();
1344 Magick::Geometry Magick::Image::size(void) const
1346 return(Magick::Geometry(constImage()->columns,constImage()->rows));
1349 void Magick::Image::strokeAntiAlias(const bool flag_)
1352 options()->strokeAntiAlias(flag_);
1355 bool Magick::Image::strokeAntiAlias(void) const
1357 return(constOptions()->strokeAntiAlias());
1360 void Magick::Image::strokeColor(const Magick::Color &strokeColor_)
1366 options()->strokeColor(strokeColor_);
1368 artifact("stroke",value);
1371 Magick::Color Magick::Image::strokeColor(void) const
1373 return(constOptions()->strokeColor());
1376 void Magick::Image::strokeDashArray(const double *strokeDashArray_)
1379 options()->strokeDashArray(strokeDashArray_);
1382 const double* Magick::Image::strokeDashArray(void) const
1384 return(constOptions()->strokeDashArray());
1387 void Magick::Image::strokeDashOffset(const double strokeDashOffset_)
1390 options()->strokeDashOffset(strokeDashOffset_);
1393 double Magick::Image::strokeDashOffset(void) const
1395 return(constOptions()->strokeDashOffset());
1398 void Magick::Image::strokeLineCap(const Magick::LineCap lineCap_)
1401 options()->strokeLineCap(lineCap_);
1404 Magick::LineCap Magick::Image::strokeLineCap(void) const
1406 return(constOptions()->strokeLineCap());
1409 void Magick::Image::strokeLineJoin(const Magick::LineJoin lineJoin_)
1412 options()->strokeLineJoin(lineJoin_);
1415 Magick::LineJoin Magick::Image::strokeLineJoin(void) const
1417 return(constOptions()->strokeLineJoin());
1420 void Magick::Image::strokeMiterLimit(const size_t strokeMiterLimit_)
1423 options()->strokeMiterLimit(strokeMiterLimit_);
1426 size_t Magick::Image::strokeMiterLimit(void) const
1428 return(constOptions()->strokeMiterLimit());
1431 void Magick::Image::strokePattern(const Image &strokePattern_)
1434 if(strokePattern_.isValid())
1435 options()->strokePattern(strokePattern_.constImage());
1437 options()->strokePattern(static_cast<MagickCore::Image*>(NULL));
1440 Magick::Image Magick::Image::strokePattern(void) const
1442 // FIXME: This is inordinately innefficient
1443 const MagickCore::Image
1449 tmpTexture=constOptions()->strokePattern();
1457 image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
1458 texture.replaceImage(image);
1459 ThrowImageException;
1464 void Magick::Image::strokeWidth(const double strokeWidth_)
1467 value[MaxTextExtent];
1470 options()->strokeWidth(strokeWidth_);
1471 FormatLocaleString(value,MaxTextExtent,"%.20g",strokeWidth_);
1472 (void) SetImageArtifact(image(),"strokewidth",value);
1475 double Magick::Image::strokeWidth(void) const
1477 return(constOptions()->strokeWidth());
1480 void Magick::Image::subImage(const size_t subImage_)
1483 options()->subImage(subImage_);
1486 size_t Magick::Image::subImage(void) const
1488 return(constOptions()->subImage());
1491 void Magick::Image::subRange(const size_t subRange_)
1494 options()->subRange(subRange_);
1497 size_t Magick::Image::subRange(void) const
1499 return(constOptions()->subRange());
1502 void Magick::Image::textDirection(DirectionType direction_)
1505 options()->textDirection(direction_);
1508 Magick::DirectionType Magick::Image::textDirection(void) const
1510 return(constOptions()->textDirection());
1513 void Magick::Image::textEncoding(const std::string &encoding_)
1516 options()->textEncoding(encoding_);
1519 std::string Magick::Image::textEncoding(void) const
1521 return(constOptions()->textEncoding());
1524 void Magick::Image::textGravity(GravityType gravity_)
1527 options()->textGravity(gravity_);
1530 Magick::GravityType Magick::Image::textGravity(void) const
1532 return(constOptions()->textGravity());
1535 void Magick::Image::textInterlineSpacing(double spacing_)
1538 options()->textInterlineSpacing(spacing_);
1541 double Magick::Image::textInterlineSpacing(void) const
1543 return(constOptions()->textInterlineSpacing());
1546 void Magick::Image::textInterwordSpacing(double spacing_)
1549 options()->textInterwordSpacing(spacing_);
1552 double Magick::Image::textInterwordSpacing(void) const
1554 return(constOptions()->textInterwordSpacing());
1557 void Magick::Image::textKerning(double kerning_)
1560 options()->textKerning(kerning_);
1563 double Magick::Image::textKerning(void) const
1565 return(constOptions()->textKerning());
1568 size_t Magick::Image::totalColors(void) const
1574 colors=GetNumberColors(constImage(),(FILE *) NULL,exceptionInfo);
1575 ThrowImageException;
1579 void Magick::Image::transformRotation(const double angle_)
1582 options()->transformRotation(angle_);
1585 void Magick::Image::transformSkewX(const double skewx_)
1588 options()->transformSkewX(skewx_);
1591 void Magick::Image::transformSkewY(const double skewy_)
1594 options()->transformSkewY(skewy_);
1597 Magick::ImageType Magick::Image::type(void) const
1599 if (constOptions()->type() != UndefinedType)
1600 return(constOptions()->type());
1601 else if (constImage()->type != UndefinedType)
1602 return(constImage()->type);
1604 return(determineType());
1607 void Magick::Image::type(const Magick::ImageType type_)
1610 options()->type(type_);
1612 SetImageType(image(),type_,exceptionInfo);
1613 ThrowImageException;
1616 void Magick::Image::verbose(const bool verboseFlag_)
1619 options()->verbose(verboseFlag_);
1622 bool Magick::Image::verbose(void) const
1624 return(constOptions()->verbose());
1627 void Magick::Image::view(const std::string &view_)
1630 options()->view(view_);
1633 std::string Magick::Image::view(void) const
1635 return(constOptions()->view());
1638 void Magick::Image::virtualPixelMethod(
1639 const VirtualPixelMethod virtualPixelMethod_)
1643 SetImageVirtualPixelMethod(image(),virtualPixelMethod_,exceptionInfo);
1644 ThrowImageException;
1647 Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod(void) const
1649 return(GetImageVirtualPixelMethod(constImage()));
1652 void Magick::Image::x11Display(const std::string &display_)
1655 options()->x11Display(display_);
1658 std::string Magick::Image::x11Display(void) const
1660 return(constOptions()->x11Display());
1663 double Magick::Image::xResolution(void) const
1665 return(constImage()->resolution.x);
1668 double Magick::Image::yResolution(void) const
1670 return(constImage()->resolution.y);
1673 void Magick::Image::adaptiveBlur(const double radius_,const double sigma_)
1679 newImage=AdaptiveBlurImage(constImage(),radius_,sigma_,exceptionInfo);
1680 replaceImage(newImage);
1681 ThrowImageException;
1684 void Magick::Image::adaptiveResize(const Geometry &geometry_)
1697 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
1701 newImage=AdaptiveResizeImage(constImage(),width,height,exceptionInfo);
1702 replaceImage(newImage);
1703 ThrowImageException;
1706 void Magick::Image::adaptiveSharpen(const double radius_,const double sigma_)
1712 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1713 replaceImage(newImage);
1714 ThrowImageException;
1717 void Magick::Image::adaptiveSharpenChannel(const ChannelType channel_,
1718 const double radius_,const double sigma_ )
1724 GetAndSetPPChannelMask(channel_);
1725 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1726 RestorePPChannelMask;
1727 replaceImage(newImage);
1728 ThrowImageException;
1731 void Magick::Image::adaptiveThreshold(const size_t width_,const size_t height_,
1739 newImage=AdaptiveThresholdImage(constImage(),width_,height_,bias_,
1741 replaceImage(newImage);
1742 ThrowImageException;
1745 void Magick::Image::addNoise(const NoiseType noiseType_)
1751 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1752 replaceImage(newImage);
1753 ThrowImageException;
1756 void Magick::Image::addNoiseChannel(const ChannelType channel_,
1757 const NoiseType noiseType_)
1763 GetAndSetPPChannelMask(channel_);
1764 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1765 RestorePPChannelMask;
1766 replaceImage(newImage);
1767 ThrowImageException;
1770 void Magick::Image::affineTransform(const DrawableAffine &affine_)
1778 _affine.sx=affine_.sx();
1779 _affine.sy=affine_.sy();
1780 _affine.rx=affine_.rx();
1781 _affine.ry=affine_.ry();
1782 _affine.tx=affine_.tx();
1783 _affine.ty=affine_.ty();
1786 newImage=AffineTransformImage(constImage(),&_affine,exceptionInfo);
1787 replaceImage(newImage);
1788 ThrowImageException;
1791 void Magick::Image::alpha(const unsigned int alpha_)
1795 SetImageAlpha(image(),alpha_,exceptionInfo);
1796 ThrowImageException;
1799 void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
1803 SetImageAlphaChannel(image(),alphaOption_,exceptionInfo);
1804 ThrowImageException;
1807 void Magick::Image::annotate(const std::string &text_,
1808 const Geometry &location_)
1810 annotate(text_,location_,NorthWestGravity,0.0);
1813 void Magick::Image::annotate(const std::string &text_,
1814 const Geometry &boundingArea_,const GravityType gravity_)
1816 annotate(text_,boundingArea_,gravity_,0.0);
1819 void Magick::Image::annotate(const std::string &text_,
1820 const Geometry &boundingArea_,const GravityType gravity_,
1821 const double degrees_)
1827 boundingArea[MaxTextExtent];
1834 drawInfo=options()->drawInfo();
1835 drawInfo->text=const_cast<char *>(text_.c_str());
1836 drawInfo->geometry=0;
1838 if (boundingArea_.isValid())
1840 if (boundingArea_.width() == 0 || boundingArea_.height() == 0)
1842 FormatLocaleString(boundingArea,MaxTextExtent,"%+.20g%+.20g",
1843 (double) boundingArea_.xOff(),(double) boundingArea_.yOff());
1847 (void) CopyMagickString(boundingArea,
1848 std::string(boundingArea_).c_str(), MaxTextExtent);
1850 drawInfo->geometry=boundingArea;
1853 drawInfo->gravity=gravity_;
1855 oaffine=drawInfo->affine;
1856 if (degrees_ != 0.0)
1869 current=drawInfo->affine;
1870 affine.sx=cos(DegreesToRadians(fmod(degrees_,360.0)));
1871 affine.rx=sin(DegreesToRadians(fmod(degrees_,360.0)));
1872 affine.ry=(-sin(DegreesToRadians(fmod(degrees_,360.0))));
1873 affine.sy=cos(DegreesToRadians(fmod(degrees_,360.0)));
1875 drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
1876 drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
1877 drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
1878 drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
1879 drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty
1884 AnnotateImage(image(),drawInfo,exceptionInfo);
1886 // Restore original values
1887 drawInfo->affine=oaffine;
1889 drawInfo->geometry=0;
1891 ThrowImageException;
1894 void Magick::Image::annotate(const std::string &text_,
1895 const GravityType gravity_)
1902 drawInfo=options()->drawInfo();
1903 drawInfo->text=const_cast<char *>(text_.c_str());
1904 drawInfo->gravity=gravity_;
1907 AnnotateImage(image(),drawInfo,exceptionInfo);
1909 drawInfo->gravity=NorthWestGravity;
1912 ThrowImageException;
1915 void Magick::Image::artifact(const std::string &name_,const std::string &value_)
1918 (void) SetImageArtifact(image(),name_.c_str(),value_.c_str());
1921 std::string Magick::Image::artifact(const std::string &name_) const
1926 value=GetImageArtifact(constImage(),name_.c_str());
1928 return(std::string(value));
1929 return(std::string());
1932 void Magick::Image::attribute(const std::string name_,const std::string value_)
1936 SetImageProperty(image(),name_.c_str(),value_.c_str(),exceptionInfo);
1937 ThrowImageException;
1940 std::string Magick::Image::attribute(const std::string name_) const
1946 value=GetImageProperty(constImage(),name_.c_str(),exceptionInfo);
1947 ThrowImageException;
1950 return(std::string(value));
1952 return(std::string()); // Intentionally no exception
1955 void Magick::Image::autoGamma(void)
1959 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1960 (void) AutoGammaImage(image(),exceptionInfo);
1961 ThrowImageException;
1964 void Magick::Image::autoGammaChannel(const ChannelType channel_)
1968 GetAndSetPPChannelMask(channel_);
1969 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1970 (void) AutoGammaImage(image(),exceptionInfo);
1971 RestorePPChannelMask;
1972 ThrowImageException;
1975 void Magick::Image::autoLevel(void)
1979 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1980 (void) AutoLevelImage(image(),exceptionInfo);
1981 ThrowImageException;
1984 void Magick::Image::autoLevelChannel(const ChannelType channel_)
1988 GetAndSetPPChannelMask(channel_);
1989 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1990 (void) AutoLevelImage(image(),exceptionInfo);
1991 RestorePPChannelMask;
1992 ThrowImageException;
1995 void Magick::Image::autoOrient(void)
2000 if (image()->orientation == UndefinedOrientation ||
2001 image()->orientation == TopLeftOrientation)
2005 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2006 newImage=AutoOrientImage(constImage(),image()->orientation,exceptionInfo);
2007 replaceImage(newImage);
2008 ThrowImageException;
2011 void Magick::Image::blackThreshold(const std::string &threshold_)
2015 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2016 ThrowImageException;
2019 void Magick::Image::blackThresholdChannel(const ChannelType channel_,
2020 const std::string &threshold_)
2024 GetAndSetPPChannelMask(channel_);
2025 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2026 RestorePPChannelMask;
2027 ThrowImageException;
2030 void Magick::Image::blueShift(const double factor_)
2036 newImage=BlueShiftImage(constImage(),factor_,exceptionInfo);
2037 replaceImage(newImage);
2038 ThrowImageException;
2041 void Magick::Image::blur(const double radius_,const double sigma_)
2047 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2048 replaceImage(newImage);
2049 ThrowImageException;
2052 void Magick::Image::blurChannel(const ChannelType channel_,
2053 const double radius_,const double sigma_)
2059 GetAndSetPPChannelMask(channel_);
2060 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2061 RestorePPChannelMask;
2062 replaceImage(newImage);
2063 ThrowImageException;
2066 void Magick::Image::border(const Geometry &geometry_)
2072 borderInfo=geometry_;
2075 newImage=BorderImage(constImage(),&borderInfo,image()->compose,
2077 replaceImage(newImage);
2078 ThrowImageException;
2081 void Magick::Image::brightnessContrast(const double brightness_,
2082 const double contrast_)
2086 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2087 ThrowImageException;
2090 void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
2091 const double brightness_,const double contrast_)
2095 GetAndSetPPChannelMask(channel_);
2096 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2097 RestorePPChannelMask;
2098 ThrowImageException;
2101 void Magick::Image::cannyEdge(const double radius_,const double sigma_,
2102 const double lowerPercent_,const double upperPercent_)
2109 newImage=CannyEdgeImage(constImage(),radius_,sigma_,lowerPercent_,
2110 upperPercent_,exceptionInfo);
2111 replaceImage(newImage);
2112 ThrowImageException;
2115 void Magick::Image::channel(const ChannelType channel_)
2121 newImage=SeparateImage(image(),channel_,exceptionInfo);
2122 replaceImage(newImage);
2123 ThrowImageException;
2126 void Magick::Image::charcoal(const double radius_,const double sigma_)
2132 newImage=CharcoalImage(image(),radius_,sigma_,exceptionInfo);
2133 replaceImage(newImage);
2134 ThrowImageException;
2137 void Magick::Image::chop(const Geometry &geometry_)
2146 newImage=ChopImage(image(),&chopInfo,exceptionInfo);
2147 replaceImage(newImage);
2148 ThrowImageException;
2151 void Magick::Image::chromaBluePrimary(const double x_,const double y_)
2154 image()->chromaticity.blue_primary.x=x_;
2155 image()->chromaticity.blue_primary.y=y_;
2158 void Magick::Image::chromaBluePrimary(double *x_,double *y_) const
2160 *x_=constImage()->chromaticity.blue_primary.x;
2161 *y_=constImage()->chromaticity.blue_primary.y;
2164 void Magick::Image::chromaGreenPrimary(const double x_,const double y_)
2167 image()->chromaticity.green_primary.x=x_;
2168 image()->chromaticity.green_primary.y=y_;
2171 void Magick::Image::chromaGreenPrimary(double *x_,double *y_) const
2173 *x_=constImage()->chromaticity.green_primary.x;
2174 *y_=constImage()->chromaticity.green_primary.y;
2177 void Magick::Image::chromaRedPrimary(const double x_,const double y_)
2180 image()->chromaticity.red_primary.x=x_;
2181 image()->chromaticity.red_primary.y=y_;
2184 void Magick::Image::chromaRedPrimary(double *x_,double *y_) const
2186 *x_=constImage()->chromaticity.red_primary.x;
2187 *y_=constImage()->chromaticity.red_primary.y;
2190 void Magick::Image::chromaWhitePoint(const double x_,const double y_)
2193 image()->chromaticity.white_point.x=x_;
2194 image()->chromaticity.white_point.y=y_;
2197 void Magick::Image::chromaWhitePoint(double *x_,double *y_) const
2199 *x_=constImage()->chromaticity.white_point.x;
2200 *y_=constImage()->chromaticity.white_point.y;
2203 void Magick::Image::cdl(const std::string &cdl_)
2207 (void) ColorDecisionListImage(image(),cdl_.c_str(),exceptionInfo);
2208 ThrowImageException;
2211 void Magick::Image::clamp(void)
2215 ClampImage(image(),exceptionInfo);
2216 ThrowImageException;
2219 void Magick::Image::clampChannel(const ChannelType channel_)
2223 GetAndSetPPChannelMask(channel_);
2224 ClampImage(image(),exceptionInfo);
2225 RestorePPChannelMask;
2226 ThrowImageException;
2229 void Magick::Image::clip(void)
2233 ClipImage(image(),exceptionInfo);
2234 ThrowImageException;
2237 void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
2241 ClipImagePath(image(),pathname_.c_str(),(MagickBooleanType) inside_,
2243 ThrowImageException;
2246 void Magick::Image::clut(const Image &clutImage_,
2247 const PixelInterpolateMethod method)
2251 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2252 ThrowImageException;
2255 void Magick::Image::clutChannel(const ChannelType channel_,
2256 const Image &clutImage_,const PixelInterpolateMethod method)
2260 GetAndSetPPChannelMask(channel_);
2261 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2262 RestorePPChannelMask;
2263 ThrowImageException;
2266 void Magick::Image::colorize(const unsigned int alpha_,const Color &penColor_)
2268 colorize(alpha_,alpha_,alpha_,penColor_);
2271 void Magick::Image::colorize(const unsigned int alphaRed_,
2272 const unsigned int alphaGreen_,const unsigned int alphaBlue_,
2273 const Color &penColor_)
2276 blend[MaxTextExtent];
2284 if (!penColor_.isValid())
2285 throwExceptionExplicit(MagickCore::OptionError,
2286 "Pen color argument is invalid");
2288 FormatLocaleString(blend,MaxTextExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
2291 target=static_cast<PixelInfo>(penColor_);
2293 newImage=ColorizeImage(image(),blend,&target,exceptionInfo);
2294 replaceImage(newImage);
2295 ThrowImageException;
2298 void Magick::Image::colorMap(const size_t index_,const Color &color_)
2305 if (index_ > (MaxColormapSize-1))
2306 throwExceptionExplicit(MagickCore::OptionError,
2307 "Colormap index must be less than MaxColormapSize");
2309 if (!color_.isValid())
2310 throwExceptionExplicit(MagickCore::OptionError,
2311 "Color argument is invalid");
2315 // Ensure that colormap size is large enough
2316 if (colorMapSize() < (index_+1))
2317 colorMapSize(index_+1);
2319 // Set color at index in colormap
2320 (imageptr->colormap)[index_]=color_;
2323 Magick::Color Magick::Image::colorMap(const size_t index_) const
2325 if (!constImage()->colormap)
2327 throwExceptionExplicit(MagickCore::OptionError,
2328 "Image does not contain a colormap");
2332 if (index_ > constImage()->colors-1)
2333 throwExceptionExplicit(MagickCore::OptionError,"Index out of range");
2335 return(Magick::Color((constImage()->colormap)[index_]));
2338 void Magick::Image::colorMatrix(const size_t order_,
2339 const double *color_matrix_)
2345 kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2346 if (kernel_info != (KernelInfo *) NULL)
2348 kernel_info->width=order_;
2349 kernel_info->height=order_;
2350 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2351 order_*sizeof(*kernel_info->values));
2352 if (kernel_info->values != (MagickRealType *) NULL)
2357 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2358 kernel_info->values[i]=color_matrix_[i];
2359 newImage=ColorMatrixImage(image(),kernel_info,exceptionInfo);
2360 replaceImage(newImage);
2362 kernel_info=DestroyKernelInfo(kernel_info);
2364 ThrowImageException;
2367 bool Magick::Image::compare(const Image &reference_)
2377 status=static_cast<bool>(IsImagesEqual(image(),ref.constImage(),
2379 ThrowImageException;
2383 double Magick::Image::compare(const Image &reference_,const MetricType metric_)
2389 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2391 ThrowImageException;
2395 double Magick::Image::compareChannel(const ChannelType channel_,
2396 const Image &reference_,const MetricType metric_)
2402 GetAndSetPPChannelMask(channel_);
2403 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2405 RestorePPChannelMask;
2406 ThrowImageException;
2410 Magick::Image Magick::Image::compare(const Image &reference_,
2411 const MetricType metric_,double *distortion)
2417 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2419 ThrowImageException;
2420 if (newImage == (MagickCore::Image *) NULL)
2421 return(Magick::Image());
2423 return(Magick::Image(newImage));
2426 Magick::Image Magick::Image::compareChannel(const ChannelType channel_,
2427 const Image &reference_,const MetricType metric_,double *distortion)
2433 GetAndSetPPChannelMask(channel_);
2434 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2436 RestorePPChannelMask;
2437 ThrowImageException;
2438 if (newImage == (MagickCore::Image *) NULL)
2439 return(Magick::Image());
2441 return(Magick::Image(newImage));
2444 void Magick::Image::composite(const Image &compositeImage_,
2445 const Geometry &offset_,const CompositeOperator compose_)
2455 ParseMetaGeometry(static_cast<std::string>(offset_).c_str(),&x,&y,&width,
2460 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2462 ThrowImageException;
2465 void Magick::Image::composite(const Image &compositeImage_,
2466 const GravityType gravity_,const CompositeOperator compose_)
2472 SetGeometry(compositeImage_.constImage(),&geometry);
2473 GravityAdjustGeometry(columns(),rows(),gravity_,&geometry);
2476 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2477 geometry.x,geometry.y,exceptionInfo);
2478 ThrowImageException;
2481 void Magick::Image::composite(const Image &compositeImage_,
2482 const ssize_t xOffset_,const ssize_t yOffset_,
2483 const CompositeOperator compose_)
2485 // Image supplied as compositeImage is composited with current image and
2486 // results in updating current image.
2489 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2490 xOffset_,yOffset_,exceptionInfo);
2491 ThrowImageException;
2494 void Magick::Image::connectedComponents(const size_t connectivity_)
2500 newImage=ConnectedComponentsImage(constImage(),connectivity_,exceptionInfo);
2501 replaceImage(newImage);
2502 ThrowImageException;
2505 void Magick::Image::contrast(const bool sharpen_)
2509 ContrastImage(image(),(MagickBooleanType) sharpen_,exceptionInfo);
2510 ThrowImageException;
2513 void Magick::Image::contrastStretch(const double blackPoint_,
2514 const double whitePoint_)
2518 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2519 ThrowImageException;
2522 void Magick::Image::contrastStretchChannel(const ChannelType channel_,
2523 const double blackPoint_,const double whitePoint_)
2527 GetAndSetPPChannelMask(channel_);
2528 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2529 RestorePPChannelMask;
2530 ThrowImageException;
2533 void Magick::Image::convolve(const size_t order_,const double *kernel_)
2539 kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2540 kernel_info->width=order_;
2541 kernel_info->height=order_;
2542 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2543 order_*sizeof(*kernel_info->values));
2544 if (kernel_info->values != (MagickRealType *) NULL)
2549 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2550 kernel_info->values[i]=kernel_[i];
2551 newImage=ConvolveImage(image(),kernel_info,exceptionInfo);
2552 replaceImage(newImage);
2554 kernel_info=DestroyKernelInfo(kernel_info);
2555 ThrowImageException;
2558 void Magick::Image::crop(const Geometry &geometry_)
2567 newImage=CropImage(constImage(),&cropInfo,exceptionInfo);
2568 replaceImage(newImage);
2569 ThrowImageException;
2572 void Magick::Image::cycleColormap(const ssize_t amount_)
2576 CycleColormapImage(image(),amount_,exceptionInfo);
2577 ThrowImageException;
2580 void Magick::Image::decipher(const std::string &passphrase_)
2584 DecipherImage(image(),passphrase_.c_str(),exceptionInfo);
2585 ThrowImageException;
2588 void Magick::Image::defineSet(const std::string &magick_,
2589 const std::string &key_,bool flag_)
2595 definition=magick_ + ":" + key_;
2597 (void) SetImageOption(imageInfo(),definition.c_str(),"");
2599 DeleteImageOption(imageInfo(),definition.c_str());
2602 bool Magick::Image::defineSet(const std::string &magick_,
2603 const std::string &key_ ) const
2611 key=magick_ + ":" + key_;
2612 option=GetImageOption(constImageInfo(),key.c_str());
2618 void Magick::Image::defineValue(const std::string &magick_,
2619 const std::string &key_,const std::string &value_)
2626 format=magick_ + ":" + key_;
2628 (void) SetImageOption(imageInfo(),format.c_str(),option.c_str());
2631 std::string Magick::Image::defineValue(const std::string &magick_,
2632 const std::string &key_) const
2640 definition=magick_ + ":" + key_;
2641 option=GetImageOption(constImageInfo(),definition.c_str());
2643 return(std::string(option));
2644 return(std::string());
2647 void Magick::Image::deskew(const double threshold_)
2653 newImage=DeskewImage(constImage(),threshold_,exceptionInfo);
2654 replaceImage(newImage);
2655 ThrowImageException;
2658 void Magick::Image::despeckle(void)
2664 newImage=DespeckleImage(constImage(),exceptionInfo);
2665 replaceImage(newImage);
2666 ThrowImageException;
2669 Magick::ImageType Magick::Image::determineType(void) const
2675 image_type=GetImageType(constImage(),exceptionInfo);
2676 ThrowImageException;
2680 void Magick::Image::display(void)
2683 DisplayImages(imageInfo(),image(),exceptionInfo);
2684 ThrowImageException;
2687 void Magick::Image::distort(const DistortImageMethod method_,
2688 const size_t numberArguments_,const double *arguments_,const bool bestfit_)
2694 newImage=DistortImage(constImage(), method_,numberArguments_,arguments_,
2695 bestfit_ == true ? MagickTrue : MagickFalse,exceptionInfo);
2696 replaceImage(newImage);
2697 ThrowImageException;
2700 void Magick::Image::draw(const Magick::Drawable &drawable_)
2707 wand=DrawAllocateWand(options()->drawInfo(),image());
2711 drawable_.operator()(wand);
2715 ClonePPDrawException(wand);
2716 wand=DestroyDrawingWand(wand);
2717 ThrowPPDrawException(quiet());
2721 void Magick::Image::draw(const std::vector<Magick::Drawable> &drawable_)
2728 wand=DrawAllocateWand(options()->drawInfo(),image());
2732 for (std::vector<Magick::Drawable>::const_iterator p = drawable_.begin();
2733 p != drawable_.end(); p++ )
2735 p->operator()(wand);
2736 if (DrawGetExceptionType(wand) != MagickCore::UndefinedException)
2740 if (DrawGetExceptionType(wand) == MagickCore::UndefinedException)
2743 ClonePPDrawException(wand);
2744 wand=DestroyDrawingWand(wand);
2745 ThrowPPDrawException(quiet());
2749 void Magick::Image::edge(const double radius_)
2755 newImage=EdgeImage(constImage(),radius_,exceptionInfo);
2756 replaceImage(newImage);
2757 ThrowImageException;
2760 void Magick::Image::emboss(const double radius_,const double sigma_)
2766 newImage=EmbossImage(constImage(),radius_,sigma_,exceptionInfo);
2767 replaceImage(newImage);
2768 ThrowImageException;
2771 void Magick::Image::encipher(const std::string &passphrase_)
2775 EncipherImage(image(),passphrase_.c_str(),exceptionInfo);
2776 ThrowImageException;
2779 void Magick::Image::enhance(void)
2785 newImage=EnhanceImage(constImage(),exceptionInfo);
2786 replaceImage(newImage);
2787 ThrowImageException;
2790 void Magick::Image::equalize(void)
2794 EqualizeImage(image(),exceptionInfo);
2795 ThrowImageException;
2798 void Magick::Image::erase(void)
2802 (void) SetImageBackgroundColor(image(),exceptionInfo);
2803 ThrowImageException;
2806 void Magick::Image::extent(const Geometry &geometry_ )
2812 extentInfo=geometry_;
2815 extentInfo.x=geometry_.xOff();
2816 extentInfo.y=geometry_.yOff();
2818 newImage=ExtentImage(image(),&extentInfo,exceptionInfo);
2819 replaceImage(newImage);
2820 ThrowImageException;
2823 void Magick::Image::extent(const Geometry &geometry_,
2824 const Color &backgroundColor_)
2826 backgroundColor(backgroundColor_);
2830 void Magick::Image::extent(const Geometry &geometry_,
2831 const Color &backgroundColor_,const GravityType gravity_)
2833 backgroundColor(backgroundColor_);
2834 extent(geometry_,gravity_);
2837 void Magick::Image::extent(const Geometry &geometry_,
2838 const GravityType gravity_)
2843 SetGeometry(image(),&geometry);
2844 geometry.width=geometry_.width();
2845 geometry.height=geometry_.height();
2846 GravityAdjustGeometry(image()->columns,image()->rows,gravity_,&geometry);
2850 void Magick::Image::flip(void)
2856 newImage=FlipImage(constImage(),exceptionInfo);
2857 replaceImage(newImage);
2858 ThrowImageException;
2861 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2862 const unsigned int alpha_,const bool invert_)
2869 target=static_cast<PixelInfo>(pixelColor(x_,y_));
2870 target.alpha=alpha_;
2872 GetAndSetPPChannelMask(AlphaChannel);
2873 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2874 (MagickBooleanType)invert_,exceptionInfo);
2875 RestorePPChannelMask;
2876 ThrowImageException;
2879 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2880 const unsigned int alpha_,const Color &target_,const bool invert_)
2887 target=static_cast<PixelInfo>(target_);
2888 target.alpha=alpha_;
2890 GetAndSetPPChannelMask(AlphaChannel);
2891 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2892 (MagickBooleanType)invert_,exceptionInfo);
2893 RestorePPChannelMask;
2894 ThrowImageException;
2897 void Magick::Image::floodFillColor(const Geometry &point_,
2898 const Magick::Color &fillColor_,const bool invert_)
2900 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,invert_);
2903 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2904 const Magick::Color &fillColor_,const bool invert_)
2911 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2912 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2915 void Magick::Image::floodFillColor(const Geometry &point_,
2916 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2919 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,borderColor_,invert_);
2922 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2923 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2931 pixel=static_cast<PixelInfo>(borderColor_);
2932 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2935 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2936 const Magick::Image &texture_,const bool invert_)
2938 floodFillTexture(point_.xOff(),point_.yOff(),texture_,invert_);
2941 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2942 const Magick::Image &texture_,const bool invert_)
2949 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2950 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
2953 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2954 const Magick::Image &texture_,const Magick::Color &borderColor_,
2957 floodFillTexture(point_.xOff(),point_.yOff(),texture_,borderColor_,invert_);
2960 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2961 const Magick::Image &texture_,const Magick::Color &borderColor_,
2969 pixel=static_cast<PixelInfo>(borderColor_);
2970 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
2973 void Magick::Image::flop(void)
2979 newImage=FlopImage(constImage(),exceptionInfo);
2980 replaceImage(newImage);
2981 ThrowImageException;
2984 void Magick::Image::fontTypeMetrics(const std::string &text_,
2985 TypeMetric *metrics)
2990 drawInfo=options()->drawInfo();
2991 drawInfo->text=const_cast<char *>(text_.c_str());
2993 GetTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
2995 ThrowImageException;
2998 void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
2999 TypeMetric *metrics)
3004 drawInfo=options()->drawInfo();
3005 drawInfo->text=const_cast<char *>(text_.c_str());
3007 GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3009 ThrowImageException;
3012 void Magick::Image::frame(const Geometry &geometry_)
3020 info.x=static_cast<ssize_t>(geometry_.width());
3021 info.y=static_cast<ssize_t>(geometry_.height());
3022 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3023 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3024 info.outer_bevel=geometry_.xOff();
3025 info.inner_bevel=geometry_.yOff();
3028 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3029 replaceImage(newImage);
3030 ThrowImageException;
3033 void Magick::Image::frame(const size_t width_,const size_t height_,
3034 const ssize_t innerBevel_,const ssize_t outerBevel_)
3042 info.x=static_cast<ssize_t>(width_);
3043 info.y=static_cast<ssize_t>(height_);
3044 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3045 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3046 info.outer_bevel=static_cast<ssize_t>(outerBevel_);
3047 info.inner_bevel=static_cast<ssize_t>(innerBevel_);
3050 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3051 replaceImage(newImage);
3052 ThrowImageException;
3055 void Magick::Image::fx(const std::string expression_)
3061 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3062 replaceImage(newImage);
3063 ThrowImageException;
3066 void Magick::Image::fx(const std::string expression_,
3067 const Magick::ChannelType channel_)
3073 GetAndSetPPChannelMask(channel_);
3074 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3075 RestorePPChannelMask;
3076 replaceImage(newImage);
3077 ThrowImageException;
3080 void Magick::Image::gamma(const double gamma_)
3084 GammaImage(image(),gamma_,exceptionInfo);
3085 ThrowImageException;
3088 void Magick::Image::gamma(const double gammaRed_,const double gammaGreen_,
3089 const double gammaBlue_)
3093 GetAndSetPPChannelMask(RedChannel);
3094 (void) GammaImage(image(),gammaRed_,exceptionInfo);
3095 SetPPChannelMask(GreenChannel);
3096 (void) GammaImage(image(),gammaGreen_,exceptionInfo);
3097 SetPPChannelMask(BlueChannel);
3098 (void) GammaImage(image(),gammaBlue_,exceptionInfo);
3099 RestorePPChannelMask;
3100 ThrowImageException;
3103 void Magick::Image::gaussianBlur(const double width_,const double sigma_)
3109 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3110 replaceImage(newImage);
3111 ThrowImageException;
3114 void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
3115 const double width_,const double sigma_)
3121 GetAndSetPPChannelMask(channel_);
3122 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3123 RestorePPChannelMask;
3124 replaceImage(newImage);
3125 ThrowImageException;
3128 const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
3129 const ssize_t y_,const size_t columns_,const size_t rows_) const
3135 p=(*GetVirtualPixels)(constImage(),x_, y_,columns_, rows_,exceptionInfo);
3136 ThrowImageException;
3140 const void *Magick::Image::getConstMetacontent(void) const
3145 result=GetVirtualMetacontent(constImage());
3148 throwExceptionExplicit(MagickCore::OptionError,
3149 "Unable to retrieve meta content.");
3154 void *Magick::Image::getMetacontent(void )
3159 result=GetAuthenticMetacontent(image());
3162 throwExceptionExplicit(MagickCore::OptionError,
3163 "Unable to retrieve meta content.");
3168 Magick::Quantum *Magick::Image::getPixels(const ssize_t x_,const ssize_t y_,
3169 const size_t columns_,const size_t rows_)
3176 result=(*GetAuthenticPixels)(image(),x_, y_,columns_,rows_,exceptionInfo);
3177 ThrowImageException;
3182 void Magick::Image::grayscale(const PixelIntensityMethod method_)
3186 (void) GrayscaleImage(image(),method_,exceptionInfo);
3187 ThrowImageException;
3190 void Magick::Image::haldClut(const Image &clutImage_)
3194 (void) HaldClutImage(image(),clutImage_.constImage(),exceptionInfo);
3195 ThrowImageException;
3198 void Magick::Image::houghLine(const size_t width_,const size_t height_,
3199 const size_t threshold_)
3205 newImage=HoughLineImage(constImage(),width_,height_,threshold_,
3207 replaceImage(newImage);
3208 ThrowImageException;
3211 void Magick::Image::implode(const double factor_)
3217 newImage=ImplodeImage(constImage(),factor_,image()->interpolate,
3219 replaceImage(newImage);
3220 ThrowImageException;
3223 void Magick::Image::inverseFourierTransform(const Image &phase_)
3225 inverseFourierTransform(phase_,true);
3228 void Magick::Image::inverseFourierTransform(const Image &phase_,
3229 const bool magnitude_)
3235 newImage=InverseFourierTransformImage(constImage(),phase_.constImage(),
3236 magnitude_ == true ? MagickTrue : MagickFalse,exceptionInfo);
3237 replaceImage(newImage);
3238 ThrowImageException;
3241 void Magick::Image::kuwahara(const double radius_,const double sigma_)
3247 newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3248 replaceImage(newImage);
3249 ThrowImageException;
3252 void Magick::Image::kuwaharaChannel(const ChannelType channel_,
3253 const double radius_,const double sigma_)
3259 GetAndSetPPChannelMask(channel_);
3260 newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3261 replaceImage(newImage);
3262 RestorePPChannelMask;
3263 ThrowImageException;
3266 void Magick::Image::level(const double blackPoint_,const double whitePoint_,
3267 const double gamma_)
3271 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3272 ThrowImageException;
3275 void Magick::Image::levelChannel(const ChannelType channel_,
3276 const double blackPoint_,const double whitePoint_,const double gamma_)
3280 GetAndSetPPChannelMask(channel_);
3281 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3282 RestorePPChannelMask;
3283 ThrowImageException;
3286 void Magick::Image::levelColors(const Color &blackColor_,
3287 const Color &whiteColor_,const bool invert_)
3295 black=static_cast<PixelInfo>(blackColor_);
3296 white=static_cast<PixelInfo>(whiteColor_);
3298 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3299 MagickTrue : MagickFalse,exceptionInfo);
3300 ThrowImageException;
3303 void Magick::Image::levelColorsChannel(const ChannelType channel_,
3304 const Color &blackColor_,const Color &whiteColor_,const bool invert_)
3312 black=static_cast<PixelInfo>(blackColor_);
3313 white=static_cast<PixelInfo>(whiteColor_);
3315 GetAndSetPPChannelMask(channel_);
3316 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3317 MagickTrue : MagickFalse,exceptionInfo);
3318 RestorePPChannelMask;
3319 ThrowImageException;
3322 void Magick::Image::linearStretch(const double blackPoint_,
3323 const double whitePoint_)
3327 LinearStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
3328 ThrowImageException;
3331 void Magick::Image::liquidRescale(const Geometry &geometry_)
3344 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3348 newImage=LiquidRescaleImage(image(),width,height,x,y,exceptionInfo);
3349 replaceImage(newImage);
3350 ThrowImageException;
3353 void Magick::Image::magnify(void)
3359 newImage=MagnifyImage(constImage(),exceptionInfo);
3360 replaceImage(newImage);
3361 ThrowImageException;
3364 void Magick::Image::map(const Image &mapImage_,const bool dither_)
3368 options()->quantizeDither(dither_);
3369 RemapImage(options()->quantizeInfo(),image(),mapImage_.constImage(),
3371 ThrowImageException;
3374 void Magick::Image::medianFilter(const double radius_)
3380 newImage=StatisticImage(image(),MedianStatistic,(size_t) radius_,
3381 (size_t) radius_,exceptionInfo);
3382 replaceImage(newImage);
3383 ThrowImageException;
3386 void Magick::Image::minify(void)
3392 newImage=MinifyImage(constImage(),exceptionInfo);
3393 replaceImage(newImage);
3394 ThrowImageException;
3397 void Magick::Image::modulate(const double brightness_,const double saturation_,
3401 modulate[MaxTextExtent + 1];
3403 FormatLocaleString(modulate,MaxTextExtent,"%3.6f,%3.6f,%3.6f",brightness_,
3408 ModulateImage(image(),modulate,exceptionInfo);
3409 ThrowImageException;
3412 Magick::ImageMoments Magick::Image::moments(void) const
3414 return(ImageMoments(*this));
3417 void Magick::Image::morphology(const MorphologyMethod method_,
3418 const std::string kernel_,const ssize_t iterations_)
3427 kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3428 if (kernel == (KernelInfo *) NULL)
3429 throwExceptionExplicit(MagickCore::OptionError,"Unable to parse kernel.");
3430 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3432 replaceImage(newImage);
3433 kernel=DestroyKernelInfo(kernel);
3434 ThrowImageException;
3437 void Magick::Image::morphology(const MorphologyMethod method_,
3438 const KernelInfoType kernel_,const std::string arguments_,
3439 const ssize_t iterations_)
3447 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3448 if (option == (const char *)NULL)
3449 throwExceptionExplicit(MagickCore::OptionError,
3450 "Unable to determine kernel type.");
3452 kernel=std::string(option);
3453 if (!arguments_.empty())
3454 kernel+=":"+arguments_;
3456 morphology(method_,kernel,iterations_);
3459 void Magick::Image::morphologyChannel(const ChannelType channel_,
3460 const MorphologyMethod method_,const std::string kernel_,
3461 const ssize_t iterations_)
3471 kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3472 if (kernel == (KernelInfo *)NULL)
3474 throwExceptionExplicit(MagickCore::OptionError,
3475 "Unable to parse kernel.");
3478 GetAndSetPPChannelMask(channel_);
3479 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3481 RestorePPChannelMask;
3482 replaceImage(newImage);
3483 kernel=DestroyKernelInfo(kernel);
3484 ThrowImageException;
3487 void Magick::Image::morphologyChannel(const ChannelType channel_,
3488 const MorphologyMethod method_,const KernelInfoType kernel_,
3489 const std::string arguments_,const ssize_t iterations_)
3497 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3498 if (option == (const char *)NULL)
3500 throwExceptionExplicit(MagickCore::OptionError,
3501 "Unable to determine kernel type.");
3505 kernel=std::string(option);
3506 if (!arguments_.empty())
3507 kernel+=":"+arguments_;
3509 morphologyChannel(channel_,method_,kernel,iterations_);
3512 void Magick::Image::motionBlur(const double radius_,const double sigma_,
3513 const double angle_)
3519 newImage=MotionBlurImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
3520 replaceImage(newImage);
3521 ThrowImageException;
3524 void Magick::Image::negate(const bool grayscale_)
3528 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3529 ThrowImageException;
3532 void Magick::Image::negateChannel(const ChannelType channel_,
3533 const bool grayscale_)
3537 GetAndSetPPChannelMask(channel_);
3538 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3539 RestorePPChannelMask;
3540 ThrowImageException;
3543 void Magick::Image::normalize(void)
3547 NormalizeImage(image(),exceptionInfo);
3548 ThrowImageException;
3551 void Magick::Image::oilPaint(const double radius_,const double sigma_)
3557 newImage=OilPaintImage(constImage(),radius_,sigma_,exceptionInfo);
3558 replaceImage(newImage);
3559 ThrowImageException;
3562 void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_,
3573 if (!opaqueColor_.isValid())
3574 throwExceptionExplicit(MagickCore::OptionError,
3575 "Opaque color argument is invalid");
3577 if (!penColor_.isValid())
3578 throwExceptionExplicit(MagickCore::OptionError,
3579 "Pen color argument is invalid");
3582 opaqueColor=opaqueColor_;
3586 (void) QueryColorCompliance(opaqueColor.c_str(),AllCompliance,&opaque,
3588 (void) QueryColorCompliance(penColor.c_str(),AllCompliance,&pen,
3590 OpaquePaintImage(image(),&opaque,&pen,invert_ ? MagickTrue : MagickFalse,
3592 ThrowImageException;
3595 void Magick::Image::orderedDither(std::string thresholdMap_)
3599 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3600 ThrowImageException;
3603 void Magick::Image::orderedDitherChannel(const ChannelType channel_,
3604 std::string thresholdMap_)
3608 GetAndSetPPChannelMask(channel_);
3609 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3610 RestorePPChannelMask;
3611 ThrowImageException;
3614 void Magick::Image::perceptible(const double epsilon_)
3618 PerceptibleImage(image(),epsilon_,exceptionInfo);
3619 ThrowImageException;
3622 void Magick::Image::perceptibleChannel(const ChannelType channel_,
3623 const double epsilon_)
3627 GetAndSetPPChannelMask(channel_);
3628 PerceptibleImage(image(),epsilon_,exceptionInfo);
3629 RestorePPChannelMask;
3630 ThrowImageException;
3633 Magick::ImagePerceptualHash Magick::Image::perceptualHash() const
3635 return(ImagePerceptualHash(*this));
3638 void Magick::Image::ping(const std::string &imageSpec_)
3644 options()->fileName(imageSpec_);
3645 newImage=PingImage(imageInfo(),exceptionInfo);
3646 read(newImage,exceptionInfo);
3649 void Magick::Image::ping(const Blob& blob_)
3655 newImage=PingBlob(imageInfo(),blob_.data(),blob_.length(),exceptionInfo);
3656 read(newImage,exceptionInfo);
3659 void Magick::Image::pixelColor(const ssize_t x_,const ssize_t y_,
3660 const Color &color_)
3668 // Test arguments to ensure they are within the image.
3669 if (y_ > (ssize_t) rows() || x_ > (ssize_t) columns())
3670 throwExceptionExplicit(MagickCore::OptionError,
3671 "Access outside of image boundary");
3675 // Set image to DirectClass
3676 classType(DirectClass );
3679 Pixels pixels(*this);
3681 pixel=pixels.get(x_, y_, 1, 1 );
3683 MagickCore::SetPixelViaPixelInfo(constImage(),&packet,pixel);
3684 // Tell ImageMagick that pixels have been updated
3688 Magick::Color Magick::Image::pixelColor(const ssize_t x_,
3689 const ssize_t y_) const
3694 pixel=getConstPixels(x_,y_,1,1);
3700 MagickCore::GetPixelInfoPixel(constImage(),pixel,&packet);
3701 return(Color(packet));
3704 return(Color()); // invalid
3707 void Magick::Image::polaroid(const std::string &caption_,const double angle_,
3708 const PixelInterpolateMethod method_)
3714 newImage=PolaroidImage(constImage(),options()->drawInfo(),caption_.c_str(),
3715 angle_,method_,exceptionInfo);
3716 replaceImage(newImage);
3717 ThrowImageException;
3720 void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
3724 PosterizeImage(image(),levels_,method_,exceptionInfo);
3725 ThrowImageException;
3728 void Magick::Image::posterizeChannel(const ChannelType channel_,
3729 const size_t levels_,const DitherMethod method_)
3733 GetAndSetPPChannelMask(channel_);
3734 PosterizeImage(image(),levels_,method_,exceptionInfo);
3735 RestorePPChannelMask;
3736 ThrowImageException;
3739 void Magick::Image::process(std::string name_,const ssize_t argc,
3745 (void) InvokeDynamicImageFilter(name_.c_str(),&image(),argc,argv,
3747 ThrowImageException;
3750 void Magick::Image::profile(const std::string name_,
3751 const Magick::Blob &profile_)
3755 (void) ProfileImage(image(),name_.c_str(),(unsigned char *)profile_.data(),
3756 profile_.length(),exceptionInfo);
3757 ThrowImageException;
3760 Magick::Blob Magick::Image::profile(const std::string name_) const
3765 profile=GetImageProfile(constImage(),name_.c_str());
3767 if (profile == (StringInfo *) NULL)
3769 return(Blob((void*) GetStringInfoDatum(profile),GetStringInfoLength(
3773 void Magick::Image::quantize(const bool measureError_)
3778 options()->quantizeInfo()->measure_error=MagickTrue;
3780 options()->quantizeInfo()->measure_error=MagickFalse;
3783 QuantizeImage(options()->quantizeInfo(),image(),exceptionInfo);
3784 ThrowImageException;
3787 void Magick::Image::quantumOperator(const ChannelType channel_,
3788 const MagickEvaluateOperator operator_,double rvalue_)
3791 GetAndSetPPChannelMask(channel_);
3792 EvaluateImage(image(),operator_,rvalue_,exceptionInfo);
3793 RestorePPChannelMask;
3794 ThrowImageException;
3797 void Magick::Image::quantumOperator(const ssize_t x_,const ssize_t y_,
3798 const size_t columns_,const size_t rows_,const ChannelType channel_,
3799 const MagickEvaluateOperator operator_,const double rvalue_)
3807 geometry.width = columns_;
3808 geometry.height = rows_;
3813 cropImage=CropImage(image(),&geometry,exceptionInfo);
3814 GetAndSetPPChannelMask(channel_);
3815 EvaluateImage(cropImage,operator_,rvalue_,exceptionInfo);
3816 RestorePPChannelMask;
3817 (void) CompositeImage(image(),cropImage,image()->alpha_trait ==
3818 BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
3819 geometry.x,geometry.y,exceptionInfo );
3820 cropImage=DestroyImageList(cropImage);
3821 ThrowImageException;
3824 void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
3827 raiseInfo=geometry_;
3831 RaiseImage(image(),&raiseInfo,raisedFlag_ == true ? MagickTrue : MagickFalse,
3833 ThrowImageException;
3836 void Magick::Image::randomThreshold(const Geometry &thresholds_)
3839 (void) RandomThresholdImage(image(),static_cast<std::string>(
3840 thresholds_).c_str(),exceptionInfo);
3841 ThrowImageException;
3844 void Magick::Image::randomThresholdChannel(const ChannelType channel_,
3845 const Geometry &thresholds_)
3849 GetAndSetPPChannelMask(channel_);
3850 (void) RandomThresholdImage(image(),static_cast<std::string>(
3851 thresholds_).c_str(),exceptionInfo);
3852 RestorePPChannelMask;
3853 ThrowImageException;
3856 void Magick::Image::read(const Blob &blob_)
3862 newImage=BlobToImage(imageInfo(),static_cast<const void *>(blob_.data()),
3863 blob_.length(),exceptionInfo);
3864 read(newImage,exceptionInfo);
3867 void Magick::Image::read(const Blob &blob_,const Geometry &size_)
3873 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3874 const size_t depth_)
3881 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3882 const size_t depth_,const std::string &magick_)
3887 // Set explicit image format
3888 fileName(magick_ + ':');
3892 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3893 const std::string &magick_)
3897 // Set explicit image format
3898 fileName(magick_ + ':');
3902 void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_)
3908 void Magick::Image::read(const size_t width_,const size_t height_,
3909 const std::string &map_,const StorageType type_,const void *pixels_)
3915 newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
3917 replaceImage(newImage);
3918 ThrowImageException;
3921 void Magick::Image::read(const std::string &imageSpec_)
3927 options()->fileName(imageSpec_);
3928 newImage=ReadImage(imageInfo(),exceptionInfo);
3929 read(newImage,exceptionInfo);
3932 void Magick::Image::readPixels(const Magick::QuantumType quantum_,
3933 const unsigned char *source_)
3938 quantum_info=AcquireQuantumInfo(imageInfo(),image());
3940 ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
3941 quantum_,source_,exceptionInfo);
3942 quantum_info=DestroyQuantumInfo(quantum_info);
3943 ThrowImageException;
3946 void Magick::Image::reduceNoise(void)
3951 void Magick::Image::reduceNoise(const double order_)
3957 newImage=StatisticImage(constImage(),NonpeakStatistic,(size_t) order_,
3958 (size_t) order_,exceptionInfo);
3959 replaceImage(newImage);
3960 ThrowImageException;
3963 void Magick::Image::repage()
3966 options()->page(Geometry());
3967 image()->page.width = 0;
3968 image()->page.height = 0;
3969 image()->page.x = 0;
3970 image()->page.y = 0;
3973 void Magick::Image::resample(const Point &density_)
3979 newImage=ResampleImage(constImage(),density_.x(),density_.y(),
3980 image()->filter,exceptionInfo);
3981 replaceImage(newImage);
3982 ThrowImageException;
3985 void Magick::Image::resize(const Geometry &geometry_)
3998 // Calculate new size. This code should be supported using binary arguments
3999 // in the ImageMagick library.
4000 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4004 newImage=ResizeImage(constImage(),width,height,image()->filter,
4006 replaceImage(newImage);
4007 ThrowImageException;
4010 void Magick::Image::roll(const Geometry &roll_)
4016 newImage=RollImage(constImage(),roll_.xOff(),roll_.yOff(),exceptionInfo);
4017 replaceImage(newImage);
4018 ThrowImageException;
4021 void Magick::Image::roll(const size_t columns_,const size_t rows_)
4027 newImage=RollImage(constImage(),static_cast<ssize_t>(columns_),
4028 static_cast<ssize_t>(rows_),exceptionInfo);
4029 replaceImage(newImage);
4030 ThrowImageException;
4033 void Magick::Image::rotate(const double degrees_)
4039 newImage=RotateImage(constImage(),degrees_,exceptionInfo);
4040 replaceImage(newImage);
4041 ThrowImageException;
4044 void Magick::Image::rotationalBlur(const double angle_)
4050 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4051 replaceImage(newImage);
4052 ThrowImageException;
4055 void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
4056 const double angle_)
4062 GetAndSetPPChannelMask(channel_);
4063 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4064 RestorePPChannelMask;
4065 replaceImage(newImage);
4066 ThrowImageException;
4069 void Magick::Image::sample(const Geometry &geometry_)
4082 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4086 newImage=SampleImage(constImage(),width,height,exceptionInfo);
4087 replaceImage(newImage);
4088 ThrowImageException;
4091 void Magick::Image::scale(const Geometry &geometry_)
4104 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4108 newImage=ScaleImage(constImage(),width,height,exceptionInfo);
4109 replaceImage(newImage);
4110 ThrowImageException;
4113 void Magick::Image::segment(const double clusterThreshold_,
4114 const double smoothingThreshold_)
4118 SegmentImage(image(),options()->quantizeColorSpace(),
4119 (MagickBooleanType) options()->verbose(),clusterThreshold_,
4120 smoothingThreshold_,exceptionInfo);
4121 SyncImage(image(),exceptionInfo);
4122 ThrowImageException;
4125 void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
4126 const double threshold_)
4132 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4134 replaceImage(newImage);
4135 ThrowImageException;
4138 void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
4139 const double radius_,const double sigma_,const double threshold_)
4145 GetAndSetPPChannelMask(channel_);
4146 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4148 RestorePPChannelMask;
4149 replaceImage(newImage);
4150 ThrowImageException;
4153 Magick::Image Magick::Image::separate(const ChannelType channel_) const
4159 image=SeparateImage(constImage(),channel_,exceptionInfo);
4160 ThrowImageException;
4161 if (image == (MagickCore::Image *) NULL)
4162 return(Magick::Image());
4164 return(Magick::Image(image));
4167 void Magick::Image::sepiaTone(const double threshold_)
4173 newImage=SepiaToneImage(constImage(),threshold_,exceptionInfo);
4174 replaceImage(newImage);
4175 ThrowImageException;
4178 Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
4179 const size_t columns_,const size_t rows_)
4186 result=(*QueueAuthenticPixels)(image(),x_,y_,columns_,rows_,exceptionInfo);
4187 ThrowImageException;
4191 void Magick::Image::shade(const double azimuth_,const double elevation_,
4192 const bool colorShading_)
4198 newImage=ShadeImage(constImage(),colorShading_ == true ?
4199 MagickTrue : MagickFalse,azimuth_,elevation_,exceptionInfo);
4200 replaceImage(newImage);
4201 ThrowImageException;
4204 void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
4205 const ssize_t x_,const ssize_t y_)
4211 newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
4213 replaceImage(newImage);
4214 ThrowImageException;
4217 void Magick::Image::sharpen(const double radius_,const double sigma_)
4223 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4224 replaceImage(newImage);
4225 ThrowImageException;
4228 void Magick::Image::sharpenChannel(const ChannelType channel_,
4229 const double radius_,const double sigma_)
4235 GetAndSetPPChannelMask(channel_);
4236 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4237 RestorePPChannelMask;
4238 replaceImage(newImage);
4239 ThrowImageException;
4242 void Magick::Image::shave(const Geometry &geometry_)
4248 shaveInfo=geometry_;
4251 newImage=ShaveImage(constImage(),&shaveInfo,exceptionInfo);
4252 replaceImage(newImage);
4253 ThrowImageException;
4256 void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
4262 newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,exceptionInfo);
4263 replaceImage(newImage);
4264 ThrowImageException;
4267 void Magick::Image::sigmoidalContrast(const size_t sharpen_,
4268 const double contrast,const double midpoint)
4272 (void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
4273 midpoint,exceptionInfo);
4274 ThrowImageException;
4277 std::string Magick::Image::signature(const bool force_) const
4279 return(_imgRef->signature());
4282 void Magick::Image::sketch(const double radius_,const double sigma_,
4283 const double angle_)
4289 newImage=SketchImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
4290 replaceImage(newImage);
4291 ThrowImageException;
4294 void Magick::Image::solarize(const double factor_)
4298 SolarizeImage(image(),factor_,exceptionInfo);
4299 ThrowImageException;
4302 void Magick::Image::sparseColor(const ChannelType channel_,
4303 const SparseColorMethod method_,const size_t numberArguments_,
4304 const double *arguments_)
4310 GetAndSetPPChannelMask(channel_);
4311 newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
4313 RestorePPChannelMask;
4314 replaceImage(newImage);
4315 ThrowImageException;
4318 void Magick::Image::splice(const Geometry &geometry_)
4324 spliceInfo=geometry_;
4327 newImage=SpliceImage(constImage(),&spliceInfo,exceptionInfo);
4328 replaceImage(newImage);
4329 ThrowImageException;
4332 void Magick::Image::spread(const size_t amount_)
4338 newImage=SpreadImage(constImage(),amount_,image()->interpolate,
4340 replaceImage(newImage);
4341 ThrowImageException;
4344 Magick::ImageStatistics Magick::Image::statistics() const
4346 return(ImageStatistics(*this));
4349 void Magick::Image::stegano(const Image &watermark_)
4355 newImage=SteganoImage(constImage(),watermark_.constImage(),exceptionInfo);
4356 replaceImage(newImage);
4357 ThrowImageException;
4360 void Magick::Image::stereo(const Image &rightImage_)
4366 newImage=StereoImage(constImage(),rightImage_.constImage(),exceptionInfo);
4367 replaceImage(newImage);
4368 ThrowImageException;
4371 void Magick::Image::strip(void)
4375 StripImage(image(),exceptionInfo);
4376 ThrowImageException;
4379 Magick::Image Magick::Image::subImageSearch(const Image &reference_,
4380 const MetricType metric_,Geometry *offset_,double *similarityMetric_,
4381 const double similarityThreshold)
4390 newImage=SimilarityImage(image(),reference_.constImage(),metric_,
4391 similarityThreshold,&offset,similarityMetric_,exceptionInfo);
4392 ThrowImageException;
4393 if (offset_ != (Geometry *) NULL)
4395 if (newImage == (MagickCore::Image *) NULL)
4396 return(Magick::Image());
4398 return(Magick::Image(newImage));
4401 void Magick::Image::swirl(const double degrees_)
4407 newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
4409 replaceImage(newImage);
4410 ThrowImageException;
4413 void Magick::Image::syncPixels(void)
4416 (void) (*SyncAuthenticPixels)(image(),exceptionInfo);
4417 ThrowImageException;
4420 void Magick::Image::texture(const Image &texture_)
4424 TextureImage(image(),texture_.constImage(),exceptionInfo);
4425 ThrowImageException;
4428 void Magick::Image::threshold(const double threshold_)
4432 BilevelImage(image(),threshold_,exceptionInfo);
4433 ThrowImageException;
4436 void Magick::Image::thumbnail(const Geometry &geometry_)
4449 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4453 newImage=ThumbnailImage(constImage(),width,height,exceptionInfo);
4454 replaceImage(newImage);
4455 ThrowImageException;
4458 void Magick::Image::tint(const std::string opacity_)
4467 color=static_cast<PixelInfo>(constOptions()->fillColor());
4468 newImage=TintImage(constImage(),opacity_.c_str(),&color,exceptionInfo);
4469 replaceImage(newImage);
4470 ThrowImageException;
4473 void Magick::Image::transform(const Geometry &imageGeometry_)
4477 TransformImage(&(image()),0,std::string(imageGeometry_).c_str(),
4479 ThrowImageException;
4482 void Magick::Image::transform(const Geometry &imageGeometry_,
4483 const Geometry &cropGeometry_)
4487 TransformImage(&(image()),std::string(cropGeometry_).c_str(),std::string(
4488 imageGeometry_).c_str(), exceptionInfo);
4489 ThrowImageException;
4492 void Magick::Image::transformOrigin(const double x_,const double y_)
4495 options()->transformOrigin(x_,y_);
4498 void Magick::Image::transformReset(void)
4501 options()->transformReset();
4504 void Magick::Image::transformScale(const double sx_,const double sy_)
4507 options()->transformScale(sx_,sy_);
4510 void Magick::Image::transparent(const Color &color_)
4518 if (!color_.isValid())
4519 throwExceptionExplicit(MagickCore::OptionError,
4520 "Color argument is invalid");
4524 (void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
4527 TransparentPaintImage(image(),&target,TransparentAlpha,MagickFalse,
4529 ThrowImageException;
4532 void Magick::Image::transparentChroma(const Color &colorLow_,
4533 const Color &colorHigh_)
4543 if (!colorLow_.isValid() || !colorHigh_.isValid())
4544 throwExceptionExplicit(MagickCore::OptionError,
4545 "Color argument is invalid");
4548 colorHigh=colorHigh_;
4551 (void) QueryColorCompliance(colorLow.c_str(),AllCompliance,&targetLow,
4553 (void) QueryColorCompliance(colorHigh.c_str(),AllCompliance,&targetHigh,
4556 TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
4557 MagickFalse,exceptionInfo);
4558 ThrowImageException;
4561 void Magick::Image::transpose(void)
4567 newImage=TransposeImage(constImage(),exceptionInfo);
4568 replaceImage(newImage);
4569 ThrowImageException;
4572 void Magick::Image::transverse(void)
4578 newImage=TransverseImage(constImage(),exceptionInfo);
4579 replaceImage(newImage);
4580 ThrowImageException;
4583 void Magick::Image::trim(void)
4589 newImage=TrimImage(constImage(),exceptionInfo);
4590 replaceImage(newImage);
4591 ThrowImageException;
4594 Magick::Image Magick::Image::uniqueColors(void) const
4600 image=UniqueImageColors(constImage(),exceptionInfo);
4601 ThrowImageException;
4602 if (image == (MagickCore::Image *) NULL)
4603 return(Magick::Image());
4605 return(Magick::Image(image));
4608 void Magick::Image::unsharpmask(const double radius_,const double sigma_,
4609 const double amount_,const double threshold_)
4615 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4617 replaceImage(newImage);
4618 ThrowImageException;
4621 void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
4622 const double radius_,const double sigma_,const double amount_,
4623 const double threshold_)
4629 GetAndSetPPChannelMask(channel_);
4630 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4632 RestorePPChannelMask;
4633 replaceImage(newImage);
4634 ThrowImageException;
4637 void Magick::Image::vignette(const double radius_,const double sigma_,
4638 const ssize_t x_,const ssize_t y_)
4644 newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,exceptionInfo);
4645 replaceImage(newImage);
4646 ThrowImageException;
4649 void Magick::Image::wave(const double amplitude_,const double wavelength_)
4655 newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
4657 replaceImage(newImage);
4658 ThrowImageException;
4661 void Magick::Image::whiteThreshold(const std::string &threshold_)
4665 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4666 ThrowImageException;
4669 void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
4670 const std::string &threshold_)
4674 GetAndSetPPChannelMask(channel_);
4675 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4676 RestorePPChannelMask;
4677 ThrowImageException;
4680 void Magick::Image::write(Blob *blob_)
4690 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4692 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4693 ThrowImageException;
4696 void Magick::Image::write(Blob *blob_,const std::string &magick_)
4707 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4709 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4710 ThrowImageException;
4713 void Magick::Image::write(Blob *blob_,const std::string &magick_,
4714 const size_t depth_)
4726 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4728 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4729 ThrowImageException;
4732 void Magick::Image::write(const ssize_t x_,const ssize_t y_,
4733 const size_t columns_,const size_t rows_,const std::string &map_,
4734 const StorageType type_,void *pixels_)
4737 ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
4739 ThrowImageException;
4742 void Magick::Image::write(const std::string &imageSpec_)
4745 fileName(imageSpec_);
4747 WriteImage(constImageInfo(),image(),exceptionInfo);
4748 ThrowImageException;
4751 void Magick::Image::writePixels(const Magick::QuantumType quantum_,
4752 unsigned char *destination_)
4757 quantum_info=AcquireQuantumInfo(imageInfo(),image());
4759 ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4760 quantum_,destination_, exceptionInfo);
4761 quantum_info=DestroyQuantumInfo(quantum_info);
4762 ThrowImageException;
4765 void Magick::Image::zoom(const Geometry &geometry_)
4778 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4782 newImage=ResizeImage(constImage(),width,height,image()->filter,exceptionInfo);
4783 replaceImage(newImage);
4784 ThrowImageException;
4787 Magick::Image::Image(MagickCore::Image *image_)
4788 : _imgRef(new ImageRef(image_))
4792 MagickCore::Image *&Magick::Image::image(void)
4794 return(_imgRef->image());
4797 const MagickCore::Image *Magick::Image::constImage(void) const
4799 return(_imgRef->image());
4802 MagickCore::ImageInfo *Magick::Image::imageInfo(void)
4804 return(_imgRef->options()->imageInfo());
4807 const MagickCore::ImageInfo *Magick::Image::constImageInfo(void) const
4809 return(_imgRef->options()->imageInfo());
4812 Magick::Options *Magick::Image::options(void)
4814 return(_imgRef->options());
4817 const Magick::Options *Magick::Image::constOptions(void) const
4819 return(_imgRef->options());
4822 MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)
4824 return(_imgRef->options()->quantizeInfo());
4827 const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
4829 return(_imgRef->options()->quantizeInfo());
4832 void Magick::Image::modifyImage(void)
4834 if (!_imgRef->isShared())
4838 replaceImage(CloneImage(image(),0,0,MagickTrue,exceptionInfo));
4839 ThrowImageException;
4842 MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
4852 image=AcquireImage(constImageInfo(),exceptionInfo);
4853 ThrowImageException;
4856 _imgRef=ImageRef::replaceImage(_imgRef,image);
4860 void Magick::Image::read(MagickCore::Image *image,
4861 MagickCore::ExceptionInfo *exceptionInfo)
4863 // Ensure that multiple image frames were not read.
4864 if (image != (MagickCore::Image *) NULL &&
4865 image->next != (MagickCore::Image *) NULL)
4870 // Destroy any extra image frames
4872 image->next=(MagickCore::Image *) NULL;
4873 next->previous=(MagickCore::Image *) NULL;
4874 DestroyImageList(next);
4876 replaceImage(image);
4877 if (exceptionInfo->severity == MagickCore::UndefinedException &&
4878 image == (MagickCore::Image *) NULL)
4880 (void) MagickCore::DestroyExceptionInfo(exceptionInfo);
4882 throwExceptionExplicit(MagickCore::ImageWarning,
4883 "No image was loaded.");
4885 ThrowImageException;
4888 void Magick::Image::floodFill(const ssize_t x_,const ssize_t y_,
4889 const Magick::Image *fillPattern_,const Magick::Color &fill_,
4890 const MagickCore::PixelInfo *target_,const bool invert_)
4898 // Set drawing fill pattern or fill color
4899 fillColor=options()->fillColor();
4900 fillPattern=(MagickCore::Image *)NULL;
4901 if (options()->fillPattern() != (MagickCore::Image *)NULL)
4904 fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
4906 ThrowImageException;
4909 if (fillPattern_ == (Magick::Image *)NULL)
4911 options()->fillPattern((MagickCore::Image *)NULL);
4912 options()->fillColor(fill_);
4915 options()->fillPattern(fillPattern_->constImage());
4918 (void) FloodfillPaintImage(image(),options()->drawInfo(),
4919 target_,static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),
4920 (MagickBooleanType) invert_,exceptionInfo);
4922 options()->fillColor(fillColor);
4923 options()->fillPattern(fillPattern);
4924 ThrowImageException;