1 // This may look like C code, but it is really -*- C++ -*-
3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
4 // Copyright Dirk Lemstra 2013-2015
6 // Implementation of Image
9 #define MAGICKCORE_IMPLEMENTATION 1
10 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
12 #include "Magick++/Include.h"
21 #include "Magick++/Image.h"
22 #include "Magick++/Functions.h"
23 #include "Magick++/Pixels.h"
24 #include "Magick++/Options.h"
25 #include "Magick++/ImageRef.h"
27 #define AbsoluteValue(x) ((x) < 0 ? -(x) : (x))
28 #define MagickPI 3.14159265358979323846264338327950288419716939937510
29 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
30 #define ThrowImageException ThrowPPException(quiet())
32 MagickPPExport const char *Magick::borderGeometryDefault="6x6+0+0";
33 MagickPPExport const char *Magick::frameGeometryDefault="25x25+6+6";
34 MagickPPExport const char *Magick::raiseGeometryDefault="6x6+0+0";
36 MagickPPExport int Magick::operator == (const Magick::Image &left_,
37 const Magick::Image &right_)
39 // If image pixels and signature are the same, then the image is identical
40 return((left_.rows() == right_.rows()) &&
41 (left_.columns() == right_.columns()) &&
42 (left_.signature() == right_.signature()));
45 MagickPPExport int Magick::operator != (const Magick::Image &left_,
46 const Magick::Image &right_)
48 return(!(left_ == right_));
51 MagickPPExport int Magick::operator > (const Magick::Image &left_,
52 const Magick::Image &right_)
54 return(!(left_ < right_) && (left_ != right_));
57 MagickPPExport int Magick::operator < (const Magick::Image &left_,
58 const Magick::Image &right_)
60 // If image pixels are less, then image is smaller
61 return((left_.rows() * left_.columns()) <
62 (right_.rows() * right_.columns()));
65 MagickPPExport int Magick::operator >= (const Magick::Image &left_,
66 const Magick::Image &right_)
68 return((left_ > right_) || (left_ == right_));
71 MagickPPExport int Magick::operator <= (const Magick::Image &left_,
72 const Magick::Image &right_)
74 return((left_ < right_) || ( left_ == right_));
77 Magick::Image::Image(void)
78 : _imgRef(new ImageRef)
82 Magick::Image::Image(const Blob &blob_)
83 : _imgRef(new ImageRef)
87 // Initialize, Allocate and Read images
100 Magick::Image::Image(const Blob &blob_,const Geometry &size_)
101 : _imgRef(new ImageRef)
118 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
120 : _imgRef(new ImageRef)
126 read(blob_,size_,depth_);
137 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
138 const size_t depth_,const std::string &magick_)
139 : _imgRef(new ImageRef)
145 read(blob_,size_,depth_,magick_);
156 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
157 const std::string &magick_)
158 : _imgRef(new ImageRef)
164 read(blob_,size_,magick_);
175 Magick::Image::Image(const Geometry &size_,const Color &color_)
176 : _imgRef(new ImageRef)
178 // xc: prefix specifies an X11 color string
179 std::string imageSpec("xc:");
188 // Initialize, Allocate and Read images
200 Magick::Image::Image(const Image &image_)
201 : _imgRef(image_._imgRef)
206 Magick::Image::Image(const size_t width_,const size_t height_,
207 const std::string &map_,const StorageType type_,const void *pixels_)
208 : _imgRef(new ImageRef)
213 read(width_,height_,map_.c_str(),type_,pixels_);
224 Magick::Image::Image(const std::string &imageSpec_)
225 : _imgRef(new ImageRef)
229 // Initialize, Allocate and Read images
242 Magick::Image::~Image()
244 if (_imgRef->decrease() == 0)
247 _imgRef=(Magick::ImageRef *) NULL;
250 Magick::Image& Magick::Image::operator=(const Magick::Image &image_)
254 image_._imgRef->increase();
255 if (_imgRef->decrease() == 0)
258 // Use new image reference
259 _imgRef=image_._imgRef;
264 void Magick::Image::adjoin(const bool flag_)
267 options()->adjoin(flag_);
270 bool Magick::Image::adjoin(void) const
272 return(constOptions()->adjoin());
275 void Magick::Image::alpha(const bool matteFlag_)
279 // If matte channel is requested, but image doesn't already have a
280 // matte channel, then create an opaque matte channel. Likewise, if
281 // the image already has a matte channel but a matte channel is not
282 // desired, then set the matte channel to opaque.
284 if ((matteFlag_ && !constImage()->alpha_trait) ||
285 (constImage()->alpha_trait && !matteFlag_))
286 SetImageAlpha(image(),OpaqueAlpha,exceptionInfo);
289 image()->alpha_trait=matteFlag_ ? BlendPixelTrait : UndefinedPixelTrait;
292 bool Magick::Image::alpha(void) const
294 if (constImage()->alpha_trait == BlendPixelTrait)
300 void Magick::Image::alphaColor(const Color &alphaColor_)
304 if (alphaColor_.isValid())
306 image()->matte_color=alphaColor_;
307 options()->matteColor(alphaColor_);
311 // Set to default matte color
312 Color tmpColor("#BDBDBD");
313 image()->matte_color=tmpColor;
314 options()->matteColor(tmpColor);
318 Magick::Color Magick::Image::alphaColor(void) const
320 return(Color(constImage()->matte_color));
323 void Magick::Image::antiAlias(const bool flag_)
326 options()->antiAlias(flag_);
329 bool Magick::Image::antiAlias(void) const
331 return(constOptions()->antiAlias());
334 void Magick::Image::animationDelay(const size_t delay_)
337 image()->delay=delay_;
340 size_t Magick::Image::animationDelay(void) const
342 return(constImage()->delay);
345 void Magick::Image::animationIterations(const size_t iterations_)
348 image()->iterations=iterations_;
351 size_t Magick::Image::animationIterations(void) const
353 return(constImage()->iterations);
356 void Magick::Image::attenuate(const double attenuate_)
359 value[MagickPathExtent];
362 FormatLocaleString(value,MagickPathExtent,"%.20g",attenuate_);
363 (void) SetImageArtifact(image(),"attenuate",value);
366 void Magick::Image::backgroundColor(const Color &backgroundColor_)
370 if (backgroundColor_.isValid())
371 image()->background_color=backgroundColor_;
373 image()->background_color=Color();
375 options()->backgroundColor(backgroundColor_);
378 Magick::Color Magick::Image::backgroundColor(void) const
380 return(constOptions()->backgroundColor());
383 void Magick::Image::backgroundTexture(const std::string &backgroundTexture_)
386 options()->backgroundTexture(backgroundTexture_);
389 std::string Magick::Image::backgroundTexture(void) const
391 return(constOptions()->backgroundTexture());
394 size_t Magick::Image::baseColumns(void) const
396 return(constImage()->magick_columns);
399 std::string Magick::Image::baseFilename(void) const
401 return(std::string(constImage()->magick_filename));
404 size_t Magick::Image::baseRows(void) const
406 return(constImage()->magick_rows);
409 void Magick::Image::blackPointCompensation(const bool flag_)
411 image()->black_point_compensation=(MagickBooleanType) flag_;
414 bool Magick::Image::blackPointCompensation(void) const
416 return(static_cast<bool>(constImage()->black_point_compensation));
419 void Magick::Image::borderColor(const Color &borderColor_)
423 if (borderColor_.isValid())
424 image()->border_color=borderColor_;
426 image()->border_color=Color();
428 options()->borderColor(borderColor_);
431 Magick::Color Magick::Image::borderColor(void) const
433 return(constOptions()->borderColor());
436 Magick::Geometry Magick::Image::boundingBox(void) const
442 bbox=GetImageBoundingBox(constImage(),exceptionInfo);
444 return(Geometry(bbox));
447 void Magick::Image::boxColor(const Color &boxColor_)
450 options()->boxColor(boxColor_);
453 Magick::Color Magick::Image::boxColor(void) const
455 return(constOptions()->boxColor());
458 void Magick::Image::channelDepth(const ChannelType channel_,
463 GetAndSetPPChannelMask(channel_);
464 SetImageDepth(image(),depth_,exceptionInfo);
465 RestorePPChannelMask;
469 size_t Magick::Image::channelDepth(const ChannelType channel_)
475 GetAndSetPPChannelMask(channel_);
476 channel_depth=GetImageDepth(constImage(),exceptionInfo);
477 RestorePPChannelMask;
479 return(channel_depth);
482 size_t Magick::Image::channels() const
484 return(constImage()->number_channels);
487 void Magick::Image::classType(const ClassType class_)
489 if (classType() == PseudoClass && class_ == DirectClass)
491 // Use SyncImage to synchronize the DirectClass pixels with the
492 // color map and then set to DirectClass type.
495 SyncImage(image(),exceptionInfo);
497 image()->colormap=(PixelInfo *)RelinquishMagickMemory(image()->colormap);
498 image()->storage_class=static_cast<MagickCore::ClassType>(DirectClass);
502 if (classType() == DirectClass && class_ == PseudoClass)
504 // Quantize to create PseudoClass color map
506 quantizeColors(MaxColormapSize);
508 image()->storage_class=static_cast<MagickCore::ClassType>(PseudoClass);
512 Magick::ClassType Magick::Image::classType(void) const
514 return static_cast<Magick::ClassType>(constImage()->storage_class);
517 void Magick::Image::colorFuzz(const double fuzz_)
521 options()->colorFuzz(fuzz_);
524 double Magick::Image::colorFuzz(void) const
526 return(constOptions()->colorFuzz());
529 void Magick::Image::colorMapSize(const size_t entries_)
531 if (entries_ >MaxColormapSize)
532 throwExceptionExplicit(MagickCore::OptionError,
533 "Colormap entries must not exceed MaxColormapSize");
537 (void) AcquireImageColormap(image(),entries_,exceptionInfo);
541 size_t Magick::Image::colorMapSize(void) const
543 if (!constImage()->colormap)
544 throwExceptionExplicit(MagickCore::OptionError,
545 "Image does not contain a colormap");
547 return(constImage()->colors);
550 void Magick::Image::colorSpace(const ColorspaceType colorSpace_)
552 if (image()->colorspace == colorSpace_)
557 TransformImageColorspace(image(),colorSpace_,exceptionInfo);
561 Magick::ColorspaceType Magick::Image::colorSpace(void) const
563 return (constImage()->colorspace);
566 void Magick::Image::colorSpaceType(const ColorspaceType colorSpace_)
570 SetImageColorspace(image(),colorSpace_,exceptionInfo);
572 options()->colorspaceType(colorSpace_);
575 Magick::ColorspaceType Magick::Image::colorSpaceType(void) const
577 return(constOptions()->colorspaceType());
580 size_t Magick::Image::columns(void) const
582 return(constImage()->columns);
585 void Magick::Image::comment(const std::string &comment_)
589 SetImageProperty(image(),"Comment",NULL,exceptionInfo);
590 if (comment_.length() > 0)
591 SetImageProperty(image(),"Comment",comment_.c_str(),exceptionInfo);
595 std::string Magick::Image::comment(void) const
601 value=GetImageProperty(constImage(),"Comment",exceptionInfo);
605 return(std::string(value));
607 return(std::string()); // Intentionally no exception
610 void Magick::Image::compose(const CompositeOperator compose_)
612 image()->compose=compose_;
615 Magick::CompositeOperator Magick::Image::compose(void) const
617 return(constImage()->compose);
620 void Magick::Image::compressType(const CompressionType compressType_)
623 image()->compression=compressType_;
624 options()->compressType(compressType_);
627 Magick::CompressionType Magick::Image::compressType(void) const
629 return(constImage()->compression);
632 void Magick::Image::debug(const bool flag_)
635 options()->debug(flag_);
638 bool Magick::Image::debug(void) const
640 return(constOptions()->debug());
643 void Magick::Image::density(const Point &density_)
646 options()->density(density_);
647 if (density_.isValid())
649 image()->resolution.x=density_.x();
650 if (density_.y() != 0.0)
651 image()->resolution.y=density_.y();
653 image()->resolution.y=density_.x();
658 image()->resolution.x=0.0;
659 image()->resolution.y=0.0;
663 Magick::Point Magick::Image::density(void) const
671 if (constImage()->resolution.x > 0.0)
672 x_resolution=constImage()->resolution.x;
674 if (constImage()->resolution.y > 0.0)
675 y_resolution=constImage()->resolution.y;
677 return(Point(x_resolution,y_resolution));
680 return(constOptions()->density());
683 void Magick::Image::depth(const size_t depth_)
688 if (depth > MAGICKCORE_QUANTUM_DEPTH)
689 depth=MAGICKCORE_QUANTUM_DEPTH;
692 image()->depth=depth;
693 options()->depth(depth);
696 size_t Magick::Image::depth(void) const
698 return(constImage()->depth);
701 std::string Magick::Image::directory(void) const
703 if (constImage()->directory)
704 return(std::string(constImage()->directory));
707 throwExceptionExplicit(MagickCore::CorruptImageWarning,
708 "Image does not contain a directory");
710 return(std::string());
713 void Magick::Image::endian(const Magick::EndianType endian_)
716 options()->endian(endian_);
717 image()->endian=endian_;
720 Magick::EndianType Magick::Image::endian(void) const
722 return(constImage()->endian);
725 void Magick::Image::exifProfile(const Magick::Blob &exifProfile_)
729 if (exifProfile_.data() != 0)
734 exif_profile=AcquireStringInfo(exifProfile_.length());
735 SetStringInfoDatum(exif_profile,(unsigned char *) exifProfile_.data());
737 (void) SetImageProfile(image(),"exif",exif_profile,exceptionInfo);
738 exif_profile=DestroyStringInfo(exif_profile);
743 Magick::Blob Magick::Image::exifProfile(void) const
748 exif_profile=GetImageProfile(constImage(),"exif");
749 if (exif_profile == (StringInfo *) NULL)
751 return(Blob(GetStringInfoDatum(exif_profile),
752 GetStringInfoLength(exif_profile)));
755 void Magick::Image::fileName(const std::string &fileName_)
759 fileName_.copy(image()->filename,sizeof(image()->filename)-1);
760 image()->filename[fileName_.length()]=0; // Null terminate
762 options()->fileName(fileName_);
765 std::string Magick::Image::fileName(void) const
767 return(constOptions()->fileName());
770 MagickCore::MagickSizeType Magick::Image::fileSize(void) const
772 return(GetBlobSize(constImage()));
775 void Magick::Image::fillColor(const Magick::Color &fillColor_)
778 options()->fillColor(fillColor_);
781 Magick::Color Magick::Image::fillColor(void) const
783 return(constOptions()->fillColor());
786 void Magick::Image::fillRule(const Magick::FillRule &fillRule_)
789 options()->fillRule(fillRule_);
792 Magick::FillRule Magick::Image::fillRule(void) const
794 return constOptions()->fillRule();
797 void Magick::Image::fillPattern(const Image &fillPattern_)
800 if (fillPattern_.isValid())
801 options()->fillPattern(fillPattern_.constImage());
803 options()->fillPattern(static_cast<MagickCore::Image*>(NULL));
806 Magick::Image Magick::Image::fillPattern(void) const
808 // FIXME: This is inordinately innefficient
809 const MagickCore::Image
815 tmpTexture=constOptions()->fillPattern();
823 image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
824 texture.replaceImage(image);
830 void Magick::Image::filterType(const Magick::FilterTypes filterType_)
833 image()->filter=filterType_;
836 Magick::FilterTypes Magick::Image::filterType(void) const
838 return(constImage()->filter);
841 void Magick::Image::font(const std::string &font_)
844 options()->font(font_);
847 std::string Magick::Image::font(void) const
849 return(constOptions()->font());
852 void Magick::Image::fontFamily(const std::string &family_)
855 options()->fontFamily(family_);
858 std::string Magick::Image::fontFamily(void) const
860 return(constOptions()->fontFamily());
863 void Magick::Image::fontPointsize(const double pointSize_)
866 options()->fontPointsize(pointSize_);
869 double Magick::Image::fontPointsize(void) const
871 return(constOptions()->fontPointsize());
874 void Magick::Image::fontStyle(const StyleType pointSize_)
877 options()->fontStyle(pointSize_);
880 Magick::StyleType Magick::Image::fontStyle(void) const
882 return(constOptions()->fontStyle());
885 void Magick::Image::fontWeight(const size_t weight_)
888 options()->fontWeight(weight_);
891 size_t Magick::Image::fontWeight(void) const
893 return(constOptions()->fontWeight());
896 std::string Magick::Image::format(void) const
902 magick_info=GetMagickInfo(constImage()->magick,exceptionInfo);
905 if ((magick_info != 0) && (*magick_info->description != '\0'))
906 return(std::string(magick_info->description));
909 throwExceptionExplicit(MagickCore::CorruptImageWarning,
910 "Unrecognized image magick type");
912 return(std::string());
915 std::string Magick::Image::formatExpression(const std::string expression)
925 text=InterpretImageProperties(imageInfo(),image(),expression.c_str(),
927 if (text != (char *) NULL)
929 text_string=std::string(text);
930 text=DestroyString(text);
936 double Magick::Image::gamma(void) const
938 return(constImage()->gamma);
941 Magick::Geometry Magick::Image::geometry(void) const
943 if (constImage()->geometry)
944 return Geometry(constImage()->geometry);
947 throwExceptionExplicit(MagickCore::OptionWarning,
948 "Image does not contain a geometry");
953 void Magick::Image::gifDisposeMethod(
954 const MagickCore::DisposeType disposeMethod_)
957 image()->dispose=disposeMethod_;
960 MagickCore::DisposeType Magick::Image::gifDisposeMethod(void) const
962 return(constImage()->dispose);
965 bool Magick::Image::hasChannel(const PixelChannel channel) const
967 if (GetPixelChannelTraits(constImage(),channel) == UndefinedPixelTrait)
970 if (channel == GreenPixelChannel || channel == BluePixelChannel)
971 return (GetPixelChannelOffset(constImage(),channel) == (ssize_t)channel);
976 void Magick::Image::highlightColor(const Color color_)
982 artifact("highlight-color",value);
985 void Magick::Image::iccColorProfile(const Magick::Blob &colorProfile_)
987 profile("icc",colorProfile_);
990 Magick::Blob Magick::Image::iccColorProfile(void) const
995 color_profile=GetImageProfile(constImage(),"icc");
996 if (color_profile == (StringInfo *) NULL)
998 return(Blob(GetStringInfoDatum(color_profile),GetStringInfoLength(
1002 void Magick::Image::interlaceType(const Magick::InterlaceType interlace_)
1005 image()->interlace=interlace_;
1006 options()->interlaceType(interlace_);
1009 Magick::InterlaceType Magick::Image::interlaceType(void) const
1011 return(constImage()->interlace);
1014 void Magick::Image::interpolate(const PixelInterpolateMethod interpolate_)
1017 image()->interpolate=interpolate_;
1020 Magick::PixelInterpolateMethod Magick::Image::interpolate(void) const
1022 return constImage()->interpolate;
1025 void Magick::Image::iptcProfile(const Magick::Blob &iptcProfile_)
1028 if (iptcProfile_.data() != 0)
1033 iptc_profile=AcquireStringInfo(iptcProfile_.length());
1034 SetStringInfoDatum(iptc_profile,(unsigned char *) iptcProfile_.data());
1036 (void) SetImageProfile(image(),"iptc",iptc_profile,exceptionInfo);
1037 iptc_profile=DestroyStringInfo(iptc_profile);
1038 ThrowImageException;
1042 Magick::Blob Magick::Image::iptcProfile(void) const
1047 iptc_profile=GetImageProfile(constImage(),"iptc");
1048 if (iptc_profile == (StringInfo *) NULL)
1050 return(Blob(GetStringInfoDatum(iptc_profile),GetStringInfoLength(
1054 bool Magick::Image::isOpaque(void) const
1060 result=IsImageOpaque(constImage(),exceptionInfo);
1061 ThrowImageException;
1062 return(result != MagickFalse ? true : false);
1065 void Magick::Image::isValid(const bool isValid_)
1070 _imgRef=new ImageRef;
1072 else if (!isValid())
1074 // Construct with single-pixel black image to make
1075 // image valid. This is an obvious hack.
1076 size(Geometry(1,1));
1081 bool Magick::Image::isValid(void) const
1083 return rows() && columns();
1086 void Magick::Image::label(const std::string &label_)
1090 (void) SetImageProperty(image(),"Label",NULL,exceptionInfo);
1091 if (label_.length() > 0)
1092 (void) SetImageProperty(image(),"Label",label_.c_str(),exceptionInfo);
1093 ThrowImageException;
1096 std::string Magick::Image::label(void) const
1102 value=GetImageProperty(constImage(),"Label",exceptionInfo);
1103 ThrowImageException;
1106 return(std::string(value));
1108 return(std::string());
1111 void Magick::Image::lowlightColor(const Color color_)
1117 artifact("lowlight-color",value);
1120 void Magick::Image::mask(const Magick::Image &mask_)
1125 if (mask_.isValid())
1126 SetImageMask(image(),ReadPixelMask,mask_.constImage(),exceptionInfo);
1128 SetImageMask(image(),ReadPixelMask,(MagickCore::Image *) NULL,
1130 ThrowImageException;
1133 Magick::Image Magick::Image::mask(void) const
1139 image=GetImageMask(constImage(),exceptionInfo);
1140 ThrowImageException;
1142 if (image == (MagickCore::Image *) NULL)
1143 return(Magick::Image());
1145 return(Magick::Image(image));
1148 void Magick::Image::magick(const std::string &magick_)
1155 length=sizeof(image()->magick)-1;
1156 if (magick_.length() < length)
1157 length=magick_.length();
1159 if (!magick_.empty())
1160 magick_.copy(image()->magick,length);
1161 image()->magick[length]=0;
1163 options()->magick(magick_);
1166 std::string Magick::Image::magick(void) const
1168 if (*(constImage()->magick) != '\0')
1169 return(std::string(constImage()->magick));
1171 return(constOptions()->magick());
1174 double Magick::Image::meanErrorPerPixel(void) const
1176 return(constImage()->error.mean_error_per_pixel);
1179 void Magick::Image::modulusDepth(const size_t depth_)
1183 SetImageDepth(image(),depth_,exceptionInfo);
1184 ThrowImageException;
1185 options()->depth(depth_);
1188 size_t Magick::Image::modulusDepth(void) const
1194 depth=GetImageDepth(constImage(),exceptionInfo);
1195 ThrowImageException;
1199 void Magick::Image::monochrome(const bool monochromeFlag_)
1202 options()->monochrome(monochromeFlag_);
1205 bool Magick::Image::monochrome(void) const
1207 return(constOptions()->monochrome());
1210 Magick::Geometry Magick::Image::montageGeometry(void) const
1212 if (constImage()->montage)
1213 return Magick::Geometry(constImage()->montage);
1216 throwExceptionExplicit(MagickCore::CorruptImageWarning,
1217 "Image does not contain a montage");
1219 return(Magick::Geometry());
1222 double Magick::Image::normalizedMaxError(void) const
1224 return(constImage()->error.normalized_maximum_error);
1227 double Magick::Image::normalizedMeanError(void) const
1229 return(constImage()->error.normalized_mean_error);
1232 void Magick::Image::orientation(const Magick::OrientationType orientation_)
1235 image()->orientation=orientation_;
1238 Magick::OrientationType Magick::Image::orientation(void) const
1240 return(constImage()->orientation);
1243 void Magick::Image::page(const Magick::Geometry &pageSize_)
1246 options()->page(pageSize_);
1247 image()->page=pageSize_;
1250 Magick::Geometry Magick::Image::page(void) const
1252 return(Geometry(constImage()->page.width,constImage()->page.height,
1253 constImage()->page.x,constImage()->page.y));
1256 void Magick::Image::quality(const size_t quality_)
1259 image()->quality=quality_;
1260 options()->quality(quality_);
1263 size_t Magick::Image::quality(void) const
1265 return(constImage()->quality);
1268 void Magick::Image::quantizeColors(const size_t colors_)
1271 options()->quantizeColors(colors_);
1274 size_t Magick::Image::quantizeColors(void) const
1276 return(constOptions()->quantizeColors());
1279 void Magick::Image::quantizeColorSpace(
1280 const Magick::ColorspaceType colorSpace_)
1283 options()->quantizeColorSpace(colorSpace_);
1286 Magick::ColorspaceType Magick::Image::quantizeColorSpace(void) const
1288 return(constOptions()->quantizeColorSpace());
1291 void Magick::Image::quantizeDither(const bool ditherFlag_)
1294 options()->quantizeDither(ditherFlag_);
1297 bool Magick::Image::quantizeDither(void) const
1299 return(constOptions()->quantizeDither());
1302 void Magick::Image::quantizeDitherMethod(const DitherMethod ditherMethod_)
1305 options()->quantizeDitherMethod(ditherMethod_);
1308 MagickCore::DitherMethod Magick::Image::quantizeDitherMethod(void) const
1310 return(constOptions()->quantizeDitherMethod());
1313 void Magick::Image::quantizeTreeDepth(const size_t treeDepth_)
1316 options()->quantizeTreeDepth(treeDepth_);
1319 size_t Magick::Image::quantizeTreeDepth() const
1321 return(constOptions()->quantizeTreeDepth());
1324 void Magick::Image::quiet(const bool quiet_)
1327 options()->quiet(quiet_);
1330 bool Magick::Image::quiet(void) const
1332 return(constOptions()->quiet());
1335 void Magick::Image::renderingIntent(
1336 const Magick::RenderingIntent renderingIntent_)
1339 image()->rendering_intent=renderingIntent_;
1342 Magick::RenderingIntent Magick::Image::renderingIntent(void) const
1344 return(static_cast<Magick::RenderingIntent>(constImage()->rendering_intent));
1347 void Magick::Image::resolutionUnits(
1348 const Magick::ResolutionType resolutionUnits_)
1351 image()->units=resolutionUnits_;
1352 options()->resolutionUnits(resolutionUnits_);
1355 Magick::ResolutionType Magick::Image::resolutionUnits(void) const
1357 return(static_cast<Magick::ResolutionType>(constImage()->units));
1360 size_t Magick::Image::rows(void) const
1362 return(constImage()->rows);
1365 void Magick::Image::scene(const size_t scene_)
1368 image()->scene=scene_;
1371 size_t Magick::Image::scene(void) const
1373 return(constImage()->scene);
1376 void Magick::Image::size(const Geometry &geometry_)
1379 options()->size(geometry_);
1380 image()->rows=geometry_.height();
1381 image()->columns=geometry_.width();
1384 Magick::Geometry Magick::Image::size(void) const
1386 return(Magick::Geometry(constImage()->columns,constImage()->rows));
1389 void Magick::Image::strokeAntiAlias(const bool flag_)
1392 options()->strokeAntiAlias(flag_);
1395 bool Magick::Image::strokeAntiAlias(void) const
1397 return(constOptions()->strokeAntiAlias());
1400 void Magick::Image::strokeColor(const Magick::Color &strokeColor_)
1406 options()->strokeColor(strokeColor_);
1408 artifact("stroke",value);
1411 Magick::Color Magick::Image::strokeColor(void) const
1413 return(constOptions()->strokeColor());
1416 void Magick::Image::strokeDashArray(const double *strokeDashArray_)
1419 options()->strokeDashArray(strokeDashArray_);
1422 const double* Magick::Image::strokeDashArray(void) const
1424 return(constOptions()->strokeDashArray());
1427 void Magick::Image::strokeDashOffset(const double strokeDashOffset_)
1430 options()->strokeDashOffset(strokeDashOffset_);
1433 double Magick::Image::strokeDashOffset(void) const
1435 return(constOptions()->strokeDashOffset());
1438 void Magick::Image::strokeLineCap(const Magick::LineCap lineCap_)
1441 options()->strokeLineCap(lineCap_);
1444 Magick::LineCap Magick::Image::strokeLineCap(void) const
1446 return(constOptions()->strokeLineCap());
1449 void Magick::Image::strokeLineJoin(const Magick::LineJoin lineJoin_)
1452 options()->strokeLineJoin(lineJoin_);
1455 Magick::LineJoin Magick::Image::strokeLineJoin(void) const
1457 return(constOptions()->strokeLineJoin());
1460 void Magick::Image::strokeMiterLimit(const size_t strokeMiterLimit_)
1463 options()->strokeMiterLimit(strokeMiterLimit_);
1466 size_t Magick::Image::strokeMiterLimit(void) const
1468 return(constOptions()->strokeMiterLimit());
1471 void Magick::Image::strokePattern(const Image &strokePattern_)
1474 if(strokePattern_.isValid())
1475 options()->strokePattern(strokePattern_.constImage());
1477 options()->strokePattern(static_cast<MagickCore::Image*>(NULL));
1480 Magick::Image Magick::Image::strokePattern(void) const
1482 // FIXME: This is inordinately innefficient
1483 const MagickCore::Image
1489 tmpTexture=constOptions()->strokePattern();
1497 image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
1498 texture.replaceImage(image);
1499 ThrowImageException;
1504 void Magick::Image::strokeWidth(const double strokeWidth_)
1507 value[MagickPathExtent];
1510 options()->strokeWidth(strokeWidth_);
1511 FormatLocaleString(value,MagickPathExtent,"%.20g",strokeWidth_);
1512 (void) SetImageArtifact(image(),"strokewidth",value);
1515 double Magick::Image::strokeWidth(void) const
1517 return(constOptions()->strokeWidth());
1520 void Magick::Image::subImage(const size_t subImage_)
1523 options()->subImage(subImage_);
1526 size_t Magick::Image::subImage(void) const
1528 return(constOptions()->subImage());
1531 void Magick::Image::subRange(const size_t subRange_)
1534 options()->subRange(subRange_);
1537 size_t Magick::Image::subRange(void) const
1539 return(constOptions()->subRange());
1542 void Magick::Image::textDirection(DirectionType direction_)
1545 options()->textDirection(direction_);
1548 Magick::DirectionType Magick::Image::textDirection(void) const
1550 return(constOptions()->textDirection());
1553 void Magick::Image::textEncoding(const std::string &encoding_)
1556 options()->textEncoding(encoding_);
1559 std::string Magick::Image::textEncoding(void) const
1561 return(constOptions()->textEncoding());
1564 void Magick::Image::textGravity(GravityType gravity_)
1567 options()->textGravity(gravity_);
1570 Magick::GravityType Magick::Image::textGravity(void) const
1572 return(constOptions()->textGravity());
1575 void Magick::Image::textInterlineSpacing(double spacing_)
1578 options()->textInterlineSpacing(spacing_);
1581 double Magick::Image::textInterlineSpacing(void) const
1583 return(constOptions()->textInterlineSpacing());
1586 void Magick::Image::textInterwordSpacing(double spacing_)
1589 options()->textInterwordSpacing(spacing_);
1592 double Magick::Image::textInterwordSpacing(void) const
1594 return(constOptions()->textInterwordSpacing());
1597 void Magick::Image::textKerning(double kerning_)
1600 options()->textKerning(kerning_);
1603 double Magick::Image::textKerning(void) const
1605 return(constOptions()->textKerning());
1608 void Magick::Image::textUnderColor(const Color &underColor_)
1611 options()->textUnderColor(underColor_);
1614 Magick::Color Magick::Image::textUnderColor(void) const
1616 return(constOptions()->textUnderColor());
1619 size_t Magick::Image::totalColors(void) const
1625 colors=GetNumberColors(constImage(),(FILE *) NULL,exceptionInfo);
1626 ThrowImageException;
1630 void Magick::Image::transformRotation(const double angle_)
1633 options()->transformRotation(angle_);
1636 void Magick::Image::transformSkewX(const double skewx_)
1639 options()->transformSkewX(skewx_);
1642 void Magick::Image::transformSkewY(const double skewy_)
1645 options()->transformSkewY(skewy_);
1648 Magick::ImageType Magick::Image::type(void) const
1650 if (constOptions()->type() != UndefinedType)
1651 return(constOptions()->type());
1652 return(GetImageType(constImage()));
1655 void Magick::Image::type(const Magick::ImageType type_)
1658 options()->type(type_);
1660 SetImageType(image(),type_,exceptionInfo);
1661 ThrowImageException;
1664 void Magick::Image::verbose(const bool verboseFlag_)
1667 options()->verbose(verboseFlag_);
1670 bool Magick::Image::verbose(void) const
1672 return(constOptions()->verbose());
1675 void Magick::Image::view(const std::string &view_)
1678 options()->view(view_);
1681 std::string Magick::Image::view(void) const
1683 return(constOptions()->view());
1686 void Magick::Image::virtualPixelMethod(
1687 const VirtualPixelMethod virtualPixelMethod_)
1691 SetImageVirtualPixelMethod(image(),virtualPixelMethod_,exceptionInfo);
1692 ThrowImageException;
1695 Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod(void) const
1697 return(GetImageVirtualPixelMethod(constImage()));
1700 void Magick::Image::x11Display(const std::string &display_)
1703 options()->x11Display(display_);
1706 std::string Magick::Image::x11Display(void) const
1708 return(constOptions()->x11Display());
1711 double Magick::Image::xResolution(void) const
1713 return(constImage()->resolution.x);
1716 double Magick::Image::yResolution(void) const
1718 return(constImage()->resolution.y);
1721 void Magick::Image::adaptiveBlur(const double radius_,const double sigma_)
1727 newImage=AdaptiveBlurImage(constImage(),radius_,sigma_,exceptionInfo);
1728 replaceImage(newImage);
1729 ThrowImageException;
1732 void Magick::Image::adaptiveResize(const Geometry &geometry_)
1745 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
1749 newImage=AdaptiveResizeImage(constImage(),width,height,exceptionInfo);
1750 replaceImage(newImage);
1751 ThrowImageException;
1754 void Magick::Image::adaptiveSharpen(const double radius_,const double sigma_)
1760 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1761 replaceImage(newImage);
1762 ThrowImageException;
1765 void Magick::Image::adaptiveSharpenChannel(const ChannelType channel_,
1766 const double radius_,const double sigma_ )
1772 GetAndSetPPChannelMask(channel_);
1773 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1774 RestorePPChannelMask;
1775 replaceImage(newImage);
1776 ThrowImageException;
1779 void Magick::Image::adaptiveThreshold(const size_t width_,const size_t height_,
1787 newImage=AdaptiveThresholdImage(constImage(),width_,height_,bias_,
1789 replaceImage(newImage);
1790 ThrowImageException;
1793 void Magick::Image::addNoise(const NoiseType noiseType_)
1799 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1800 replaceImage(newImage);
1801 ThrowImageException;
1804 void Magick::Image::addNoiseChannel(const ChannelType channel_,
1805 const NoiseType noiseType_)
1811 GetAndSetPPChannelMask(channel_);
1812 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1813 RestorePPChannelMask;
1814 replaceImage(newImage);
1815 ThrowImageException;
1818 void Magick::Image::affineTransform(const DrawableAffine &affine_)
1826 _affine.sx=affine_.sx();
1827 _affine.sy=affine_.sy();
1828 _affine.rx=affine_.rx();
1829 _affine.ry=affine_.ry();
1830 _affine.tx=affine_.tx();
1831 _affine.ty=affine_.ty();
1834 newImage=AffineTransformImage(constImage(),&_affine,exceptionInfo);
1835 replaceImage(newImage);
1836 ThrowImageException;
1839 void Magick::Image::alpha(const unsigned int alpha_)
1843 SetImageAlpha(image(),alpha_,exceptionInfo);
1844 ThrowImageException;
1847 void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
1851 SetImageAlphaChannel(image(),alphaOption_,exceptionInfo);
1852 ThrowImageException;
1855 void Magick::Image::annotate(const std::string &text_,
1856 const Geometry &location_)
1858 annotate(text_,location_,NorthWestGravity,0.0);
1861 void Magick::Image::annotate(const std::string &text_,
1862 const Geometry &boundingArea_,const GravityType gravity_)
1864 annotate(text_,boundingArea_,gravity_,0.0);
1867 void Magick::Image::annotate(const std::string &text_,
1868 const Geometry &boundingArea_,const GravityType gravity_,
1869 const double degrees_)
1875 boundingArea[MagickPathExtent];
1882 drawInfo=options()->drawInfo();
1883 drawInfo->text=const_cast<char *>(text_.c_str());
1884 drawInfo->geometry=0;
1886 if (boundingArea_.isValid())
1888 if (boundingArea_.width() == 0 || boundingArea_.height() == 0)
1890 FormatLocaleString(boundingArea,MagickPathExtent,"%+.20g%+.20g",
1891 (double) boundingArea_.xOff(),(double) boundingArea_.yOff());
1895 (void) CopyMagickString(boundingArea,
1896 std::string(boundingArea_).c_str(), MagickPathExtent);
1898 drawInfo->geometry=boundingArea;
1901 drawInfo->gravity=gravity_;
1903 oaffine=drawInfo->affine;
1904 if (degrees_ != 0.0)
1917 current=drawInfo->affine;
1918 affine.sx=cos(DegreesToRadians(fmod(degrees_,360.0)));
1919 affine.rx=sin(DegreesToRadians(fmod(degrees_,360.0)));
1920 affine.ry=(-sin(DegreesToRadians(fmod(degrees_,360.0))));
1921 affine.sy=cos(DegreesToRadians(fmod(degrees_,360.0)));
1923 drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
1924 drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
1925 drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
1926 drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
1927 drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty
1932 AnnotateImage(image(),drawInfo,exceptionInfo);
1934 // Restore original values
1935 drawInfo->affine=oaffine;
1937 drawInfo->geometry=0;
1939 ThrowImageException;
1942 void Magick::Image::annotate(const std::string &text_,
1943 const GravityType gravity_)
1950 drawInfo=options()->drawInfo();
1951 drawInfo->text=const_cast<char *>(text_.c_str());
1952 drawInfo->gravity=gravity_;
1955 AnnotateImage(image(),drawInfo,exceptionInfo);
1957 drawInfo->gravity=NorthWestGravity;
1960 ThrowImageException;
1963 void Magick::Image::artifact(const std::string &name_,const std::string &value_)
1966 (void) SetImageArtifact(image(),name_.c_str(),value_.c_str());
1969 std::string Magick::Image::artifact(const std::string &name_) const
1974 value=GetImageArtifact(constImage(),name_.c_str());
1976 return(std::string(value));
1977 return(std::string());
1980 void Magick::Image::attribute(const std::string name_,const std::string value_)
1984 SetImageProperty(image(),name_.c_str(),value_.c_str(),exceptionInfo);
1985 ThrowImageException;
1988 std::string Magick::Image::attribute(const std::string name_) const
1994 value=GetImageProperty(constImage(),name_.c_str(),exceptionInfo);
1995 ThrowImageException;
1998 return(std::string(value));
2000 return(std::string()); // Intentionally no exception
2003 void Magick::Image::autoGamma(void)
2007 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2008 (void) AutoGammaImage(image(),exceptionInfo);
2009 ThrowImageException;
2012 void Magick::Image::autoGammaChannel(const ChannelType channel_)
2016 GetAndSetPPChannelMask(channel_);
2017 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2018 (void) AutoGammaImage(image(),exceptionInfo);
2019 RestorePPChannelMask;
2020 ThrowImageException;
2023 void Magick::Image::autoLevel(void)
2027 (void) AutoLevelImage(image(),exceptionInfo);
2028 ThrowImageException;
2031 void Magick::Image::autoLevelChannel(const ChannelType channel_)
2035 GetAndSetPPChannelMask(channel_);
2036 (void) AutoLevelImage(image(),exceptionInfo);
2037 RestorePPChannelMask;
2038 ThrowImageException;
2041 void Magick::Image::autoOrient(void)
2046 if (image()->orientation == UndefinedOrientation ||
2047 image()->orientation == TopLeftOrientation)
2051 newImage=AutoOrientImage(constImage(),image()->orientation,exceptionInfo);
2052 replaceImage(newImage);
2053 ThrowImageException;
2056 void Magick::Image::blackThreshold(const std::string &threshold_)
2060 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2061 ThrowImageException;
2064 void Magick::Image::blackThresholdChannel(const ChannelType channel_,
2065 const std::string &threshold_)
2069 GetAndSetPPChannelMask(channel_);
2070 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2071 RestorePPChannelMask;
2072 ThrowImageException;
2075 void Magick::Image::blueShift(const double factor_)
2081 newImage=BlueShiftImage(constImage(),factor_,exceptionInfo);
2082 replaceImage(newImage);
2083 ThrowImageException;
2086 void Magick::Image::blur(const double radius_,const double sigma_)
2092 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2093 replaceImage(newImage);
2094 ThrowImageException;
2097 void Magick::Image::blurChannel(const ChannelType channel_,
2098 const double radius_,const double sigma_)
2104 GetAndSetPPChannelMask(channel_);
2105 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2106 RestorePPChannelMask;
2107 replaceImage(newImage);
2108 ThrowImageException;
2111 void Magick::Image::border(const Geometry &geometry_)
2117 borderInfo=geometry_;
2120 newImage=BorderImage(constImage(),&borderInfo,image()->compose,
2122 replaceImage(newImage);
2123 ThrowImageException;
2126 void Magick::Image::brightnessContrast(const double brightness_,
2127 const double contrast_)
2131 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2132 ThrowImageException;
2135 void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
2136 const double brightness_,const double contrast_)
2140 GetAndSetPPChannelMask(channel_);
2141 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2142 RestorePPChannelMask;
2143 ThrowImageException;
2146 void Magick::Image::cannyEdge(const double radius_,const double sigma_,
2147 const double lowerPercent_,const double upperPercent_)
2154 newImage=CannyEdgeImage(constImage(),radius_,sigma_,lowerPercent_,
2155 upperPercent_,exceptionInfo);
2156 replaceImage(newImage);
2157 ThrowImageException;
2160 void Magick::Image::cdl(const std::string &cdl_)
2164 (void) ColorDecisionListImage(image(),cdl_.c_str(),exceptionInfo);
2165 ThrowImageException;
2168 void Magick::Image::channel(const ChannelType channel_)
2174 newImage=SeparateImage(image(),channel_,exceptionInfo);
2175 replaceImage(newImage);
2176 ThrowImageException;
2179 void Magick::Image::charcoal(const double radius_,const double sigma_)
2185 newImage=CharcoalImage(image(),radius_,sigma_,exceptionInfo);
2186 replaceImage(newImage);
2187 ThrowImageException;
2190 void Magick::Image::chop(const Geometry &geometry_)
2199 newImage=ChopImage(image(),&chopInfo,exceptionInfo);
2200 replaceImage(newImage);
2201 ThrowImageException;
2204 void Magick::Image::chromaBluePrimary(const double x_,const double y_)
2207 image()->chromaticity.blue_primary.x=x_;
2208 image()->chromaticity.blue_primary.y=y_;
2211 void Magick::Image::chromaBluePrimary(double *x_,double *y_) const
2213 *x_=constImage()->chromaticity.blue_primary.x;
2214 *y_=constImage()->chromaticity.blue_primary.y;
2217 void Magick::Image::chromaGreenPrimary(const double x_,const double y_)
2220 image()->chromaticity.green_primary.x=x_;
2221 image()->chromaticity.green_primary.y=y_;
2224 void Magick::Image::chromaGreenPrimary(double *x_,double *y_) const
2226 *x_=constImage()->chromaticity.green_primary.x;
2227 *y_=constImage()->chromaticity.green_primary.y;
2230 void Magick::Image::chromaRedPrimary(const double x_,const double y_)
2233 image()->chromaticity.red_primary.x=x_;
2234 image()->chromaticity.red_primary.y=y_;
2237 void Magick::Image::chromaRedPrimary(double *x_,double *y_) const
2239 *x_=constImage()->chromaticity.red_primary.x;
2240 *y_=constImage()->chromaticity.red_primary.y;
2243 void Magick::Image::chromaWhitePoint(const double x_,const double y_)
2246 image()->chromaticity.white_point.x=x_;
2247 image()->chromaticity.white_point.y=y_;
2250 void Magick::Image::chromaWhitePoint(double *x_,double *y_) const
2252 *x_=constImage()->chromaticity.white_point.x;
2253 *y_=constImage()->chromaticity.white_point.y;
2256 void Magick::Image::clamp(void)
2260 ClampImage(image(),exceptionInfo);
2261 ThrowImageException;
2264 void Magick::Image::clampChannel(const ChannelType channel_)
2268 GetAndSetPPChannelMask(channel_);
2269 ClampImage(image(),exceptionInfo);
2270 RestorePPChannelMask;
2271 ThrowImageException;
2274 void Magick::Image::clip(void)
2278 ClipImage(image(),exceptionInfo);
2279 ThrowImageException;
2282 void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
2286 ClipImagePath(image(),pathname_.c_str(),(MagickBooleanType) inside_,
2288 ThrowImageException;
2291 void Magick::Image::clut(const Image &clutImage_,
2292 const PixelInterpolateMethod method)
2296 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2297 ThrowImageException;
2300 void Magick::Image::clutChannel(const ChannelType channel_,
2301 const Image &clutImage_,const PixelInterpolateMethod method)
2305 GetAndSetPPChannelMask(channel_);
2306 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2307 RestorePPChannelMask;
2308 ThrowImageException;
2311 void Magick::Image::colorize(const unsigned int alpha_,const Color &penColor_)
2313 colorize(alpha_,alpha_,alpha_,penColor_);
2316 void Magick::Image::colorize(const unsigned int alphaRed_,
2317 const unsigned int alphaGreen_,const unsigned int alphaBlue_,
2318 const Color &penColor_)
2321 blend[MagickPathExtent];
2329 if (!penColor_.isValid())
2330 throwExceptionExplicit(MagickCore::OptionError,
2331 "Pen color argument is invalid");
2333 FormatLocaleString(blend,MagickPathExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
2336 target=static_cast<PixelInfo>(penColor_);
2338 newImage=ColorizeImage(image(),blend,&target,exceptionInfo);
2339 replaceImage(newImage);
2340 ThrowImageException;
2343 void Magick::Image::colorMap(const size_t index_,const Color &color_)
2350 if (index_ > (MaxColormapSize-1))
2351 throwExceptionExplicit(MagickCore::OptionError,
2352 "Colormap index must be less than MaxColormapSize");
2354 if (!color_.isValid())
2355 throwExceptionExplicit(MagickCore::OptionError,
2356 "Color argument is invalid");
2360 // Ensure that colormap size is large enough
2361 if (colorMapSize() < (index_+1))
2362 colorMapSize(index_+1);
2364 // Set color at index in colormap
2365 (imageptr->colormap)[index_]=color_;
2368 Magick::Color Magick::Image::colorMap(const size_t index_) const
2370 if (!constImage()->colormap)
2372 throwExceptionExplicit(MagickCore::OptionError,
2373 "Image does not contain a colormap");
2377 if (index_ > constImage()->colors-1)
2378 throwExceptionExplicit(MagickCore::OptionError,"Index out of range");
2380 return(Magick::Color((constImage()->colormap)[index_]));
2383 void Magick::Image::colorMatrix(const size_t order_,
2384 const double *color_matrix_)
2390 kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2391 if (kernel_info != (KernelInfo *) NULL)
2393 kernel_info->width=order_;
2394 kernel_info->height=order_;
2395 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2396 order_*sizeof(*kernel_info->values));
2397 if (kernel_info->values != (MagickRealType *) NULL)
2402 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2403 kernel_info->values[i]=color_matrix_[i];
2404 newImage=ColorMatrixImage(image(),kernel_info,exceptionInfo);
2405 replaceImage(newImage);
2407 kernel_info=DestroyKernelInfo(kernel_info);
2409 ThrowImageException;
2412 bool Magick::Image::compare(const Image &reference_)
2422 status=static_cast<bool>(IsImagesEqual(image(),ref.constImage(),
2424 ThrowImageException;
2428 double Magick::Image::compare(const Image &reference_,const MetricType metric_)
2434 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2436 ThrowImageException;
2440 double Magick::Image::compareChannel(const ChannelType channel_,
2441 const Image &reference_,const MetricType metric_)
2447 GetAndSetPPChannelMask(channel_);
2448 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2450 RestorePPChannelMask;
2451 ThrowImageException;
2455 Magick::Image Magick::Image::compare(const Image &reference_,
2456 const MetricType metric_,double *distortion)
2462 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2464 ThrowImageException;
2465 if (newImage == (MagickCore::Image *) NULL)
2466 return(Magick::Image());
2468 return(Magick::Image(newImage));
2471 Magick::Image Magick::Image::compareChannel(const ChannelType channel_,
2472 const Image &reference_,const MetricType metric_,double *distortion)
2478 GetAndSetPPChannelMask(channel_);
2479 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2481 RestorePPChannelMask;
2482 ThrowImageException;
2483 if (newImage == (MagickCore::Image *) NULL)
2484 return(Magick::Image());
2486 return(Magick::Image(newImage));
2489 void Magick::Image::composite(const Image &compositeImage_,
2490 const Geometry &offset_,const CompositeOperator compose_)
2500 ParseMetaGeometry(static_cast<std::string>(offset_).c_str(),&x,&y,&width,
2505 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2507 ThrowImageException;
2510 void Magick::Image::composite(const Image &compositeImage_,
2511 const GravityType gravity_,const CompositeOperator compose_)
2517 SetGeometry(compositeImage_.constImage(),&geometry);
2518 GravityAdjustGeometry(columns(),rows(),gravity_,&geometry);
2521 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2522 geometry.x,geometry.y,exceptionInfo);
2523 ThrowImageException;
2526 void Magick::Image::composite(const Image &compositeImage_,
2527 const ssize_t xOffset_,const ssize_t yOffset_,
2528 const CompositeOperator compose_)
2530 // Image supplied as compositeImage is composited with current image and
2531 // results in updating current image.
2534 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2535 xOffset_,yOffset_,exceptionInfo);
2536 ThrowImageException;
2539 void Magick::Image::connectedComponents(const size_t connectivity_)
2545 newImage=ConnectedComponentsImage(constImage(),connectivity_,exceptionInfo);
2546 replaceImage(newImage);
2547 ThrowImageException;
2550 void Magick::Image::contrast(const bool sharpen_)
2554 ContrastImage(image(),(MagickBooleanType) sharpen_,exceptionInfo);
2555 ThrowImageException;
2558 void Magick::Image::contrastStretch(const double blackPoint_,
2559 const double whitePoint_)
2563 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2564 ThrowImageException;
2567 void Magick::Image::contrastStretchChannel(const ChannelType channel_,
2568 const double blackPoint_,const double whitePoint_)
2572 GetAndSetPPChannelMask(channel_);
2573 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2574 RestorePPChannelMask;
2575 ThrowImageException;
2578 void Magick::Image::convolve(const size_t order_,const double *kernel_)
2584 kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2585 kernel_info->width=order_;
2586 kernel_info->height=order_;
2587 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2588 order_*sizeof(*kernel_info->values));
2589 if (kernel_info->values != (MagickRealType *) NULL)
2594 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2595 kernel_info->values[i]=kernel_[i];
2596 newImage=ConvolveImage(image(),kernel_info,exceptionInfo);
2597 replaceImage(newImage);
2599 kernel_info=DestroyKernelInfo(kernel_info);
2600 ThrowImageException;
2603 void Magick::Image::copyPixels(const Image &source_,const Geometry &geometry_,
2604 const Offset &offset_)
2613 (void) CopyImagePixels(image(),source_.constImage(),&geometry,&offset,
2615 ThrowImageException;
2618 void Magick::Image::crop(const Geometry &geometry_)
2627 newImage=CropImage(constImage(),&cropInfo,exceptionInfo);
2628 replaceImage(newImage);
2629 ThrowImageException;
2632 void Magick::Image::cycleColormap(const ssize_t amount_)
2636 CycleColormapImage(image(),amount_,exceptionInfo);
2637 ThrowImageException;
2640 void Magick::Image::decipher(const std::string &passphrase_)
2644 DecipherImage(image(),passphrase_.c_str(),exceptionInfo);
2645 ThrowImageException;
2648 void Magick::Image::defineSet(const std::string &magick_,
2649 const std::string &key_,bool flag_)
2655 definition=magick_ + ":" + key_;
2657 (void) SetImageOption(imageInfo(),definition.c_str(),"");
2659 DeleteImageOption(imageInfo(),definition.c_str());
2662 bool Magick::Image::defineSet(const std::string &magick_,
2663 const std::string &key_ ) const
2671 key=magick_ + ":" + key_;
2672 option=GetImageOption(constImageInfo(),key.c_str());
2678 void Magick::Image::defineValue(const std::string &magick_,
2679 const std::string &key_,const std::string &value_)
2686 format=magick_ + ":" + key_;
2688 (void) SetImageOption(imageInfo(),format.c_str(),option.c_str());
2691 std::string Magick::Image::defineValue(const std::string &magick_,
2692 const std::string &key_) const
2700 definition=magick_ + ":" + key_;
2701 option=GetImageOption(constImageInfo(),definition.c_str());
2703 return(std::string(option));
2704 return(std::string());
2707 void Magick::Image::deskew(const double threshold_)
2713 newImage=DeskewImage(constImage(),threshold_,exceptionInfo);
2714 replaceImage(newImage);
2715 ThrowImageException;
2718 void Magick::Image::despeckle(void)
2724 newImage=DespeckleImage(constImage(),exceptionInfo);
2725 replaceImage(newImage);
2726 ThrowImageException;
2729 void Magick::Image::display(void)
2732 DisplayImages(imageInfo(),image(),exceptionInfo);
2733 ThrowImageException;
2736 void Magick::Image::distort(const DistortImageMethod method_,
2737 const size_t numberArguments_,const double *arguments_,const bool bestfit_)
2743 newImage=DistortImage(constImage(), method_,numberArguments_,arguments_,
2744 bestfit_ == true ? MagickTrue : MagickFalse,exceptionInfo);
2745 replaceImage(newImage);
2746 ThrowImageException;
2749 void Magick::Image::draw(const Magick::Drawable &drawable_)
2756 wand=DrawAllocateWand(options()->drawInfo(),image());
2760 drawable_.operator()(wand);
2764 ClonePPDrawException(wand);
2765 wand=DestroyDrawingWand(wand);
2766 ThrowPPDrawException(quiet());
2770 void Magick::Image::draw(const std::vector<Magick::Drawable> &drawable_)
2777 wand=DrawAllocateWand(options()->drawInfo(),image());
2781 for (std::vector<Magick::Drawable>::const_iterator p = drawable_.begin();
2782 p != drawable_.end(); p++ )
2784 p->operator()(wand);
2785 if (DrawGetExceptionType(wand) != MagickCore::UndefinedException)
2789 if (DrawGetExceptionType(wand) == MagickCore::UndefinedException)
2792 ClonePPDrawException(wand);
2793 wand=DestroyDrawingWand(wand);
2794 ThrowPPDrawException(quiet());
2798 void Magick::Image::edge(const double radius_)
2804 newImage=EdgeImage(constImage(),radius_,exceptionInfo);
2805 replaceImage(newImage);
2806 ThrowImageException;
2809 void Magick::Image::emboss(const double radius_,const double sigma_)
2815 newImage=EmbossImage(constImage(),radius_,sigma_,exceptionInfo);
2816 replaceImage(newImage);
2817 ThrowImageException;
2820 void Magick::Image::encipher(const std::string &passphrase_)
2824 EncipherImage(image(),passphrase_.c_str(),exceptionInfo);
2825 ThrowImageException;
2828 void Magick::Image::enhance(void)
2834 newImage=EnhanceImage(constImage(),exceptionInfo);
2835 replaceImage(newImage);
2836 ThrowImageException;
2839 void Magick::Image::equalize(void)
2843 EqualizeImage(image(),exceptionInfo);
2844 ThrowImageException;
2847 void Magick::Image::erase(void)
2851 (void) SetImageBackgroundColor(image(),exceptionInfo);
2852 ThrowImageException;
2855 void Magick::Image::extent(const Geometry &geometry_ )
2861 extentInfo=geometry_;
2864 extentInfo.x=geometry_.xOff();
2865 extentInfo.y=geometry_.yOff();
2867 newImage=ExtentImage(image(),&extentInfo,exceptionInfo);
2868 replaceImage(newImage);
2869 ThrowImageException;
2872 void Magick::Image::extent(const Geometry &geometry_,
2873 const Color &backgroundColor_)
2875 backgroundColor(backgroundColor_);
2879 void Magick::Image::extent(const Geometry &geometry_,
2880 const Color &backgroundColor_,const GravityType gravity_)
2882 backgroundColor(backgroundColor_);
2883 extent(geometry_,gravity_);
2886 void Magick::Image::extent(const Geometry &geometry_,
2887 const GravityType gravity_)
2892 SetGeometry(image(),&geometry);
2893 geometry.width=geometry_.width();
2894 geometry.height=geometry_.height();
2895 GravityAdjustGeometry(image()->columns,image()->rows,gravity_,&geometry);
2899 void Magick::Image::flip(void)
2905 newImage=FlipImage(constImage(),exceptionInfo);
2906 replaceImage(newImage);
2907 ThrowImageException;
2910 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2911 const unsigned int alpha_,const bool invert_)
2918 target=static_cast<PixelInfo>(pixelColor(x_,y_));
2919 target.alpha=alpha_;
2921 GetAndSetPPChannelMask(AlphaChannel);
2922 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2923 (MagickBooleanType)invert_,exceptionInfo);
2924 RestorePPChannelMask;
2925 ThrowImageException;
2928 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2929 const unsigned int alpha_,const Color &target_,const bool invert_)
2936 target=static_cast<PixelInfo>(target_);
2937 target.alpha=alpha_;
2939 GetAndSetPPChannelMask(AlphaChannel);
2940 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2941 (MagickBooleanType)invert_,exceptionInfo);
2942 RestorePPChannelMask;
2943 ThrowImageException;
2946 void Magick::Image::floodFillColor(const Geometry &point_,
2947 const Magick::Color &fillColor_,const bool invert_)
2949 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,invert_);
2952 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2953 const Magick::Color &fillColor_,const bool invert_)
2960 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2961 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2964 void Magick::Image::floodFillColor(const Geometry &point_,
2965 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2968 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,borderColor_,invert_);
2971 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2972 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2980 pixel=static_cast<PixelInfo>(borderColor_);
2981 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2984 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2985 const Magick::Image &texture_,const bool invert_)
2987 floodFillTexture(point_.xOff(),point_.yOff(),texture_,invert_);
2990 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2991 const Magick::Image &texture_,const bool invert_)
2998 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2999 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
3002 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
3003 const Magick::Image &texture_,const Magick::Color &borderColor_,
3006 floodFillTexture(point_.xOff(),point_.yOff(),texture_,borderColor_,invert_);
3009 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
3010 const Magick::Image &texture_,const Magick::Color &borderColor_,
3018 pixel=static_cast<PixelInfo>(borderColor_);
3019 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
3022 void Magick::Image::flop(void)
3028 newImage=FlopImage(constImage(),exceptionInfo);
3029 replaceImage(newImage);
3030 ThrowImageException;
3033 void Magick::Image::fontTypeMetrics(const std::string &text_,
3034 TypeMetric *metrics)
3039 drawInfo=options()->drawInfo();
3040 drawInfo->text=const_cast<char *>(text_.c_str());
3042 GetTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3044 ThrowImageException;
3047 void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
3048 TypeMetric *metrics)
3053 drawInfo=options()->drawInfo();
3054 drawInfo->text=const_cast<char *>(text_.c_str());
3056 GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3058 ThrowImageException;
3061 void Magick::Image::frame(const Geometry &geometry_)
3069 info.x=static_cast<ssize_t>(geometry_.width());
3070 info.y=static_cast<ssize_t>(geometry_.height());
3071 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3072 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3073 info.outer_bevel=geometry_.xOff();
3074 info.inner_bevel=geometry_.yOff();
3077 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3078 replaceImage(newImage);
3079 ThrowImageException;
3082 void Magick::Image::frame(const size_t width_,const size_t height_,
3083 const ssize_t innerBevel_,const ssize_t outerBevel_)
3091 info.x=static_cast<ssize_t>(width_);
3092 info.y=static_cast<ssize_t>(height_);
3093 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3094 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3095 info.outer_bevel=static_cast<ssize_t>(outerBevel_);
3096 info.inner_bevel=static_cast<ssize_t>(innerBevel_);
3099 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3100 replaceImage(newImage);
3101 ThrowImageException;
3104 void Magick::Image::fx(const std::string expression_)
3110 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3111 replaceImage(newImage);
3112 ThrowImageException;
3115 void Magick::Image::fx(const std::string expression_,
3116 const Magick::ChannelType channel_)
3122 GetAndSetPPChannelMask(channel_);
3123 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3124 RestorePPChannelMask;
3125 replaceImage(newImage);
3126 ThrowImageException;
3129 void Magick::Image::gamma(const double gamma_)
3133 GammaImage(image(),gamma_,exceptionInfo);
3134 ThrowImageException;
3137 void Magick::Image::gamma(const double gammaRed_,const double gammaGreen_,
3138 const double gammaBlue_)
3142 GetAndSetPPChannelMask(RedChannel);
3143 (void) GammaImage(image(),gammaRed_,exceptionInfo);
3144 SetPPChannelMask(GreenChannel);
3145 (void) GammaImage(image(),gammaGreen_,exceptionInfo);
3146 SetPPChannelMask(BlueChannel);
3147 (void) GammaImage(image(),gammaBlue_,exceptionInfo);
3148 RestorePPChannelMask;
3149 ThrowImageException;
3152 void Magick::Image::gaussianBlur(const double width_,const double sigma_)
3158 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3159 replaceImage(newImage);
3160 ThrowImageException;
3163 void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
3164 const double width_,const double sigma_)
3170 GetAndSetPPChannelMask(channel_);
3171 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3172 RestorePPChannelMask;
3173 replaceImage(newImage);
3174 ThrowImageException;
3177 const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
3178 const ssize_t y_,const size_t columns_,const size_t rows_) const
3184 p=GetVirtualPixels(constImage(),x_, y_,columns_, rows_,exceptionInfo);
3185 ThrowImageException;
3189 const void *Magick::Image::getConstMetacontent(void) const
3194 result=GetVirtualMetacontent(constImage());
3197 throwExceptionExplicit(MagickCore::OptionError,
3198 "Unable to retrieve meta content.");
3203 void *Magick::Image::getMetacontent(void )
3208 result=GetAuthenticMetacontent(image());
3211 throwExceptionExplicit(MagickCore::OptionError,
3212 "Unable to retrieve meta content.");
3217 Magick::Quantum *Magick::Image::getPixels(const ssize_t x_,const ssize_t y_,
3218 const size_t columns_,const size_t rows_)
3225 result=GetAuthenticPixels(image(),x_, y_,columns_,rows_,exceptionInfo);
3226 ThrowImageException;
3231 void Magick::Image::grayscale(const PixelIntensityMethod method_)
3235 (void) GrayscaleImage(image(),method_,exceptionInfo);
3236 ThrowImageException;
3239 void Magick::Image::haldClut(const Image &clutImage_)
3243 (void) HaldClutImage(image(),clutImage_.constImage(),exceptionInfo);
3244 ThrowImageException;
3247 void Magick::Image::houghLine(const size_t width_,const size_t height_,
3248 const size_t threshold_)
3254 newImage=HoughLineImage(constImage(),width_,height_,threshold_,
3256 replaceImage(newImage);
3257 ThrowImageException;
3260 Magick::ImageType Magick::Image::identifyType(void) const
3266 image_type=IdentifyImageType(constImage(),exceptionInfo);
3267 ThrowImageException;
3271 void Magick::Image::implode(const double factor_)
3277 newImage=ImplodeImage(constImage(),factor_,image()->interpolate,
3279 replaceImage(newImage);
3280 ThrowImageException;
3283 void Magick::Image::inverseFourierTransform(const Image &phase_)
3285 inverseFourierTransform(phase_,true);
3288 void Magick::Image::inverseFourierTransform(const Image &phase_,
3289 const bool magnitude_)
3295 newImage=InverseFourierTransformImage(constImage(),phase_.constImage(),
3296 magnitude_ == true ? MagickTrue : MagickFalse,exceptionInfo);
3297 replaceImage(newImage);
3298 ThrowImageException;
3301 void Magick::Image::kuwahara(const double radius_,const double sigma_)
3307 newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3308 replaceImage(newImage);
3309 ThrowImageException;
3312 void Magick::Image::kuwaharaChannel(const ChannelType channel_,
3313 const double radius_,const double sigma_)
3319 GetAndSetPPChannelMask(channel_);
3320 newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3321 replaceImage(newImage);
3322 RestorePPChannelMask;
3323 ThrowImageException;
3326 void Magick::Image::level(const double blackPoint_,const double whitePoint_,
3327 const double gamma_)
3331 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3332 ThrowImageException;
3335 void Magick::Image::levelChannel(const ChannelType channel_,
3336 const double blackPoint_,const double whitePoint_,const double gamma_)
3340 GetAndSetPPChannelMask(channel_);
3341 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3342 RestorePPChannelMask;
3343 ThrowImageException;
3346 void Magick::Image::levelColors(const Color &blackColor_,
3347 const Color &whiteColor_,const bool invert_)
3355 black=static_cast<PixelInfo>(blackColor_);
3356 white=static_cast<PixelInfo>(whiteColor_);
3358 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3359 MagickTrue : MagickFalse,exceptionInfo);
3360 ThrowImageException;
3363 void Magick::Image::levelColorsChannel(const ChannelType channel_,
3364 const Color &blackColor_,const Color &whiteColor_,const bool invert_)
3372 black=static_cast<PixelInfo>(blackColor_);
3373 white=static_cast<PixelInfo>(whiteColor_);
3375 GetAndSetPPChannelMask(channel_);
3376 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3377 MagickTrue : MagickFalse,exceptionInfo);
3378 RestorePPChannelMask;
3379 ThrowImageException;
3382 void Magick::Image::linearStretch(const double blackPoint_,
3383 const double whitePoint_)
3387 LinearStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
3388 ThrowImageException;
3391 void Magick::Image::liquidRescale(const Geometry &geometry_)
3404 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3408 newImage=LiquidRescaleImage(image(),width,height,x,y,exceptionInfo);
3409 replaceImage(newImage);
3410 ThrowImageException;
3413 void Magick::Image::magnify(void)
3419 newImage=MagnifyImage(constImage(),exceptionInfo);
3420 replaceImage(newImage);
3421 ThrowImageException;
3424 void Magick::Image::map(const Image &mapImage_,const bool dither_)
3428 options()->quantizeDither(dither_);
3429 RemapImage(options()->quantizeInfo(),image(),mapImage_.constImage(),
3431 ThrowImageException;
3434 void Magick::Image::medianFilter(const double radius_)
3440 newImage=StatisticImage(image(),MedianStatistic,(size_t) radius_,
3441 (size_t) radius_,exceptionInfo);
3442 replaceImage(newImage);
3443 ThrowImageException;
3446 void Magick::Image::minify(void)
3452 newImage=MinifyImage(constImage(),exceptionInfo);
3453 replaceImage(newImage);
3454 ThrowImageException;
3457 void Magick::Image::modulate(const double brightness_,const double saturation_,
3461 modulate[MagickPathExtent + 1];
3463 FormatLocaleString(modulate,MagickPathExtent,"%3.6f,%3.6f,%3.6f",brightness_,
3468 ModulateImage(image(),modulate,exceptionInfo);
3469 ThrowImageException;
3472 Magick::ImageMoments Magick::Image::moments(void) const
3474 return(ImageMoments(*this));
3477 void Magick::Image::morphology(const MorphologyMethod method_,
3478 const std::string kernel_,const ssize_t iterations_)
3487 kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3488 if (kernel == (KernelInfo *) NULL)
3489 throwExceptionExplicit(MagickCore::OptionError,"Unable to parse kernel.");
3490 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3492 replaceImage(newImage);
3493 kernel=DestroyKernelInfo(kernel);
3494 ThrowImageException;
3497 void Magick::Image::morphology(const MorphologyMethod method_,
3498 const KernelInfoType kernel_,const std::string arguments_,
3499 const ssize_t iterations_)
3507 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3508 if (option == (const char *)NULL)
3510 throwExceptionExplicit(MagickCore::OptionError,
3511 "Unable to determine kernel type.");
3514 kernel=std::string(option);
3515 if (!arguments_.empty())
3516 kernel+=":"+arguments_;
3518 morphology(method_,kernel,iterations_);
3521 void Magick::Image::morphologyChannel(const ChannelType channel_,
3522 const MorphologyMethod method_,const std::string kernel_,
3523 const ssize_t iterations_)
3533 kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3534 if (kernel == (KernelInfo *)NULL)
3536 throwExceptionExplicit(MagickCore::OptionError,
3537 "Unable to parse kernel.");
3540 GetAndSetPPChannelMask(channel_);
3541 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3543 RestorePPChannelMask;
3544 replaceImage(newImage);
3545 kernel=DestroyKernelInfo(kernel);
3546 ThrowImageException;
3549 void Magick::Image::morphologyChannel(const ChannelType channel_,
3550 const MorphologyMethod method_,const KernelInfoType kernel_,
3551 const std::string arguments_,const ssize_t iterations_)
3559 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3560 if (option == (const char *)NULL)
3562 throwExceptionExplicit(MagickCore::OptionError,
3563 "Unable to determine kernel type.");
3567 kernel=std::string(option);
3568 if (!arguments_.empty())
3569 kernel+=":"+arguments_;
3571 morphologyChannel(channel_,method_,kernel,iterations_);
3574 void Magick::Image::motionBlur(const double radius_,const double sigma_,
3575 const double angle_)
3581 newImage=MotionBlurImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
3582 replaceImage(newImage);
3583 ThrowImageException;
3586 void Magick::Image::negate(const bool grayscale_)
3590 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3591 ThrowImageException;
3594 void Magick::Image::negateChannel(const ChannelType channel_,
3595 const bool grayscale_)
3599 GetAndSetPPChannelMask(channel_);
3600 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3601 RestorePPChannelMask;
3602 ThrowImageException;
3605 void Magick::Image::normalize(void)
3609 NormalizeImage(image(),exceptionInfo);
3610 ThrowImageException;
3613 void Magick::Image::oilPaint(const double radius_,const double sigma_)
3619 newImage=OilPaintImage(constImage(),radius_,sigma_,exceptionInfo);
3620 replaceImage(newImage);
3621 ThrowImageException;
3624 void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_,
3635 if (!opaqueColor_.isValid())
3636 throwExceptionExplicit(MagickCore::OptionError,
3637 "Opaque color argument is invalid");
3639 if (!penColor_.isValid())
3640 throwExceptionExplicit(MagickCore::OptionError,
3641 "Pen color argument is invalid");
3644 opaqueColor=opaqueColor_;
3648 (void) QueryColorCompliance(opaqueColor.c_str(),AllCompliance,&opaque,
3650 (void) QueryColorCompliance(penColor.c_str(),AllCompliance,&pen,
3652 OpaquePaintImage(image(),&opaque,&pen,invert_ ? MagickTrue : MagickFalse,
3654 ThrowImageException;
3657 void Magick::Image::orderedDither(std::string thresholdMap_)
3661 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3662 ThrowImageException;
3665 void Magick::Image::orderedDitherChannel(const ChannelType channel_,
3666 std::string thresholdMap_)
3670 GetAndSetPPChannelMask(channel_);
3671 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3672 RestorePPChannelMask;
3673 ThrowImageException;
3676 void Magick::Image::perceptible(const double epsilon_)
3680 PerceptibleImage(image(),epsilon_,exceptionInfo);
3681 ThrowImageException;
3684 void Magick::Image::perceptibleChannel(const ChannelType channel_,
3685 const double epsilon_)
3689 GetAndSetPPChannelMask(channel_);
3690 PerceptibleImage(image(),epsilon_,exceptionInfo);
3691 RestorePPChannelMask;
3692 ThrowImageException;
3695 Magick::ImagePerceptualHash Magick::Image::perceptualHash() const
3697 return(ImagePerceptualHash(*this));
3700 void Magick::Image::ping(const std::string &imageSpec_)
3706 options()->fileName(imageSpec_);
3707 newImage=PingImage(imageInfo(),exceptionInfo);
3708 read(newImage,exceptionInfo);
3711 void Magick::Image::ping(const Blob& blob_)
3717 newImage=PingBlob(imageInfo(),blob_.data(),blob_.length(),exceptionInfo);
3718 read(newImage,exceptionInfo);
3721 void Magick::Image::pixelColor(const ssize_t x_,const ssize_t y_,
3722 const Color &color_)
3730 // Test arguments to ensure they are within the image.
3731 if (y_ > (ssize_t) rows() || x_ > (ssize_t) columns())
3732 throwExceptionExplicit(MagickCore::OptionError,
3733 "Access outside of image boundary");
3737 // Set image to DirectClass
3738 classType(DirectClass );
3741 Pixels pixels(*this);
3743 pixel=pixels.get(x_, y_, 1, 1 );
3745 MagickCore::SetPixelViaPixelInfo(constImage(),&packet,pixel);
3746 // Tell ImageMagick that pixels have been updated
3750 Magick::Color Magick::Image::pixelColor(const ssize_t x_,
3751 const ssize_t y_) const
3756 pixel=getConstPixels(x_,y_,1,1);
3762 MagickCore::GetPixelInfoPixel(constImage(),pixel,&packet);
3763 return(Color(packet));
3766 return(Color()); // invalid
3769 void Magick::Image::polaroid(const std::string &caption_,const double angle_,
3770 const PixelInterpolateMethod method_)
3776 newImage=PolaroidImage(constImage(),options()->drawInfo(),caption_.c_str(),
3777 angle_,method_,exceptionInfo);
3778 replaceImage(newImage);
3779 ThrowImageException;
3782 void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
3786 PosterizeImage(image(),levels_,method_,exceptionInfo);
3787 ThrowImageException;
3790 void Magick::Image::posterizeChannel(const ChannelType channel_,
3791 const size_t levels_,const DitherMethod method_)
3795 GetAndSetPPChannelMask(channel_);
3796 PosterizeImage(image(),levels_,method_,exceptionInfo);
3797 RestorePPChannelMask;
3798 ThrowImageException;
3801 void Magick::Image::process(std::string name_,const ssize_t argc,
3807 (void) InvokeDynamicImageFilter(name_.c_str(),&image(),argc,argv,
3809 ThrowImageException;
3812 void Magick::Image::profile(const std::string name_,
3813 const Magick::Blob &profile_)
3817 (void) ProfileImage(image(),name_.c_str(),(unsigned char *)profile_.data(),
3818 profile_.length(),exceptionInfo);
3819 ThrowImageException;
3822 Magick::Blob Magick::Image::profile(const std::string name_) const
3827 profile=GetImageProfile(constImage(),name_.c_str());
3829 if (profile == (StringInfo *) NULL)
3831 return(Blob((void*) GetStringInfoDatum(profile),GetStringInfoLength(
3835 void Magick::Image::quantize(const bool measureError_)
3840 options()->quantizeInfo()->measure_error=MagickTrue;
3842 options()->quantizeInfo()->measure_error=MagickFalse;
3845 QuantizeImage(options()->quantizeInfo(),image(),exceptionInfo);
3846 ThrowImageException;
3849 void Magick::Image::quantumOperator(const ChannelType channel_,
3850 const MagickEvaluateOperator operator_,double rvalue_)
3853 GetAndSetPPChannelMask(channel_);
3854 EvaluateImage(image(),operator_,rvalue_,exceptionInfo);
3855 RestorePPChannelMask;
3856 ThrowImageException;
3859 void Magick::Image::quantumOperator(const ssize_t x_,const ssize_t y_,
3860 const size_t columns_,const size_t rows_,const ChannelType channel_,
3861 const MagickEvaluateOperator operator_,const double rvalue_)
3869 geometry.width = columns_;
3870 geometry.height = rows_;
3875 cropImage=CropImage(image(),&geometry,exceptionInfo);
3876 GetAndSetPPChannelMask(channel_);
3877 EvaluateImage(cropImage,operator_,rvalue_,exceptionInfo);
3878 RestorePPChannelMask;
3879 (void) CompositeImage(image(),cropImage,image()->alpha_trait ==
3880 BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
3881 geometry.x,geometry.y,exceptionInfo );
3882 cropImage=DestroyImageList(cropImage);
3883 ThrowImageException;
3886 void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
3889 raiseInfo=geometry_;
3893 RaiseImage(image(),&raiseInfo,raisedFlag_ == true ? MagickTrue : MagickFalse,
3895 ThrowImageException;
3898 void Magick::Image::randomThreshold(const Geometry &thresholds_)
3901 (void) RandomThresholdImage(image(),static_cast<std::string>(
3902 thresholds_).c_str(),exceptionInfo);
3903 ThrowImageException;
3906 void Magick::Image::randomThresholdChannel(const ChannelType channel_,
3907 const Geometry &thresholds_)
3911 GetAndSetPPChannelMask(channel_);
3912 (void) RandomThresholdImage(image(),static_cast<std::string>(
3913 thresholds_).c_str(),exceptionInfo);
3914 RestorePPChannelMask;
3915 ThrowImageException;
3918 void Magick::Image::read(const Blob &blob_)
3924 newImage=BlobToImage(imageInfo(),static_cast<const void *>(blob_.data()),
3925 blob_.length(),exceptionInfo);
3926 read(newImage,exceptionInfo);
3929 void Magick::Image::read(const Blob &blob_,const Geometry &size_)
3935 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3936 const size_t depth_)
3943 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3944 const size_t depth_,const std::string &magick_)
3949 // Set explicit image format
3950 fileName(magick_ + ':');
3954 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3955 const std::string &magick_)
3959 // Set explicit image format
3960 fileName(magick_ + ':');
3964 void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_)
3970 void Magick::Image::read(const size_t width_,const size_t height_,
3971 const std::string &map_,const StorageType type_,const void *pixels_)
3977 newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
3979 replaceImage(newImage);
3980 ThrowImageException;
3983 void Magick::Image::read(const std::string &imageSpec_)
3989 options()->fileName(imageSpec_);
3990 newImage=ReadImage(imageInfo(),exceptionInfo);
3991 read(newImage,exceptionInfo);
3994 void Magick::Image::readPixels(const Magick::QuantumType quantum_,
3995 const unsigned char *source_)
4000 quantum_info=AcquireQuantumInfo(imageInfo(),image());
4002 ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4003 quantum_,source_,exceptionInfo);
4004 quantum_info=DestroyQuantumInfo(quantum_info);
4005 ThrowImageException;
4008 void Magick::Image::reduceNoise(void)
4013 void Magick::Image::reduceNoise(const size_t order_)
4019 newImage=StatisticImage(constImage(),NonpeakStatistic,order_,
4020 order_,exceptionInfo);
4021 replaceImage(newImage);
4022 ThrowImageException;
4025 void Magick::Image::repage()
4028 options()->page(Geometry());
4029 image()->page.width = 0;
4030 image()->page.height = 0;
4031 image()->page.x = 0;
4032 image()->page.y = 0;
4035 void Magick::Image::resample(const Point &density_)
4041 newImage=ResampleImage(constImage(),density_.x(),density_.y(),
4042 image()->filter,exceptionInfo);
4043 replaceImage(newImage);
4044 ThrowImageException;
4047 void Magick::Image::resize(const Geometry &geometry_)
4060 // Calculate new size. This code should be supported using binary arguments
4061 // in the ImageMagick library.
4062 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4066 newImage=ResizeImage(constImage(),width,height,image()->filter,
4068 replaceImage(newImage);
4069 ThrowImageException;
4072 void Magick::Image::roll(const Geometry &roll_)
4078 newImage=RollImage(constImage(),roll_.xOff(),roll_.yOff(),exceptionInfo);
4079 replaceImage(newImage);
4080 ThrowImageException;
4083 void Magick::Image::roll(const size_t columns_,const size_t rows_)
4089 newImage=RollImage(constImage(),static_cast<ssize_t>(columns_),
4090 static_cast<ssize_t>(rows_),exceptionInfo);
4091 replaceImage(newImage);
4092 ThrowImageException;
4095 void Magick::Image::rotate(const double degrees_)
4101 newImage=RotateImage(constImage(),degrees_,exceptionInfo);
4102 replaceImage(newImage);
4103 ThrowImageException;
4106 void Magick::Image::rotationalBlur(const double angle_)
4112 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4113 replaceImage(newImage);
4114 ThrowImageException;
4117 void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
4118 const double angle_)
4124 GetAndSetPPChannelMask(channel_);
4125 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4126 RestorePPChannelMask;
4127 replaceImage(newImage);
4128 ThrowImageException;
4131 void Magick::Image::sample(const Geometry &geometry_)
4144 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4148 newImage=SampleImage(constImage(),width,height,exceptionInfo);
4149 replaceImage(newImage);
4150 ThrowImageException;
4153 void Magick::Image::scale(const Geometry &geometry_)
4166 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4170 newImage=ScaleImage(constImage(),width,height,exceptionInfo);
4171 replaceImage(newImage);
4172 ThrowImageException;
4175 void Magick::Image::segment(const double clusterThreshold_,
4176 const double smoothingThreshold_)
4180 SegmentImage(image(),options()->quantizeColorSpace(),
4181 (MagickBooleanType) options()->verbose(),clusterThreshold_,
4182 smoothingThreshold_,exceptionInfo);
4183 SyncImage(image(),exceptionInfo);
4184 ThrowImageException;
4187 void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
4188 const double threshold_)
4194 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4196 replaceImage(newImage);
4197 ThrowImageException;
4200 void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
4201 const double radius_,const double sigma_,const double threshold_)
4207 GetAndSetPPChannelMask(channel_);
4208 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4210 RestorePPChannelMask;
4211 replaceImage(newImage);
4212 ThrowImageException;
4215 Magick::Image Magick::Image::separate(const ChannelType channel_) const
4221 image=SeparateImage(constImage(),channel_,exceptionInfo);
4222 ThrowImageException;
4223 if (image == (MagickCore::Image *) NULL)
4224 return(Magick::Image());
4226 return(Magick::Image(image));
4229 void Magick::Image::sepiaTone(const double threshold_)
4235 newImage=SepiaToneImage(constImage(),threshold_,exceptionInfo);
4236 replaceImage(newImage);
4237 ThrowImageException;
4240 Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
4241 const size_t columns_,const size_t rows_)
4248 result=QueueAuthenticPixels(image(),x_,y_,columns_,rows_,exceptionInfo);
4249 ThrowImageException;
4253 void Magick::Image::shade(const double azimuth_,const double elevation_,
4254 const bool colorShading_)
4260 newImage=ShadeImage(constImage(),colorShading_ == true ?
4261 MagickTrue : MagickFalse,azimuth_,elevation_,exceptionInfo);
4262 replaceImage(newImage);
4263 ThrowImageException;
4266 void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
4267 const ssize_t x_,const ssize_t y_)
4273 newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
4275 replaceImage(newImage);
4276 ThrowImageException;
4279 void Magick::Image::sharpen(const double radius_,const double sigma_)
4285 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4286 replaceImage(newImage);
4287 ThrowImageException;
4290 void Magick::Image::sharpenChannel(const ChannelType channel_,
4291 const double radius_,const double sigma_)
4297 GetAndSetPPChannelMask(channel_);
4298 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4299 RestorePPChannelMask;
4300 replaceImage(newImage);
4301 ThrowImageException;
4304 void Magick::Image::shave(const Geometry &geometry_)
4310 shaveInfo=geometry_;
4313 newImage=ShaveImage(constImage(),&shaveInfo,exceptionInfo);
4314 replaceImage(newImage);
4315 ThrowImageException;
4318 void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
4324 newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,exceptionInfo);
4325 replaceImage(newImage);
4326 ThrowImageException;
4329 void Magick::Image::sigmoidalContrast(const bool sharpen_,
4330 const double contrast,const double midpoint)
4334 (void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
4335 midpoint,exceptionInfo);
4336 ThrowImageException;
4339 std::string Magick::Image::signature(const bool force_) const
4341 return(_imgRef->signature());
4344 void Magick::Image::sketch(const double radius_,const double sigma_,
4345 const double angle_)
4351 newImage=SketchImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
4352 replaceImage(newImage);
4353 ThrowImageException;
4356 void Magick::Image::solarize(const double factor_)
4360 SolarizeImage(image(),factor_,exceptionInfo);
4361 ThrowImageException;
4364 void Magick::Image::sparseColor(const ChannelType channel_,
4365 const SparseColorMethod method_,const size_t numberArguments_,
4366 const double *arguments_)
4372 GetAndSetPPChannelMask(channel_);
4373 newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
4375 RestorePPChannelMask;
4376 replaceImage(newImage);
4377 ThrowImageException;
4380 void Magick::Image::splice(const Geometry &geometry_)
4386 spliceInfo=geometry_;
4389 newImage=SpliceImage(constImage(),&spliceInfo,exceptionInfo);
4390 replaceImage(newImage);
4391 ThrowImageException;
4394 void Magick::Image::splice(const Geometry &geometry_,
4395 const Color &backgroundColor_)
4397 backgroundColor(backgroundColor_);
4401 void Magick::Image::splice(const Geometry &geometry_,
4402 const Color &backgroundColor_,const GravityType gravity_)
4404 backgroundColor(backgroundColor_);
4405 image()->gravity=gravity_;
4409 void Magick::Image::spread(const size_t amount_)
4415 newImage=SpreadImage(constImage(),image()->interpolate,amount_,exceptionInfo);
4416 replaceImage(newImage);
4417 ThrowImageException;
4420 Magick::ImageStatistics Magick::Image::statistics() const
4422 return(ImageStatistics(*this));
4425 void Magick::Image::stegano(const Image &watermark_)
4431 newImage=SteganoImage(constImage(),watermark_.constImage(),exceptionInfo);
4432 replaceImage(newImage);
4433 ThrowImageException;
4436 void Magick::Image::stereo(const Image &rightImage_)
4442 newImage=StereoImage(constImage(),rightImage_.constImage(),exceptionInfo);
4443 replaceImage(newImage);
4444 ThrowImageException;
4447 void Magick::Image::strip(void)
4451 StripImage(image(),exceptionInfo);
4452 ThrowImageException;
4455 Magick::Image Magick::Image::subImageSearch(const Image &reference_,
4456 const MetricType metric_,Geometry *offset_,double *similarityMetric_,
4457 const double similarityThreshold)
4466 newImage=SimilarityImage(image(),reference_.constImage(),metric_,
4467 similarityThreshold,&offset,similarityMetric_,exceptionInfo);
4468 ThrowImageException;
4469 if (offset_ != (Geometry *) NULL)
4471 if (newImage == (MagickCore::Image *) NULL)
4472 return(Magick::Image());
4474 return(Magick::Image(newImage));
4477 void Magick::Image::swirl(const double degrees_)
4483 newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
4485 replaceImage(newImage);
4486 ThrowImageException;
4489 void Magick::Image::syncPixels(void)
4492 (void) SyncAuthenticPixels(image(),exceptionInfo);
4493 ThrowImageException;
4496 void Magick::Image::texture(const Image &texture_)
4500 TextureImage(image(),texture_.constImage(),exceptionInfo);
4501 ThrowImageException;
4504 void Magick::Image::threshold(const double threshold_)
4508 BilevelImage(image(),threshold_,exceptionInfo);
4509 ThrowImageException;
4512 void Magick::Image::thumbnail(const Geometry &geometry_)
4525 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4529 newImage=ThumbnailImage(constImage(),width,height,exceptionInfo);
4530 replaceImage(newImage);
4531 ThrowImageException;
4534 void Magick::Image::tint(const std::string opacity_)
4543 color=static_cast<PixelInfo>(constOptions()->fillColor());
4544 newImage=TintImage(constImage(),opacity_.c_str(),&color,exceptionInfo);
4545 replaceImage(newImage);
4546 ThrowImageException;
4549 void Magick::Image::transform(const Geometry &imageGeometry_)
4553 TransformImage(&(image()),0,std::string(imageGeometry_).c_str(),
4555 ThrowImageException;
4558 void Magick::Image::transform(const Geometry &imageGeometry_,
4559 const Geometry &cropGeometry_)
4563 TransformImage(&(image()),std::string(cropGeometry_).c_str(),std::string(
4564 imageGeometry_).c_str(), exceptionInfo);
4565 ThrowImageException;
4568 void Magick::Image::transformOrigin(const double x_,const double y_)
4571 options()->transformOrigin(x_,y_);
4574 void Magick::Image::transformReset(void)
4577 options()->transformReset();
4580 void Magick::Image::transformScale(const double sx_,const double sy_)
4583 options()->transformScale(sx_,sy_);
4586 void Magick::Image::transparent(const Color &color_)
4594 if (!color_.isValid())
4595 throwExceptionExplicit(MagickCore::OptionError,
4596 "Color argument is invalid");
4600 (void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
4603 TransparentPaintImage(image(),&target,TransparentAlpha,MagickFalse,
4605 ThrowImageException;
4608 void Magick::Image::transparentChroma(const Color &colorLow_,
4609 const Color &colorHigh_)
4619 if (!colorLow_.isValid() || !colorHigh_.isValid())
4620 throwExceptionExplicit(MagickCore::OptionError,
4621 "Color argument is invalid");
4624 colorHigh=colorHigh_;
4627 (void) QueryColorCompliance(colorLow.c_str(),AllCompliance,&targetLow,
4629 (void) QueryColorCompliance(colorHigh.c_str(),AllCompliance,&targetHigh,
4632 TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
4633 MagickFalse,exceptionInfo);
4634 ThrowImageException;
4637 void Magick::Image::transpose(void)
4643 newImage=TransposeImage(constImage(),exceptionInfo);
4644 replaceImage(newImage);
4645 ThrowImageException;
4648 void Magick::Image::transverse(void)
4654 newImage=TransverseImage(constImage(),exceptionInfo);
4655 replaceImage(newImage);
4656 ThrowImageException;
4659 void Magick::Image::trim(void)
4665 newImage=TrimImage(constImage(),exceptionInfo);
4666 replaceImage(newImage);
4667 ThrowImageException;
4670 Magick::Image Magick::Image::uniqueColors(void) const
4676 image=UniqueImageColors(constImage(),exceptionInfo);
4677 ThrowImageException;
4678 if (image == (MagickCore::Image *) NULL)
4679 return(Magick::Image());
4681 return(Magick::Image(image));
4684 void Magick::Image::unsharpmask(const double radius_,const double sigma_,
4685 const double amount_,const double threshold_)
4691 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4693 replaceImage(newImage);
4694 ThrowImageException;
4697 void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
4698 const double radius_,const double sigma_,const double amount_,
4699 const double threshold_)
4705 GetAndSetPPChannelMask(channel_);
4706 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4708 RestorePPChannelMask;
4709 replaceImage(newImage);
4710 ThrowImageException;
4713 void Magick::Image::vignette(const double radius_,const double sigma_,
4714 const ssize_t x_,const ssize_t y_)
4720 newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,exceptionInfo);
4721 replaceImage(newImage);
4722 ThrowImageException;
4725 void Magick::Image::wave(const double amplitude_,const double wavelength_)
4731 newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
4733 replaceImage(newImage);
4734 ThrowImageException;
4737 void Magick::Image::whiteThreshold(const std::string &threshold_)
4741 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4742 ThrowImageException;
4745 void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
4746 const std::string &threshold_)
4750 GetAndSetPPChannelMask(channel_);
4751 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4752 RestorePPChannelMask;
4753 ThrowImageException;
4756 void Magick::Image::write(Blob *blob_)
4766 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4768 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4769 ThrowImageException;
4772 void Magick::Image::write(Blob *blob_,const std::string &magick_)
4783 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4785 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4786 ThrowImageException;
4789 void Magick::Image::write(Blob *blob_,const std::string &magick_,
4790 const size_t depth_)
4802 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4804 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4805 ThrowImageException;
4808 void Magick::Image::write(const ssize_t x_,const ssize_t y_,
4809 const size_t columns_,const size_t rows_,const std::string &map_,
4810 const StorageType type_,void *pixels_)
4813 ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
4815 ThrowImageException;
4818 void Magick::Image::write(const std::string &imageSpec_)
4821 fileName(imageSpec_);
4823 WriteImage(constImageInfo(),image(),exceptionInfo);
4824 ThrowImageException;
4827 void Magick::Image::writePixels(const Magick::QuantumType quantum_,
4828 unsigned char *destination_)
4833 quantum_info=AcquireQuantumInfo(imageInfo(),image());
4835 ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4836 quantum_,destination_, exceptionInfo);
4837 quantum_info=DestroyQuantumInfo(quantum_info);
4838 ThrowImageException;
4841 void Magick::Image::zoom(const Geometry &geometry_)
4854 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4858 newImage=ResizeImage(constImage(),width,height,image()->filter,exceptionInfo);
4859 replaceImage(newImage);
4860 ThrowImageException;
4863 Magick::Image::Image(MagickCore::Image *image_)
4864 : _imgRef(new ImageRef(image_))
4868 MagickCore::Image *&Magick::Image::image(void)
4870 return(_imgRef->image());
4873 const MagickCore::Image *Magick::Image::constImage(void) const
4875 return(_imgRef->image());
4878 MagickCore::ImageInfo *Magick::Image::imageInfo(void)
4880 return(_imgRef->options()->imageInfo());
4883 const MagickCore::ImageInfo *Magick::Image::constImageInfo(void) const
4885 return(_imgRef->options()->imageInfo());
4888 Magick::Options *Magick::Image::options(void)
4890 return(_imgRef->options());
4893 const Magick::Options *Magick::Image::constOptions(void) const
4895 return(_imgRef->options());
4898 MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)
4900 return(_imgRef->options()->quantizeInfo());
4903 const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
4905 return(_imgRef->options()->quantizeInfo());
4908 void Magick::Image::modifyImage(void)
4910 if (!_imgRef->isShared())
4914 replaceImage(CloneImage(image(),0,0,MagickTrue,exceptionInfo));
4915 ThrowImageException;
4918 MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
4928 image=AcquireImage(constImageInfo(),exceptionInfo);
4929 ThrowImageException;
4932 _imgRef=ImageRef::replaceImage(_imgRef,image);
4936 void Magick::Image::read(MagickCore::Image *image,
4937 MagickCore::ExceptionInfo *exceptionInfo)
4939 // Ensure that multiple image frames were not read.
4940 if (image != (MagickCore::Image *) NULL &&
4941 image->next != (MagickCore::Image *) NULL)
4946 // Destroy any extra image frames
4948 image->next=(MagickCore::Image *) NULL;
4949 next->previous=(MagickCore::Image *) NULL;
4950 DestroyImageList(next);
4952 replaceImage(image);
4953 if (exceptionInfo->severity == MagickCore::UndefinedException &&
4954 image == (MagickCore::Image *) NULL)
4956 (void) MagickCore::DestroyExceptionInfo(exceptionInfo);
4958 throwExceptionExplicit(MagickCore::ImageWarning,
4959 "No image was loaded.");
4961 ThrowImageException;
4964 void Magick::Image::floodFill(const ssize_t x_,const ssize_t y_,
4965 const Magick::Image *fillPattern_,const Magick::Color &fill_,
4966 const MagickCore::PixelInfo *target_,const bool invert_)
4974 // Set drawing fill pattern or fill color
4975 fillColor=options()->fillColor();
4976 fillPattern=(MagickCore::Image *)NULL;
4977 if (options()->fillPattern() != (MagickCore::Image *)NULL)
4980 fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
4982 ThrowImageException;
4985 if (fillPattern_ == (Magick::Image *)NULL)
4987 options()->fillPattern((MagickCore::Image *)NULL);
4988 options()->fillColor(fill_);
4991 options()->fillPattern(fillPattern_->constImage());
4994 (void) FloodfillPaintImage(image(),options()->drawInfo(),
4995 target_,static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),
4996 (MagickBooleanType) invert_,exceptionInfo);
4998 options()->fillColor(fillColor);
4999 options()->fillPattern(fillPattern);
5000 ThrowImageException;