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) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2028 (void) AutoLevelImage(image(),exceptionInfo);
2029 ThrowImageException;
2032 void Magick::Image::autoLevelChannel(const ChannelType channel_)
2036 GetAndSetPPChannelMask(channel_);
2037 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2038 (void) AutoLevelImage(image(),exceptionInfo);
2039 RestorePPChannelMask;
2040 ThrowImageException;
2043 void Magick::Image::autoOrient(void)
2048 if (image()->orientation == UndefinedOrientation ||
2049 image()->orientation == TopLeftOrientation)
2053 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2054 newImage=AutoOrientImage(constImage(),image()->orientation,exceptionInfo);
2055 replaceImage(newImage);
2056 ThrowImageException;
2059 void Magick::Image::blackThreshold(const std::string &threshold_)
2063 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2064 ThrowImageException;
2067 void Magick::Image::blackThresholdChannel(const ChannelType channel_,
2068 const std::string &threshold_)
2072 GetAndSetPPChannelMask(channel_);
2073 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2074 RestorePPChannelMask;
2075 ThrowImageException;
2078 void Magick::Image::blueShift(const double factor_)
2084 newImage=BlueShiftImage(constImage(),factor_,exceptionInfo);
2085 replaceImage(newImage);
2086 ThrowImageException;
2089 void Magick::Image::blur(const double radius_,const double sigma_)
2095 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2096 replaceImage(newImage);
2097 ThrowImageException;
2100 void Magick::Image::blurChannel(const ChannelType channel_,
2101 const double radius_,const double sigma_)
2107 GetAndSetPPChannelMask(channel_);
2108 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2109 RestorePPChannelMask;
2110 replaceImage(newImage);
2111 ThrowImageException;
2114 void Magick::Image::border(const Geometry &geometry_)
2120 borderInfo=geometry_;
2123 newImage=BorderImage(constImage(),&borderInfo,image()->compose,
2125 replaceImage(newImage);
2126 ThrowImageException;
2129 void Magick::Image::brightnessContrast(const double brightness_,
2130 const double contrast_)
2134 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2135 ThrowImageException;
2138 void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
2139 const double brightness_,const double contrast_)
2143 GetAndSetPPChannelMask(channel_);
2144 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2145 RestorePPChannelMask;
2146 ThrowImageException;
2149 void Magick::Image::cannyEdge(const double radius_,const double sigma_,
2150 const double lowerPercent_,const double upperPercent_)
2157 newImage=CannyEdgeImage(constImage(),radius_,sigma_,lowerPercent_,
2158 upperPercent_,exceptionInfo);
2159 replaceImage(newImage);
2160 ThrowImageException;
2163 void Magick::Image::cdl(const std::string &cdl_)
2167 (void) ColorDecisionListImage(image(),cdl_.c_str(),exceptionInfo);
2168 ThrowImageException;
2171 void Magick::Image::channel(const ChannelType channel_)
2177 newImage=SeparateImage(image(),channel_,exceptionInfo);
2178 replaceImage(newImage);
2179 ThrowImageException;
2182 void Magick::Image::charcoal(const double radius_,const double sigma_)
2188 newImage=CharcoalImage(image(),radius_,sigma_,exceptionInfo);
2189 replaceImage(newImage);
2190 ThrowImageException;
2193 void Magick::Image::chop(const Geometry &geometry_)
2202 newImage=ChopImage(image(),&chopInfo,exceptionInfo);
2203 replaceImage(newImage);
2204 ThrowImageException;
2207 void Magick::Image::chromaBluePrimary(const double x_,const double y_)
2210 image()->chromaticity.blue_primary.x=x_;
2211 image()->chromaticity.blue_primary.y=y_;
2214 void Magick::Image::chromaBluePrimary(double *x_,double *y_) const
2216 *x_=constImage()->chromaticity.blue_primary.x;
2217 *y_=constImage()->chromaticity.blue_primary.y;
2220 void Magick::Image::chromaGreenPrimary(const double x_,const double y_)
2223 image()->chromaticity.green_primary.x=x_;
2224 image()->chromaticity.green_primary.y=y_;
2227 void Magick::Image::chromaGreenPrimary(double *x_,double *y_) const
2229 *x_=constImage()->chromaticity.green_primary.x;
2230 *y_=constImage()->chromaticity.green_primary.y;
2233 void Magick::Image::chromaRedPrimary(const double x_,const double y_)
2236 image()->chromaticity.red_primary.x=x_;
2237 image()->chromaticity.red_primary.y=y_;
2240 void Magick::Image::chromaRedPrimary(double *x_,double *y_) const
2242 *x_=constImage()->chromaticity.red_primary.x;
2243 *y_=constImage()->chromaticity.red_primary.y;
2246 void Magick::Image::chromaWhitePoint(const double x_,const double y_)
2249 image()->chromaticity.white_point.x=x_;
2250 image()->chromaticity.white_point.y=y_;
2253 void Magick::Image::chromaWhitePoint(double *x_,double *y_) const
2255 *x_=constImage()->chromaticity.white_point.x;
2256 *y_=constImage()->chromaticity.white_point.y;
2259 void Magick::Image::clamp(void)
2263 ClampImage(image(),exceptionInfo);
2264 ThrowImageException;
2267 void Magick::Image::clampChannel(const ChannelType channel_)
2271 GetAndSetPPChannelMask(channel_);
2272 ClampImage(image(),exceptionInfo);
2273 RestorePPChannelMask;
2274 ThrowImageException;
2277 void Magick::Image::clip(void)
2281 ClipImage(image(),exceptionInfo);
2282 ThrowImageException;
2285 void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
2289 ClipImagePath(image(),pathname_.c_str(),(MagickBooleanType) inside_,
2291 ThrowImageException;
2294 void Magick::Image::clut(const Image &clutImage_,
2295 const PixelInterpolateMethod method)
2299 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2300 ThrowImageException;
2303 void Magick::Image::clutChannel(const ChannelType channel_,
2304 const Image &clutImage_,const PixelInterpolateMethod method)
2308 GetAndSetPPChannelMask(channel_);
2309 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2310 RestorePPChannelMask;
2311 ThrowImageException;
2314 void Magick::Image::colorize(const unsigned int alpha_,const Color &penColor_)
2316 colorize(alpha_,alpha_,alpha_,penColor_);
2319 void Magick::Image::colorize(const unsigned int alphaRed_,
2320 const unsigned int alphaGreen_,const unsigned int alphaBlue_,
2321 const Color &penColor_)
2324 blend[MagickPathExtent];
2332 if (!penColor_.isValid())
2333 throwExceptionExplicit(MagickCore::OptionError,
2334 "Pen color argument is invalid");
2336 FormatLocaleString(blend,MagickPathExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
2339 target=static_cast<PixelInfo>(penColor_);
2341 newImage=ColorizeImage(image(),blend,&target,exceptionInfo);
2342 replaceImage(newImage);
2343 ThrowImageException;
2346 void Magick::Image::colorMap(const size_t index_,const Color &color_)
2353 if (index_ > (MaxColormapSize-1))
2354 throwExceptionExplicit(MagickCore::OptionError,
2355 "Colormap index must be less than MaxColormapSize");
2357 if (!color_.isValid())
2358 throwExceptionExplicit(MagickCore::OptionError,
2359 "Color argument is invalid");
2363 // Ensure that colormap size is large enough
2364 if (colorMapSize() < (index_+1))
2365 colorMapSize(index_+1);
2367 // Set color at index in colormap
2368 (imageptr->colormap)[index_]=color_;
2371 Magick::Color Magick::Image::colorMap(const size_t index_) const
2373 if (!constImage()->colormap)
2375 throwExceptionExplicit(MagickCore::OptionError,
2376 "Image does not contain a colormap");
2380 if (index_ > constImage()->colors-1)
2381 throwExceptionExplicit(MagickCore::OptionError,"Index out of range");
2383 return(Magick::Color((constImage()->colormap)[index_]));
2386 void Magick::Image::colorMatrix(const size_t order_,
2387 const double *color_matrix_)
2393 kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2394 if (kernel_info != (KernelInfo *) NULL)
2396 kernel_info->width=order_;
2397 kernel_info->height=order_;
2398 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2399 order_*sizeof(*kernel_info->values));
2400 if (kernel_info->values != (MagickRealType *) NULL)
2405 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2406 kernel_info->values[i]=color_matrix_[i];
2407 newImage=ColorMatrixImage(image(),kernel_info,exceptionInfo);
2408 replaceImage(newImage);
2410 kernel_info=DestroyKernelInfo(kernel_info);
2412 ThrowImageException;
2415 bool Magick::Image::compare(const Image &reference_)
2425 status=static_cast<bool>(IsImagesEqual(image(),ref.constImage(),
2427 ThrowImageException;
2431 double Magick::Image::compare(const Image &reference_,const MetricType metric_)
2437 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2439 ThrowImageException;
2443 double Magick::Image::compareChannel(const ChannelType channel_,
2444 const Image &reference_,const MetricType metric_)
2450 GetAndSetPPChannelMask(channel_);
2451 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2453 RestorePPChannelMask;
2454 ThrowImageException;
2458 Magick::Image Magick::Image::compare(const Image &reference_,
2459 const MetricType metric_,double *distortion)
2465 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2467 ThrowImageException;
2468 if (newImage == (MagickCore::Image *) NULL)
2469 return(Magick::Image());
2471 return(Magick::Image(newImage));
2474 Magick::Image Magick::Image::compareChannel(const ChannelType channel_,
2475 const Image &reference_,const MetricType metric_,double *distortion)
2481 GetAndSetPPChannelMask(channel_);
2482 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2484 RestorePPChannelMask;
2485 ThrowImageException;
2486 if (newImage == (MagickCore::Image *) NULL)
2487 return(Magick::Image());
2489 return(Magick::Image(newImage));
2492 void Magick::Image::composite(const Image &compositeImage_,
2493 const Geometry &offset_,const CompositeOperator compose_)
2503 ParseMetaGeometry(static_cast<std::string>(offset_).c_str(),&x,&y,&width,
2508 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2510 ThrowImageException;
2513 void Magick::Image::composite(const Image &compositeImage_,
2514 const GravityType gravity_,const CompositeOperator compose_)
2520 SetGeometry(compositeImage_.constImage(),&geometry);
2521 GravityAdjustGeometry(columns(),rows(),gravity_,&geometry);
2524 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2525 geometry.x,geometry.y,exceptionInfo);
2526 ThrowImageException;
2529 void Magick::Image::composite(const Image &compositeImage_,
2530 const ssize_t xOffset_,const ssize_t yOffset_,
2531 const CompositeOperator compose_)
2533 // Image supplied as compositeImage is composited with current image and
2534 // results in updating current image.
2537 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2538 xOffset_,yOffset_,exceptionInfo);
2539 ThrowImageException;
2542 void Magick::Image::connectedComponents(const size_t connectivity_)
2548 newImage=ConnectedComponentsImage(constImage(),connectivity_,exceptionInfo);
2549 replaceImage(newImage);
2550 ThrowImageException;
2553 void Magick::Image::contrast(const bool sharpen_)
2557 ContrastImage(image(),(MagickBooleanType) sharpen_,exceptionInfo);
2558 ThrowImageException;
2561 void Magick::Image::contrastStretch(const double blackPoint_,
2562 const double whitePoint_)
2566 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2567 ThrowImageException;
2570 void Magick::Image::contrastStretchChannel(const ChannelType channel_,
2571 const double blackPoint_,const double whitePoint_)
2575 GetAndSetPPChannelMask(channel_);
2576 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2577 RestorePPChannelMask;
2578 ThrowImageException;
2581 void Magick::Image::convolve(const size_t order_,const double *kernel_)
2587 kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2588 kernel_info->width=order_;
2589 kernel_info->height=order_;
2590 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2591 order_*sizeof(*kernel_info->values));
2592 if (kernel_info->values != (MagickRealType *) NULL)
2597 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2598 kernel_info->values[i]=kernel_[i];
2599 newImage=ConvolveImage(image(),kernel_info,exceptionInfo);
2600 replaceImage(newImage);
2602 kernel_info=DestroyKernelInfo(kernel_info);
2603 ThrowImageException;
2606 void Magick::Image::copyPixels(const Image &source_,const Geometry &geometry_,
2607 const Offset &offset_)
2616 (void) CopyImagePixels(image(),source_.constImage(),&geometry,&offset,
2618 ThrowImageException;
2621 void Magick::Image::crop(const Geometry &geometry_)
2630 newImage=CropImage(constImage(),&cropInfo,exceptionInfo);
2631 replaceImage(newImage);
2632 ThrowImageException;
2635 void Magick::Image::cycleColormap(const ssize_t amount_)
2639 CycleColormapImage(image(),amount_,exceptionInfo);
2640 ThrowImageException;
2643 void Magick::Image::decipher(const std::string &passphrase_)
2647 DecipherImage(image(),passphrase_.c_str(),exceptionInfo);
2648 ThrowImageException;
2651 void Magick::Image::defineSet(const std::string &magick_,
2652 const std::string &key_,bool flag_)
2658 definition=magick_ + ":" + key_;
2660 (void) SetImageOption(imageInfo(),definition.c_str(),"");
2662 DeleteImageOption(imageInfo(),definition.c_str());
2665 bool Magick::Image::defineSet(const std::string &magick_,
2666 const std::string &key_ ) const
2674 key=magick_ + ":" + key_;
2675 option=GetImageOption(constImageInfo(),key.c_str());
2681 void Magick::Image::defineValue(const std::string &magick_,
2682 const std::string &key_,const std::string &value_)
2689 format=magick_ + ":" + key_;
2691 (void) SetImageOption(imageInfo(),format.c_str(),option.c_str());
2694 std::string Magick::Image::defineValue(const std::string &magick_,
2695 const std::string &key_) const
2703 definition=magick_ + ":" + key_;
2704 option=GetImageOption(constImageInfo(),definition.c_str());
2706 return(std::string(option));
2707 return(std::string());
2710 void Magick::Image::deskew(const double threshold_)
2716 newImage=DeskewImage(constImage(),threshold_,exceptionInfo);
2717 replaceImage(newImage);
2718 ThrowImageException;
2721 void Magick::Image::despeckle(void)
2727 newImage=DespeckleImage(constImage(),exceptionInfo);
2728 replaceImage(newImage);
2729 ThrowImageException;
2732 void Magick::Image::display(void)
2735 DisplayImages(imageInfo(),image(),exceptionInfo);
2736 ThrowImageException;
2739 void Magick::Image::distort(const DistortImageMethod method_,
2740 const size_t numberArguments_,const double *arguments_,const bool bestfit_)
2746 newImage=DistortImage(constImage(), method_,numberArguments_,arguments_,
2747 bestfit_ == true ? MagickTrue : MagickFalse,exceptionInfo);
2748 replaceImage(newImage);
2749 ThrowImageException;
2752 void Magick::Image::draw(const Magick::Drawable &drawable_)
2759 wand=DrawAllocateWand(options()->drawInfo(),image());
2763 drawable_.operator()(wand);
2767 ClonePPDrawException(wand);
2768 wand=DestroyDrawingWand(wand);
2769 ThrowPPDrawException(quiet());
2773 void Magick::Image::draw(const std::vector<Magick::Drawable> &drawable_)
2780 wand=DrawAllocateWand(options()->drawInfo(),image());
2784 for (std::vector<Magick::Drawable>::const_iterator p = drawable_.begin();
2785 p != drawable_.end(); p++ )
2787 p->operator()(wand);
2788 if (DrawGetExceptionType(wand) != MagickCore::UndefinedException)
2792 if (DrawGetExceptionType(wand) == MagickCore::UndefinedException)
2795 ClonePPDrawException(wand);
2796 wand=DestroyDrawingWand(wand);
2797 ThrowPPDrawException(quiet());
2801 void Magick::Image::edge(const double radius_)
2807 newImage=EdgeImage(constImage(),radius_,exceptionInfo);
2808 replaceImage(newImage);
2809 ThrowImageException;
2812 void Magick::Image::emboss(const double radius_,const double sigma_)
2818 newImage=EmbossImage(constImage(),radius_,sigma_,exceptionInfo);
2819 replaceImage(newImage);
2820 ThrowImageException;
2823 void Magick::Image::encipher(const std::string &passphrase_)
2827 EncipherImage(image(),passphrase_.c_str(),exceptionInfo);
2828 ThrowImageException;
2831 void Magick::Image::enhance(void)
2837 newImage=EnhanceImage(constImage(),exceptionInfo);
2838 replaceImage(newImage);
2839 ThrowImageException;
2842 void Magick::Image::equalize(void)
2846 EqualizeImage(image(),exceptionInfo);
2847 ThrowImageException;
2850 void Magick::Image::erase(void)
2854 (void) SetImageBackgroundColor(image(),exceptionInfo);
2855 ThrowImageException;
2858 void Magick::Image::extent(const Geometry &geometry_ )
2864 extentInfo=geometry_;
2867 extentInfo.x=geometry_.xOff();
2868 extentInfo.y=geometry_.yOff();
2870 newImage=ExtentImage(image(),&extentInfo,exceptionInfo);
2871 replaceImage(newImage);
2872 ThrowImageException;
2875 void Magick::Image::extent(const Geometry &geometry_,
2876 const Color &backgroundColor_)
2878 backgroundColor(backgroundColor_);
2882 void Magick::Image::extent(const Geometry &geometry_,
2883 const Color &backgroundColor_,const GravityType gravity_)
2885 backgroundColor(backgroundColor_);
2886 extent(geometry_,gravity_);
2889 void Magick::Image::extent(const Geometry &geometry_,
2890 const GravityType gravity_)
2895 SetGeometry(image(),&geometry);
2896 geometry.width=geometry_.width();
2897 geometry.height=geometry_.height();
2898 GravityAdjustGeometry(image()->columns,image()->rows,gravity_,&geometry);
2902 void Magick::Image::flip(void)
2908 newImage=FlipImage(constImage(),exceptionInfo);
2909 replaceImage(newImage);
2910 ThrowImageException;
2913 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2914 const unsigned int alpha_,const bool invert_)
2921 target=static_cast<PixelInfo>(pixelColor(x_,y_));
2922 target.alpha=alpha_;
2924 GetAndSetPPChannelMask(AlphaChannel);
2925 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2926 (MagickBooleanType)invert_,exceptionInfo);
2927 RestorePPChannelMask;
2928 ThrowImageException;
2931 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2932 const unsigned int alpha_,const Color &target_,const bool invert_)
2939 target=static_cast<PixelInfo>(target_);
2940 target.alpha=alpha_;
2942 GetAndSetPPChannelMask(AlphaChannel);
2943 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2944 (MagickBooleanType)invert_,exceptionInfo);
2945 RestorePPChannelMask;
2946 ThrowImageException;
2949 void Magick::Image::floodFillColor(const Geometry &point_,
2950 const Magick::Color &fillColor_,const bool invert_)
2952 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,invert_);
2955 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2956 const Magick::Color &fillColor_,const bool invert_)
2963 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2964 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2967 void Magick::Image::floodFillColor(const Geometry &point_,
2968 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2971 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,borderColor_,invert_);
2974 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2975 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2983 pixel=static_cast<PixelInfo>(borderColor_);
2984 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2987 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2988 const Magick::Image &texture_,const bool invert_)
2990 floodFillTexture(point_.xOff(),point_.yOff(),texture_,invert_);
2993 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2994 const Magick::Image &texture_,const bool invert_)
3001 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
3002 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
3005 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
3006 const Magick::Image &texture_,const Magick::Color &borderColor_,
3009 floodFillTexture(point_.xOff(),point_.yOff(),texture_,borderColor_,invert_);
3012 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
3013 const Magick::Image &texture_,const Magick::Color &borderColor_,
3021 pixel=static_cast<PixelInfo>(borderColor_);
3022 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
3025 void Magick::Image::flop(void)
3031 newImage=FlopImage(constImage(),exceptionInfo);
3032 replaceImage(newImage);
3033 ThrowImageException;
3036 void Magick::Image::fontTypeMetrics(const std::string &text_,
3037 TypeMetric *metrics)
3042 drawInfo=options()->drawInfo();
3043 drawInfo->text=const_cast<char *>(text_.c_str());
3045 GetTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3047 ThrowImageException;
3050 void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
3051 TypeMetric *metrics)
3056 drawInfo=options()->drawInfo();
3057 drawInfo->text=const_cast<char *>(text_.c_str());
3059 GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3061 ThrowImageException;
3064 void Magick::Image::frame(const Geometry &geometry_)
3072 info.x=static_cast<ssize_t>(geometry_.width());
3073 info.y=static_cast<ssize_t>(geometry_.height());
3074 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3075 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3076 info.outer_bevel=geometry_.xOff();
3077 info.inner_bevel=geometry_.yOff();
3080 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3081 replaceImage(newImage);
3082 ThrowImageException;
3085 void Magick::Image::frame(const size_t width_,const size_t height_,
3086 const ssize_t innerBevel_,const ssize_t outerBevel_)
3094 info.x=static_cast<ssize_t>(width_);
3095 info.y=static_cast<ssize_t>(height_);
3096 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3097 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3098 info.outer_bevel=static_cast<ssize_t>(outerBevel_);
3099 info.inner_bevel=static_cast<ssize_t>(innerBevel_);
3102 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3103 replaceImage(newImage);
3104 ThrowImageException;
3107 void Magick::Image::fx(const std::string expression_)
3113 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3114 replaceImage(newImage);
3115 ThrowImageException;
3118 void Magick::Image::fx(const std::string expression_,
3119 const Magick::ChannelType channel_)
3125 GetAndSetPPChannelMask(channel_);
3126 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3127 RestorePPChannelMask;
3128 replaceImage(newImage);
3129 ThrowImageException;
3132 void Magick::Image::gamma(const double gamma_)
3136 GammaImage(image(),gamma_,exceptionInfo);
3137 ThrowImageException;
3140 void Magick::Image::gamma(const double gammaRed_,const double gammaGreen_,
3141 const double gammaBlue_)
3145 GetAndSetPPChannelMask(RedChannel);
3146 (void) GammaImage(image(),gammaRed_,exceptionInfo);
3147 SetPPChannelMask(GreenChannel);
3148 (void) GammaImage(image(),gammaGreen_,exceptionInfo);
3149 SetPPChannelMask(BlueChannel);
3150 (void) GammaImage(image(),gammaBlue_,exceptionInfo);
3151 RestorePPChannelMask;
3152 ThrowImageException;
3155 void Magick::Image::gaussianBlur(const double width_,const double sigma_)
3161 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3162 replaceImage(newImage);
3163 ThrowImageException;
3166 void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
3167 const double width_,const double sigma_)
3173 GetAndSetPPChannelMask(channel_);
3174 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3175 RestorePPChannelMask;
3176 replaceImage(newImage);
3177 ThrowImageException;
3180 const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
3181 const ssize_t y_,const size_t columns_,const size_t rows_) const
3187 p=GetVirtualPixels(constImage(),x_, y_,columns_, rows_,exceptionInfo);
3188 ThrowImageException;
3192 const void *Magick::Image::getConstMetacontent(void) const
3197 result=GetVirtualMetacontent(constImage());
3200 throwExceptionExplicit(MagickCore::OptionError,
3201 "Unable to retrieve meta content.");
3206 void *Magick::Image::getMetacontent(void )
3211 result=GetAuthenticMetacontent(image());
3214 throwExceptionExplicit(MagickCore::OptionError,
3215 "Unable to retrieve meta content.");
3220 Magick::Quantum *Magick::Image::getPixels(const ssize_t x_,const ssize_t y_,
3221 const size_t columns_,const size_t rows_)
3228 result=GetAuthenticPixels(image(),x_, y_,columns_,rows_,exceptionInfo);
3229 ThrowImageException;
3234 void Magick::Image::grayscale(const PixelIntensityMethod method_)
3238 (void) GrayscaleImage(image(),method_,exceptionInfo);
3239 ThrowImageException;
3242 void Magick::Image::haldClut(const Image &clutImage_)
3246 (void) HaldClutImage(image(),clutImage_.constImage(),exceptionInfo);
3247 ThrowImageException;
3250 void Magick::Image::houghLine(const size_t width_,const size_t height_,
3251 const size_t threshold_)
3257 newImage=HoughLineImage(constImage(),width_,height_,threshold_,
3259 replaceImage(newImage);
3260 ThrowImageException;
3263 Magick::ImageType Magick::Image::identifyType(void) const
3269 image_type=IdentifyImageType(constImage(),exceptionInfo);
3270 ThrowImageException;
3274 void Magick::Image::implode(const double factor_)
3280 newImage=ImplodeImage(constImage(),factor_,image()->interpolate,
3282 replaceImage(newImage);
3283 ThrowImageException;
3286 void Magick::Image::inverseFourierTransform(const Image &phase_)
3288 inverseFourierTransform(phase_,true);
3291 void Magick::Image::inverseFourierTransform(const Image &phase_,
3292 const bool magnitude_)
3298 newImage=InverseFourierTransformImage(constImage(),phase_.constImage(),
3299 magnitude_ == true ? MagickTrue : MagickFalse,exceptionInfo);
3300 replaceImage(newImage);
3301 ThrowImageException;
3304 void Magick::Image::kuwahara(const double radius_,const double sigma_)
3310 newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3311 replaceImage(newImage);
3312 ThrowImageException;
3315 void Magick::Image::kuwaharaChannel(const ChannelType channel_,
3316 const double radius_,const double sigma_)
3322 GetAndSetPPChannelMask(channel_);
3323 newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3324 replaceImage(newImage);
3325 RestorePPChannelMask;
3326 ThrowImageException;
3329 void Magick::Image::level(const double blackPoint_,const double whitePoint_,
3330 const double gamma_)
3334 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3335 ThrowImageException;
3338 void Magick::Image::levelChannel(const ChannelType channel_,
3339 const double blackPoint_,const double whitePoint_,const double gamma_)
3343 GetAndSetPPChannelMask(channel_);
3344 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3345 RestorePPChannelMask;
3346 ThrowImageException;
3349 void Magick::Image::levelColors(const Color &blackColor_,
3350 const Color &whiteColor_,const bool invert_)
3358 black=static_cast<PixelInfo>(blackColor_);
3359 white=static_cast<PixelInfo>(whiteColor_);
3361 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3362 MagickTrue : MagickFalse,exceptionInfo);
3363 ThrowImageException;
3366 void Magick::Image::levelColorsChannel(const ChannelType channel_,
3367 const Color &blackColor_,const Color &whiteColor_,const bool invert_)
3375 black=static_cast<PixelInfo>(blackColor_);
3376 white=static_cast<PixelInfo>(whiteColor_);
3378 GetAndSetPPChannelMask(channel_);
3379 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3380 MagickTrue : MagickFalse,exceptionInfo);
3381 RestorePPChannelMask;
3382 ThrowImageException;
3385 void Magick::Image::linearStretch(const double blackPoint_,
3386 const double whitePoint_)
3390 LinearStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
3391 ThrowImageException;
3394 void Magick::Image::liquidRescale(const Geometry &geometry_)
3407 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3411 newImage=LiquidRescaleImage(image(),width,height,x,y,exceptionInfo);
3412 replaceImage(newImage);
3413 ThrowImageException;
3416 void Magick::Image::magnify(void)
3422 newImage=MagnifyImage(constImage(),exceptionInfo);
3423 replaceImage(newImage);
3424 ThrowImageException;
3427 void Magick::Image::map(const Image &mapImage_,const bool dither_)
3431 options()->quantizeDither(dither_);
3432 RemapImage(options()->quantizeInfo(),image(),mapImage_.constImage(),
3434 ThrowImageException;
3437 void Magick::Image::medianFilter(const double radius_)
3443 newImage=StatisticImage(image(),MedianStatistic,(size_t) radius_,
3444 (size_t) radius_,exceptionInfo);
3445 replaceImage(newImage);
3446 ThrowImageException;
3449 void Magick::Image::minify(void)
3455 newImage=MinifyImage(constImage(),exceptionInfo);
3456 replaceImage(newImage);
3457 ThrowImageException;
3460 void Magick::Image::modulate(const double brightness_,const double saturation_,
3464 modulate[MagickPathExtent + 1];
3466 FormatLocaleString(modulate,MagickPathExtent,"%3.6f,%3.6f,%3.6f",brightness_,
3471 ModulateImage(image(),modulate,exceptionInfo);
3472 ThrowImageException;
3475 Magick::ImageMoments Magick::Image::moments(void) const
3477 return(ImageMoments(*this));
3480 void Magick::Image::morphology(const MorphologyMethod method_,
3481 const std::string kernel_,const ssize_t iterations_)
3490 kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3491 if (kernel == (KernelInfo *) NULL)
3492 throwExceptionExplicit(MagickCore::OptionError,"Unable to parse kernel.");
3493 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3495 replaceImage(newImage);
3496 kernel=DestroyKernelInfo(kernel);
3497 ThrowImageException;
3500 void Magick::Image::morphology(const MorphologyMethod method_,
3501 const KernelInfoType kernel_,const std::string arguments_,
3502 const ssize_t iterations_)
3510 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3511 if (option == (const char *)NULL)
3513 throwExceptionExplicit(MagickCore::OptionError,
3514 "Unable to determine kernel type.");
3517 kernel=std::string(option);
3518 if (!arguments_.empty())
3519 kernel+=":"+arguments_;
3521 morphology(method_,kernel,iterations_);
3524 void Magick::Image::morphologyChannel(const ChannelType channel_,
3525 const MorphologyMethod method_,const std::string kernel_,
3526 const ssize_t iterations_)
3536 kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3537 if (kernel == (KernelInfo *)NULL)
3539 throwExceptionExplicit(MagickCore::OptionError,
3540 "Unable to parse kernel.");
3543 GetAndSetPPChannelMask(channel_);
3544 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3546 RestorePPChannelMask;
3547 replaceImage(newImage);
3548 kernel=DestroyKernelInfo(kernel);
3549 ThrowImageException;
3552 void Magick::Image::morphologyChannel(const ChannelType channel_,
3553 const MorphologyMethod method_,const KernelInfoType kernel_,
3554 const std::string arguments_,const ssize_t iterations_)
3562 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3563 if (option == (const char *)NULL)
3565 throwExceptionExplicit(MagickCore::OptionError,
3566 "Unable to determine kernel type.");
3570 kernel=std::string(option);
3571 if (!arguments_.empty())
3572 kernel+=":"+arguments_;
3574 morphologyChannel(channel_,method_,kernel,iterations_);
3577 void Magick::Image::motionBlur(const double radius_,const double sigma_,
3578 const double angle_)
3584 newImage=MotionBlurImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
3585 replaceImage(newImage);
3586 ThrowImageException;
3589 void Magick::Image::negate(const bool grayscale_)
3593 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3594 ThrowImageException;
3597 void Magick::Image::negateChannel(const ChannelType channel_,
3598 const bool grayscale_)
3602 GetAndSetPPChannelMask(channel_);
3603 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3604 RestorePPChannelMask;
3605 ThrowImageException;
3608 void Magick::Image::normalize(void)
3612 NormalizeImage(image(),exceptionInfo);
3613 ThrowImageException;
3616 void Magick::Image::oilPaint(const double radius_,const double sigma_)
3622 newImage=OilPaintImage(constImage(),radius_,sigma_,exceptionInfo);
3623 replaceImage(newImage);
3624 ThrowImageException;
3627 void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_,
3638 if (!opaqueColor_.isValid())
3639 throwExceptionExplicit(MagickCore::OptionError,
3640 "Opaque color argument is invalid");
3642 if (!penColor_.isValid())
3643 throwExceptionExplicit(MagickCore::OptionError,
3644 "Pen color argument is invalid");
3647 opaqueColor=opaqueColor_;
3651 (void) QueryColorCompliance(opaqueColor.c_str(),AllCompliance,&opaque,
3653 (void) QueryColorCompliance(penColor.c_str(),AllCompliance,&pen,
3655 OpaquePaintImage(image(),&opaque,&pen,invert_ ? MagickTrue : MagickFalse,
3657 ThrowImageException;
3660 void Magick::Image::orderedDither(std::string thresholdMap_)
3664 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3665 ThrowImageException;
3668 void Magick::Image::orderedDitherChannel(const ChannelType channel_,
3669 std::string thresholdMap_)
3673 GetAndSetPPChannelMask(channel_);
3674 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3675 RestorePPChannelMask;
3676 ThrowImageException;
3679 void Magick::Image::perceptible(const double epsilon_)
3683 PerceptibleImage(image(),epsilon_,exceptionInfo);
3684 ThrowImageException;
3687 void Magick::Image::perceptibleChannel(const ChannelType channel_,
3688 const double epsilon_)
3692 GetAndSetPPChannelMask(channel_);
3693 PerceptibleImage(image(),epsilon_,exceptionInfo);
3694 RestorePPChannelMask;
3695 ThrowImageException;
3698 Magick::ImagePerceptualHash Magick::Image::perceptualHash() const
3700 return(ImagePerceptualHash(*this));
3703 void Magick::Image::ping(const std::string &imageSpec_)
3709 options()->fileName(imageSpec_);
3710 newImage=PingImage(imageInfo(),exceptionInfo);
3711 read(newImage,exceptionInfo);
3714 void Magick::Image::ping(const Blob& blob_)
3720 newImage=PingBlob(imageInfo(),blob_.data(),blob_.length(),exceptionInfo);
3721 read(newImage,exceptionInfo);
3724 void Magick::Image::pixelColor(const ssize_t x_,const ssize_t y_,
3725 const Color &color_)
3733 // Test arguments to ensure they are within the image.
3734 if (y_ > (ssize_t) rows() || x_ > (ssize_t) columns())
3735 throwExceptionExplicit(MagickCore::OptionError,
3736 "Access outside of image boundary");
3740 // Set image to DirectClass
3741 classType(DirectClass );
3744 Pixels pixels(*this);
3746 pixel=pixels.get(x_, y_, 1, 1 );
3748 MagickCore::SetPixelViaPixelInfo(constImage(),&packet,pixel);
3749 // Tell ImageMagick that pixels have been updated
3753 Magick::Color Magick::Image::pixelColor(const ssize_t x_,
3754 const ssize_t y_) const
3759 pixel=getConstPixels(x_,y_,1,1);
3765 MagickCore::GetPixelInfoPixel(constImage(),pixel,&packet);
3766 return(Color(packet));
3769 return(Color()); // invalid
3772 void Magick::Image::polaroid(const std::string &caption_,const double angle_,
3773 const PixelInterpolateMethod method_)
3779 newImage=PolaroidImage(constImage(),options()->drawInfo(),caption_.c_str(),
3780 angle_,method_,exceptionInfo);
3781 replaceImage(newImage);
3782 ThrowImageException;
3785 void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
3789 PosterizeImage(image(),levels_,method_,exceptionInfo);
3790 ThrowImageException;
3793 void Magick::Image::posterizeChannel(const ChannelType channel_,
3794 const size_t levels_,const DitherMethod method_)
3798 GetAndSetPPChannelMask(channel_);
3799 PosterizeImage(image(),levels_,method_,exceptionInfo);
3800 RestorePPChannelMask;
3801 ThrowImageException;
3804 void Magick::Image::process(std::string name_,const ssize_t argc,
3810 (void) InvokeDynamicImageFilter(name_.c_str(),&image(),argc,argv,
3812 ThrowImageException;
3815 void Magick::Image::profile(const std::string name_,
3816 const Magick::Blob &profile_)
3820 (void) ProfileImage(image(),name_.c_str(),(unsigned char *)profile_.data(),
3821 profile_.length(),exceptionInfo);
3822 ThrowImageException;
3825 Magick::Blob Magick::Image::profile(const std::string name_) const
3830 profile=GetImageProfile(constImage(),name_.c_str());
3832 if (profile == (StringInfo *) NULL)
3834 return(Blob((void*) GetStringInfoDatum(profile),GetStringInfoLength(
3838 void Magick::Image::quantize(const bool measureError_)
3843 options()->quantizeInfo()->measure_error=MagickTrue;
3845 options()->quantizeInfo()->measure_error=MagickFalse;
3848 QuantizeImage(options()->quantizeInfo(),image(),exceptionInfo);
3849 ThrowImageException;
3852 void Magick::Image::quantumOperator(const ChannelType channel_,
3853 const MagickEvaluateOperator operator_,double rvalue_)
3856 GetAndSetPPChannelMask(channel_);
3857 EvaluateImage(image(),operator_,rvalue_,exceptionInfo);
3858 RestorePPChannelMask;
3859 ThrowImageException;
3862 void Magick::Image::quantumOperator(const ssize_t x_,const ssize_t y_,
3863 const size_t columns_,const size_t rows_,const ChannelType channel_,
3864 const MagickEvaluateOperator operator_,const double rvalue_)
3872 geometry.width = columns_;
3873 geometry.height = rows_;
3878 cropImage=CropImage(image(),&geometry,exceptionInfo);
3879 GetAndSetPPChannelMask(channel_);
3880 EvaluateImage(cropImage,operator_,rvalue_,exceptionInfo);
3881 RestorePPChannelMask;
3882 (void) CompositeImage(image(),cropImage,image()->alpha_trait ==
3883 BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
3884 geometry.x,geometry.y,exceptionInfo );
3885 cropImage=DestroyImageList(cropImage);
3886 ThrowImageException;
3889 void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
3892 raiseInfo=geometry_;
3896 RaiseImage(image(),&raiseInfo,raisedFlag_ == true ? MagickTrue : MagickFalse,
3898 ThrowImageException;
3901 void Magick::Image::randomThreshold(const Geometry &thresholds_)
3904 (void) RandomThresholdImage(image(),static_cast<std::string>(
3905 thresholds_).c_str(),exceptionInfo);
3906 ThrowImageException;
3909 void Magick::Image::randomThresholdChannel(const ChannelType channel_,
3910 const Geometry &thresholds_)
3914 GetAndSetPPChannelMask(channel_);
3915 (void) RandomThresholdImage(image(),static_cast<std::string>(
3916 thresholds_).c_str(),exceptionInfo);
3917 RestorePPChannelMask;
3918 ThrowImageException;
3921 void Magick::Image::read(const Blob &blob_)
3927 newImage=BlobToImage(imageInfo(),static_cast<const void *>(blob_.data()),
3928 blob_.length(),exceptionInfo);
3929 read(newImage,exceptionInfo);
3932 void Magick::Image::read(const Blob &blob_,const Geometry &size_)
3938 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3939 const size_t depth_)
3946 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3947 const size_t depth_,const std::string &magick_)
3952 // Set explicit image format
3953 fileName(magick_ + ':');
3957 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3958 const std::string &magick_)
3962 // Set explicit image format
3963 fileName(magick_ + ':');
3967 void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_)
3973 void Magick::Image::read(const size_t width_,const size_t height_,
3974 const std::string &map_,const StorageType type_,const void *pixels_)
3980 newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
3982 replaceImage(newImage);
3983 ThrowImageException;
3986 void Magick::Image::read(const std::string &imageSpec_)
3992 options()->fileName(imageSpec_);
3993 newImage=ReadImage(imageInfo(),exceptionInfo);
3994 read(newImage,exceptionInfo);
3997 void Magick::Image::readPixels(const Magick::QuantumType quantum_,
3998 const unsigned char *source_)
4003 quantum_info=AcquireQuantumInfo(imageInfo(),image());
4005 ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4006 quantum_,source_,exceptionInfo);
4007 quantum_info=DestroyQuantumInfo(quantum_info);
4008 ThrowImageException;
4011 void Magick::Image::reduceNoise(void)
4016 void Magick::Image::reduceNoise(const size_t order_)
4022 newImage=StatisticImage(constImage(),NonpeakStatistic,order_,
4023 order_,exceptionInfo);
4024 replaceImage(newImage);
4025 ThrowImageException;
4028 void Magick::Image::repage()
4031 options()->page(Geometry());
4032 image()->page.width = 0;
4033 image()->page.height = 0;
4034 image()->page.x = 0;
4035 image()->page.y = 0;
4038 void Magick::Image::resample(const Point &density_)
4044 newImage=ResampleImage(constImage(),density_.x(),density_.y(),
4045 image()->filter,exceptionInfo);
4046 replaceImage(newImage);
4047 ThrowImageException;
4050 void Magick::Image::resize(const Geometry &geometry_)
4063 // Calculate new size. This code should be supported using binary arguments
4064 // in the ImageMagick library.
4065 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4069 newImage=ResizeImage(constImage(),width,height,image()->filter,
4071 replaceImage(newImage);
4072 ThrowImageException;
4075 void Magick::Image::roll(const Geometry &roll_)
4081 newImage=RollImage(constImage(),roll_.xOff(),roll_.yOff(),exceptionInfo);
4082 replaceImage(newImage);
4083 ThrowImageException;
4086 void Magick::Image::roll(const size_t columns_,const size_t rows_)
4092 newImage=RollImage(constImage(),static_cast<ssize_t>(columns_),
4093 static_cast<ssize_t>(rows_),exceptionInfo);
4094 replaceImage(newImage);
4095 ThrowImageException;
4098 void Magick::Image::rotate(const double degrees_)
4104 newImage=RotateImage(constImage(),degrees_,exceptionInfo);
4105 replaceImage(newImage);
4106 ThrowImageException;
4109 void Magick::Image::rotationalBlur(const double angle_)
4115 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4116 replaceImage(newImage);
4117 ThrowImageException;
4120 void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
4121 const double angle_)
4127 GetAndSetPPChannelMask(channel_);
4128 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4129 RestorePPChannelMask;
4130 replaceImage(newImage);
4131 ThrowImageException;
4134 void Magick::Image::sample(const Geometry &geometry_)
4147 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4151 newImage=SampleImage(constImage(),width,height,exceptionInfo);
4152 replaceImage(newImage);
4153 ThrowImageException;
4156 void Magick::Image::scale(const Geometry &geometry_)
4169 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4173 newImage=ScaleImage(constImage(),width,height,exceptionInfo);
4174 replaceImage(newImage);
4175 ThrowImageException;
4178 void Magick::Image::segment(const double clusterThreshold_,
4179 const double smoothingThreshold_)
4183 SegmentImage(image(),options()->quantizeColorSpace(),
4184 (MagickBooleanType) options()->verbose(),clusterThreshold_,
4185 smoothingThreshold_,exceptionInfo);
4186 SyncImage(image(),exceptionInfo);
4187 ThrowImageException;
4190 void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
4191 const double threshold_)
4197 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4199 replaceImage(newImage);
4200 ThrowImageException;
4203 void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
4204 const double radius_,const double sigma_,const double threshold_)
4210 GetAndSetPPChannelMask(channel_);
4211 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4213 RestorePPChannelMask;
4214 replaceImage(newImage);
4215 ThrowImageException;
4218 Magick::Image Magick::Image::separate(const ChannelType channel_) const
4224 image=SeparateImage(constImage(),channel_,exceptionInfo);
4225 ThrowImageException;
4226 if (image == (MagickCore::Image *) NULL)
4227 return(Magick::Image());
4229 return(Magick::Image(image));
4232 void Magick::Image::sepiaTone(const double threshold_)
4238 newImage=SepiaToneImage(constImage(),threshold_,exceptionInfo);
4239 replaceImage(newImage);
4240 ThrowImageException;
4243 Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
4244 const size_t columns_,const size_t rows_)
4251 result=QueueAuthenticPixels(image(),x_,y_,columns_,rows_,exceptionInfo);
4252 ThrowImageException;
4256 void Magick::Image::shade(const double azimuth_,const double elevation_,
4257 const bool colorShading_)
4263 newImage=ShadeImage(constImage(),colorShading_ == true ?
4264 MagickTrue : MagickFalse,azimuth_,elevation_,exceptionInfo);
4265 replaceImage(newImage);
4266 ThrowImageException;
4269 void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
4270 const ssize_t x_,const ssize_t y_)
4276 newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
4278 replaceImage(newImage);
4279 ThrowImageException;
4282 void Magick::Image::sharpen(const double radius_,const double sigma_)
4288 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4289 replaceImage(newImage);
4290 ThrowImageException;
4293 void Magick::Image::sharpenChannel(const ChannelType channel_,
4294 const double radius_,const double sigma_)
4300 GetAndSetPPChannelMask(channel_);
4301 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4302 RestorePPChannelMask;
4303 replaceImage(newImage);
4304 ThrowImageException;
4307 void Magick::Image::shave(const Geometry &geometry_)
4313 shaveInfo=geometry_;
4316 newImage=ShaveImage(constImage(),&shaveInfo,exceptionInfo);
4317 replaceImage(newImage);
4318 ThrowImageException;
4321 void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
4327 newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,exceptionInfo);
4328 replaceImage(newImage);
4329 ThrowImageException;
4332 void Magick::Image::sigmoidalContrast(const bool sharpen_,
4333 const double contrast,const double midpoint)
4337 (void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
4338 midpoint,exceptionInfo);
4339 ThrowImageException;
4342 std::string Magick::Image::signature(const bool force_) const
4344 return(_imgRef->signature());
4347 void Magick::Image::sketch(const double radius_,const double sigma_,
4348 const double angle_)
4354 newImage=SketchImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
4355 replaceImage(newImage);
4356 ThrowImageException;
4359 void Magick::Image::solarize(const double factor_)
4363 SolarizeImage(image(),factor_,exceptionInfo);
4364 ThrowImageException;
4367 void Magick::Image::sparseColor(const ChannelType channel_,
4368 const SparseColorMethod method_,const size_t numberArguments_,
4369 const double *arguments_)
4375 GetAndSetPPChannelMask(channel_);
4376 newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
4378 RestorePPChannelMask;
4379 replaceImage(newImage);
4380 ThrowImageException;
4383 void Magick::Image::splice(const Geometry &geometry_)
4389 spliceInfo=geometry_;
4392 newImage=SpliceImage(constImage(),&spliceInfo,exceptionInfo);
4393 replaceImage(newImage);
4394 ThrowImageException;
4397 void Magick::Image::splice(const Geometry &geometry_,
4398 const Color &backgroundColor_)
4400 backgroundColor(backgroundColor_);
4404 void Magick::Image::splice(const Geometry &geometry_,
4405 const Color &backgroundColor_,const GravityType gravity_)
4407 backgroundColor(backgroundColor_);
4408 image()->gravity=gravity_;
4412 void Magick::Image::spread(const size_t amount_)
4418 newImage=SpreadImage(constImage(),amount_,exceptionInfo);
4419 replaceImage(newImage);
4420 ThrowImageException;
4423 Magick::ImageStatistics Magick::Image::statistics() const
4425 return(ImageStatistics(*this));
4428 void Magick::Image::stegano(const Image &watermark_)
4434 newImage=SteganoImage(constImage(),watermark_.constImage(),exceptionInfo);
4435 replaceImage(newImage);
4436 ThrowImageException;
4439 void Magick::Image::stereo(const Image &rightImage_)
4445 newImage=StereoImage(constImage(),rightImage_.constImage(),exceptionInfo);
4446 replaceImage(newImage);
4447 ThrowImageException;
4450 void Magick::Image::strip(void)
4454 StripImage(image(),exceptionInfo);
4455 ThrowImageException;
4458 Magick::Image Magick::Image::subImageSearch(const Image &reference_,
4459 const MetricType metric_,Geometry *offset_,double *similarityMetric_,
4460 const double similarityThreshold)
4469 newImage=SimilarityImage(image(),reference_.constImage(),metric_,
4470 similarityThreshold,&offset,similarityMetric_,exceptionInfo);
4471 ThrowImageException;
4472 if (offset_ != (Geometry *) NULL)
4474 if (newImage == (MagickCore::Image *) NULL)
4475 return(Magick::Image());
4477 return(Magick::Image(newImage));
4480 void Magick::Image::swirl(const double degrees_)
4486 newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
4488 replaceImage(newImage);
4489 ThrowImageException;
4492 void Magick::Image::syncPixels(void)
4495 (void) SyncAuthenticPixels(image(),exceptionInfo);
4496 ThrowImageException;
4499 void Magick::Image::texture(const Image &texture_)
4503 TextureImage(image(),texture_.constImage(),exceptionInfo);
4504 ThrowImageException;
4507 void Magick::Image::threshold(const double threshold_)
4511 BilevelImage(image(),threshold_,exceptionInfo);
4512 ThrowImageException;
4515 void Magick::Image::thumbnail(const Geometry &geometry_)
4528 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4532 newImage=ThumbnailImage(constImage(),width,height,exceptionInfo);
4533 replaceImage(newImage);
4534 ThrowImageException;
4537 void Magick::Image::tint(const std::string opacity_)
4546 color=static_cast<PixelInfo>(constOptions()->fillColor());
4547 newImage=TintImage(constImage(),opacity_.c_str(),&color,exceptionInfo);
4548 replaceImage(newImage);
4549 ThrowImageException;
4552 void Magick::Image::transform(const Geometry &imageGeometry_)
4556 TransformImage(&(image()),0,std::string(imageGeometry_).c_str(),
4558 ThrowImageException;
4561 void Magick::Image::transform(const Geometry &imageGeometry_,
4562 const Geometry &cropGeometry_)
4566 TransformImage(&(image()),std::string(cropGeometry_).c_str(),std::string(
4567 imageGeometry_).c_str(), exceptionInfo);
4568 ThrowImageException;
4571 void Magick::Image::transformOrigin(const double x_,const double y_)
4574 options()->transformOrigin(x_,y_);
4577 void Magick::Image::transformReset(void)
4580 options()->transformReset();
4583 void Magick::Image::transformScale(const double sx_,const double sy_)
4586 options()->transformScale(sx_,sy_);
4589 void Magick::Image::transparent(const Color &color_)
4597 if (!color_.isValid())
4598 throwExceptionExplicit(MagickCore::OptionError,
4599 "Color argument is invalid");
4603 (void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
4606 TransparentPaintImage(image(),&target,TransparentAlpha,MagickFalse,
4608 ThrowImageException;
4611 void Magick::Image::transparentChroma(const Color &colorLow_,
4612 const Color &colorHigh_)
4622 if (!colorLow_.isValid() || !colorHigh_.isValid())
4623 throwExceptionExplicit(MagickCore::OptionError,
4624 "Color argument is invalid");
4627 colorHigh=colorHigh_;
4630 (void) QueryColorCompliance(colorLow.c_str(),AllCompliance,&targetLow,
4632 (void) QueryColorCompliance(colorHigh.c_str(),AllCompliance,&targetHigh,
4635 TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
4636 MagickFalse,exceptionInfo);
4637 ThrowImageException;
4640 void Magick::Image::transpose(void)
4646 newImage=TransposeImage(constImage(),exceptionInfo);
4647 replaceImage(newImage);
4648 ThrowImageException;
4651 void Magick::Image::transverse(void)
4657 newImage=TransverseImage(constImage(),exceptionInfo);
4658 replaceImage(newImage);
4659 ThrowImageException;
4662 void Magick::Image::trim(void)
4668 newImage=TrimImage(constImage(),exceptionInfo);
4669 replaceImage(newImage);
4670 ThrowImageException;
4673 Magick::Image Magick::Image::uniqueColors(void) const
4679 image=UniqueImageColors(constImage(),exceptionInfo);
4680 ThrowImageException;
4681 if (image == (MagickCore::Image *) NULL)
4682 return(Magick::Image());
4684 return(Magick::Image(image));
4687 void Magick::Image::unsharpmask(const double radius_,const double sigma_,
4688 const double amount_,const double threshold_)
4694 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4696 replaceImage(newImage);
4697 ThrowImageException;
4700 void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
4701 const double radius_,const double sigma_,const double amount_,
4702 const double threshold_)
4708 GetAndSetPPChannelMask(channel_);
4709 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4711 RestorePPChannelMask;
4712 replaceImage(newImage);
4713 ThrowImageException;
4716 void Magick::Image::vignette(const double radius_,const double sigma_,
4717 const ssize_t x_,const ssize_t y_)
4723 newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,exceptionInfo);
4724 replaceImage(newImage);
4725 ThrowImageException;
4728 void Magick::Image::wave(const double amplitude_,const double wavelength_)
4734 newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
4736 replaceImage(newImage);
4737 ThrowImageException;
4740 void Magick::Image::whiteThreshold(const std::string &threshold_)
4744 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4745 ThrowImageException;
4748 void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
4749 const std::string &threshold_)
4753 GetAndSetPPChannelMask(channel_);
4754 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4755 RestorePPChannelMask;
4756 ThrowImageException;
4759 void Magick::Image::write(Blob *blob_)
4769 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4771 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4772 ThrowImageException;
4775 void Magick::Image::write(Blob *blob_,const std::string &magick_)
4786 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4788 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4789 ThrowImageException;
4792 void Magick::Image::write(Blob *blob_,const std::string &magick_,
4793 const size_t depth_)
4805 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4807 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4808 ThrowImageException;
4811 void Magick::Image::write(const ssize_t x_,const ssize_t y_,
4812 const size_t columns_,const size_t rows_,const std::string &map_,
4813 const StorageType type_,void *pixels_)
4816 ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
4818 ThrowImageException;
4821 void Magick::Image::write(const std::string &imageSpec_)
4824 fileName(imageSpec_);
4826 WriteImage(constImageInfo(),image(),exceptionInfo);
4827 ThrowImageException;
4830 void Magick::Image::writePixels(const Magick::QuantumType quantum_,
4831 unsigned char *destination_)
4836 quantum_info=AcquireQuantumInfo(imageInfo(),image());
4838 ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4839 quantum_,destination_, exceptionInfo);
4840 quantum_info=DestroyQuantumInfo(quantum_info);
4841 ThrowImageException;
4844 void Magick::Image::zoom(const Geometry &geometry_)
4857 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4861 newImage=ResizeImage(constImage(),width,height,image()->filter,exceptionInfo);
4862 replaceImage(newImage);
4863 ThrowImageException;
4866 Magick::Image::Image(MagickCore::Image *image_)
4867 : _imgRef(new ImageRef(image_))
4871 MagickCore::Image *&Magick::Image::image(void)
4873 return(_imgRef->image());
4876 const MagickCore::Image *Magick::Image::constImage(void) const
4878 return(_imgRef->image());
4881 MagickCore::ImageInfo *Magick::Image::imageInfo(void)
4883 return(_imgRef->options()->imageInfo());
4886 const MagickCore::ImageInfo *Magick::Image::constImageInfo(void) const
4888 return(_imgRef->options()->imageInfo());
4891 Magick::Options *Magick::Image::options(void)
4893 return(_imgRef->options());
4896 const Magick::Options *Magick::Image::constOptions(void) const
4898 return(_imgRef->options());
4901 MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)
4903 return(_imgRef->options()->quantizeInfo());
4906 const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
4908 return(_imgRef->options()->quantizeInfo());
4911 void Magick::Image::modifyImage(void)
4913 if (!_imgRef->isShared())
4917 replaceImage(CloneImage(image(),0,0,MagickTrue,exceptionInfo));
4918 ThrowImageException;
4921 MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
4931 image=AcquireImage(constImageInfo(),exceptionInfo);
4932 ThrowImageException;
4935 _imgRef=ImageRef::replaceImage(_imgRef,image);
4939 void Magick::Image::read(MagickCore::Image *image,
4940 MagickCore::ExceptionInfo *exceptionInfo)
4942 // Ensure that multiple image frames were not read.
4943 if (image != (MagickCore::Image *) NULL &&
4944 image->next != (MagickCore::Image *) NULL)
4949 // Destroy any extra image frames
4951 image->next=(MagickCore::Image *) NULL;
4952 next->previous=(MagickCore::Image *) NULL;
4953 DestroyImageList(next);
4955 replaceImage(image);
4956 if (exceptionInfo->severity == MagickCore::UndefinedException &&
4957 image == (MagickCore::Image *) NULL)
4959 (void) MagickCore::DestroyExceptionInfo(exceptionInfo);
4961 throwExceptionExplicit(MagickCore::ImageWarning,
4962 "No image was loaded.");
4964 ThrowImageException;
4967 void Magick::Image::floodFill(const ssize_t x_,const ssize_t y_,
4968 const Magick::Image *fillPattern_,const Magick::Color &fill_,
4969 const MagickCore::PixelInfo *target_,const bool invert_)
4977 // Set drawing fill pattern or fill color
4978 fillColor=options()->fillColor();
4979 fillPattern=(MagickCore::Image *)NULL;
4980 if (options()->fillPattern() != (MagickCore::Image *)NULL)
4983 fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
4985 ThrowImageException;
4988 if (fillPattern_ == (Magick::Image *)NULL)
4990 options()->fillPattern((MagickCore::Image *)NULL);
4991 options()->fillColor(fill_);
4994 options()->fillPattern(fillPattern_->constImage());
4997 (void) FloodfillPaintImage(image(),options()->drawInfo(),
4998 target_,static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),
4999 (MagickBooleanType) invert_,exceptionInfo);
5001 options()->fillColor(fillColor);
5002 options()->fillPattern(fillPattern);
5003 ThrowImageException;