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 Image &image_,const Geometry &geometry_)
207 : _imgRef(new ImageRef)
219 image=CloneImage(image_.constImage(),geometry_.width(),geometry_.height(),
220 MagickTrue,exceptionInfo);
222 _imgRef->options(new Options(*image_.constOptions()));
225 (void) CopyImagePixels(image,image_.constImage(),&geometry,&offset,
230 Magick::Image::Image(const size_t width_,const size_t height_,
231 const std::string &map_,const StorageType type_,const void *pixels_)
232 : _imgRef(new ImageRef)
237 read(width_,height_,map_.c_str(),type_,pixels_);
248 Magick::Image::Image(const std::string &imageSpec_)
249 : _imgRef(new ImageRef)
253 // Initialize, Allocate and Read images
266 Magick::Image::~Image()
268 if (_imgRef->decrease() == 0)
271 _imgRef=(Magick::ImageRef *) NULL;
274 Magick::Image& Magick::Image::operator=(const Magick::Image &image_)
278 image_._imgRef->increase();
279 if (_imgRef->decrease() == 0)
282 // Use new image reference
283 _imgRef=image_._imgRef;
288 void Magick::Image::adjoin(const bool flag_)
291 options()->adjoin(flag_);
294 bool Magick::Image::adjoin(void) const
296 return(constOptions()->adjoin());
299 void Magick::Image::alpha(const bool matteFlag_)
303 // If matte channel is requested, but image doesn't already have a
304 // matte channel, then create an opaque matte channel. Likewise, if
305 // the image already has a matte channel but a matte channel is not
306 // desired, then set the matte channel to opaque.
308 if ((matteFlag_ && !constImage()->alpha_trait) ||
309 (constImage()->alpha_trait && !matteFlag_))
310 SetImageAlpha(image(),OpaqueAlpha,exceptionInfo);
313 image()->alpha_trait=matteFlag_ ? BlendPixelTrait : UndefinedPixelTrait;
316 bool Magick::Image::alpha(void) const
318 if (constImage()->alpha_trait == BlendPixelTrait)
324 void Magick::Image::alphaColor(const Color &alphaColor_)
328 if (alphaColor_.isValid())
330 image()->matte_color=alphaColor_;
331 options()->matteColor(alphaColor_);
335 // Set to default matte color
336 Color tmpColor("#BDBDBD");
337 image()->matte_color=tmpColor;
338 options()->matteColor(tmpColor);
342 Magick::Color Magick::Image::alphaColor(void) const
344 return(Color(constImage()->matte_color));
347 void Magick::Image::antiAlias(const bool flag_)
350 options()->antiAlias(flag_);
353 bool Magick::Image::antiAlias(void) const
355 return(constOptions()->antiAlias());
358 void Magick::Image::animationDelay(const size_t delay_)
361 image()->delay=delay_;
364 size_t Magick::Image::animationDelay(void) const
366 return(constImage()->delay);
369 void Magick::Image::animationIterations(const size_t iterations_)
372 image()->iterations=iterations_;
375 size_t Magick::Image::animationIterations(void) const
377 return(constImage()->iterations);
380 void Magick::Image::attenuate(const double attenuate_)
383 value[MagickPathExtent];
386 FormatLocaleString(value,MagickPathExtent,"%.20g",attenuate_);
387 (void) SetImageArtifact(image(),"attenuate",value);
390 void Magick::Image::backgroundColor(const Color &backgroundColor_)
394 if (backgroundColor_.isValid())
395 image()->background_color=backgroundColor_;
397 image()->background_color=Color();
399 options()->backgroundColor(backgroundColor_);
402 Magick::Color Magick::Image::backgroundColor(void) const
404 return(constOptions()->backgroundColor());
407 void Magick::Image::backgroundTexture(const std::string &backgroundTexture_)
410 options()->backgroundTexture(backgroundTexture_);
413 std::string Magick::Image::backgroundTexture(void) const
415 return(constOptions()->backgroundTexture());
418 size_t Magick::Image::baseColumns(void) const
420 return(constImage()->magick_columns);
423 std::string Magick::Image::baseFilename(void) const
425 return(std::string(constImage()->magick_filename));
428 size_t Magick::Image::baseRows(void) const
430 return(constImage()->magick_rows);
433 void Magick::Image::blackPointCompensation(const bool flag_)
435 image()->black_point_compensation=(MagickBooleanType) flag_;
438 bool Magick::Image::blackPointCompensation(void) const
440 return(static_cast<bool>(constImage()->black_point_compensation));
443 void Magick::Image::borderColor(const Color &borderColor_)
447 if (borderColor_.isValid())
448 image()->border_color=borderColor_;
450 image()->border_color=Color();
452 options()->borderColor(borderColor_);
455 Magick::Color Magick::Image::borderColor(void) const
457 return(constOptions()->borderColor());
460 Magick::Geometry Magick::Image::boundingBox(void) const
466 bbox=GetImageBoundingBox(constImage(),exceptionInfo);
468 return(Geometry(bbox));
471 void Magick::Image::boxColor(const Color &boxColor_)
474 options()->boxColor(boxColor_);
477 Magick::Color Magick::Image::boxColor(void) const
479 return(constOptions()->boxColor());
482 void Magick::Image::channelDepth(const ChannelType channel_,
487 GetAndSetPPChannelMask(channel_);
488 SetImageDepth(image(),depth_,exceptionInfo);
489 RestorePPChannelMask;
493 size_t Magick::Image::channelDepth(const ChannelType channel_)
499 GetAndSetPPChannelMask(channel_);
500 channel_depth=GetImageDepth(constImage(),exceptionInfo);
501 RestorePPChannelMask;
503 return(channel_depth);
506 size_t Magick::Image::channels() const
508 return(constImage()->number_channels);
511 void Magick::Image::classType(const ClassType class_)
513 if (classType() == PseudoClass && class_ == DirectClass)
515 // Use SyncImage to synchronize the DirectClass pixels with the
516 // color map and then set to DirectClass type.
519 SyncImage(image(),exceptionInfo);
521 image()->colormap=(PixelInfo *)RelinquishMagickMemory(image()->colormap);
522 image()->storage_class=static_cast<MagickCore::ClassType>(DirectClass);
526 if (classType() == DirectClass && class_ == PseudoClass)
528 // Quantize to create PseudoClass color map
530 quantizeColors(MaxColormapSize);
532 image()->storage_class=static_cast<MagickCore::ClassType>(PseudoClass);
536 Magick::ClassType Magick::Image::classType(void) const
538 return static_cast<Magick::ClassType>(constImage()->storage_class);
541 void Magick::Image::colorFuzz(const double fuzz_)
545 options()->colorFuzz(fuzz_);
548 double Magick::Image::colorFuzz(void) const
550 return(constOptions()->colorFuzz());
553 void Magick::Image::colorMapSize(const size_t entries_)
555 if (entries_ >MaxColormapSize)
556 throwExceptionExplicit(MagickCore::OptionError,
557 "Colormap entries must not exceed MaxColormapSize");
561 (void) AcquireImageColormap(image(),entries_,exceptionInfo);
565 size_t Magick::Image::colorMapSize(void) const
567 if (!constImage()->colormap)
568 throwExceptionExplicit(MagickCore::OptionError,
569 "Image does not contain a colormap");
571 return(constImage()->colors);
574 void Magick::Image::colorSpace(const ColorspaceType colorSpace_)
576 if (image()->colorspace == colorSpace_)
581 TransformImageColorspace(image(),colorSpace_,exceptionInfo);
585 Magick::ColorspaceType Magick::Image::colorSpace(void) const
587 return (constImage()->colorspace);
590 void Magick::Image::colorSpaceType(const ColorspaceType colorSpace_)
594 SetImageColorspace(image(),colorSpace_,exceptionInfo);
596 options()->colorspaceType(colorSpace_);
599 Magick::ColorspaceType Magick::Image::colorSpaceType(void) const
601 return(constOptions()->colorspaceType());
604 size_t Magick::Image::columns(void) const
606 return(constImage()->columns);
609 void Magick::Image::comment(const std::string &comment_)
613 SetImageProperty(image(),"Comment",NULL,exceptionInfo);
614 if (comment_.length() > 0)
615 SetImageProperty(image(),"Comment",comment_.c_str(),exceptionInfo);
619 std::string Magick::Image::comment(void) const
625 value=GetImageProperty(constImage(),"Comment",exceptionInfo);
629 return(std::string(value));
631 return(std::string()); // Intentionally no exception
634 void Magick::Image::compose(const CompositeOperator compose_)
636 image()->compose=compose_;
639 Magick::CompositeOperator Magick::Image::compose(void) const
641 return(constImage()->compose);
644 void Magick::Image::compressType(const CompressionType compressType_)
647 image()->compression=compressType_;
648 options()->compressType(compressType_);
651 Magick::CompressionType Magick::Image::compressType(void) const
653 return(constImage()->compression);
656 void Magick::Image::debug(const bool flag_)
659 options()->debug(flag_);
662 bool Magick::Image::debug(void) const
664 return(constOptions()->debug());
667 void Magick::Image::density(const Point &density_)
670 options()->density(density_);
671 if (density_.isValid())
673 image()->resolution.x=density_.x();
674 if (density_.y() != 0.0)
675 image()->resolution.y=density_.y();
677 image()->resolution.y=density_.x();
682 image()->resolution.x=0.0;
683 image()->resolution.y=0.0;
687 Magick::Point Magick::Image::density(void) const
695 if (constImage()->resolution.x > 0.0)
696 x_resolution=constImage()->resolution.x;
698 if (constImage()->resolution.y > 0.0)
699 y_resolution=constImage()->resolution.y;
701 return(Point(x_resolution,y_resolution));
704 return(constOptions()->density());
707 void Magick::Image::depth(const size_t depth_)
712 if (depth > MAGICKCORE_QUANTUM_DEPTH)
713 depth=MAGICKCORE_QUANTUM_DEPTH;
716 image()->depth=depth;
717 options()->depth(depth);
720 size_t Magick::Image::depth(void) const
722 return(constImage()->depth);
725 std::string Magick::Image::directory(void) const
727 if (constImage()->directory)
728 return(std::string(constImage()->directory));
731 throwExceptionExplicit(MagickCore::CorruptImageWarning,
732 "Image does not contain a directory");
734 return(std::string());
737 void Magick::Image::endian(const Magick::EndianType endian_)
740 options()->endian(endian_);
741 image()->endian=endian_;
744 Magick::EndianType Magick::Image::endian(void) const
746 return(constImage()->endian);
749 void Magick::Image::exifProfile(const Magick::Blob &exifProfile_)
753 if (exifProfile_.data() != 0)
758 exif_profile=AcquireStringInfo(exifProfile_.length());
759 SetStringInfoDatum(exif_profile,(unsigned char *) exifProfile_.data());
761 (void) SetImageProfile(image(),"exif",exif_profile,exceptionInfo);
762 exif_profile=DestroyStringInfo(exif_profile);
767 Magick::Blob Magick::Image::exifProfile(void) const
772 exif_profile=GetImageProfile(constImage(),"exif");
773 if (exif_profile == (StringInfo *) NULL)
775 return(Blob(GetStringInfoDatum(exif_profile),
776 GetStringInfoLength(exif_profile)));
779 void Magick::Image::fileName(const std::string &fileName_)
783 fileName_.copy(image()->filename,sizeof(image()->filename)-1);
784 image()->filename[fileName_.length()]=0; // Null terminate
786 options()->fileName(fileName_);
789 std::string Magick::Image::fileName(void) const
791 return(constOptions()->fileName());
794 MagickCore::MagickSizeType Magick::Image::fileSize(void) const
796 return(GetBlobSize(constImage()));
799 void Magick::Image::fillColor(const Magick::Color &fillColor_)
802 options()->fillColor(fillColor_);
805 Magick::Color Magick::Image::fillColor(void) const
807 return(constOptions()->fillColor());
810 void Magick::Image::fillRule(const Magick::FillRule &fillRule_)
813 options()->fillRule(fillRule_);
816 Magick::FillRule Magick::Image::fillRule(void) const
818 return constOptions()->fillRule();
821 void Magick::Image::fillPattern(const Image &fillPattern_)
824 if (fillPattern_.isValid())
825 options()->fillPattern(fillPattern_.constImage());
827 options()->fillPattern(static_cast<MagickCore::Image*>(NULL));
830 Magick::Image Magick::Image::fillPattern(void) const
832 // FIXME: This is inordinately innefficient
833 const MagickCore::Image
839 tmpTexture=constOptions()->fillPattern();
847 image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
848 texture.replaceImage(image);
854 void Magick::Image::filterType(const Magick::FilterTypes filterType_)
857 image()->filter=filterType_;
860 Magick::FilterTypes Magick::Image::filterType(void) const
862 return(constImage()->filter);
865 void Magick::Image::font(const std::string &font_)
868 options()->font(font_);
871 std::string Magick::Image::font(void) const
873 return(constOptions()->font());
876 void Magick::Image::fontFamily(const std::string &family_)
879 options()->fontFamily(family_);
882 std::string Magick::Image::fontFamily(void) const
884 return(constOptions()->fontFamily());
887 void Magick::Image::fontPointsize(const double pointSize_)
890 options()->fontPointsize(pointSize_);
893 double Magick::Image::fontPointsize(void) const
895 return(constOptions()->fontPointsize());
898 void Magick::Image::fontStyle(const StyleType pointSize_)
901 options()->fontStyle(pointSize_);
904 Magick::StyleType Magick::Image::fontStyle(void) const
906 return(constOptions()->fontStyle());
909 void Magick::Image::fontWeight(const size_t weight_)
912 options()->fontWeight(weight_);
915 size_t Magick::Image::fontWeight(void) const
917 return(constOptions()->fontWeight());
920 std::string Magick::Image::format(void) const
926 magick_info=GetMagickInfo(constImage()->magick,exceptionInfo);
929 if ((magick_info != 0) && (*magick_info->description != '\0'))
930 return(std::string(magick_info->description));
933 throwExceptionExplicit(MagickCore::CorruptImageWarning,
934 "Unrecognized image magick type");
936 return(std::string());
939 std::string Magick::Image::formatExpression(const std::string expression)
949 text=InterpretImageProperties(imageInfo(),image(),expression.c_str(),
951 if (text != (char *) NULL)
953 text_string=std::string(text);
954 text=DestroyString(text);
960 double Magick::Image::gamma(void) const
962 return(constImage()->gamma);
965 Magick::Geometry Magick::Image::geometry(void) const
967 if (constImage()->geometry)
968 return Geometry(constImage()->geometry);
971 throwExceptionExplicit(MagickCore::OptionWarning,
972 "Image does not contain a geometry");
977 void Magick::Image::gifDisposeMethod(
978 const MagickCore::DisposeType disposeMethod_)
981 image()->dispose=disposeMethod_;
984 MagickCore::DisposeType Magick::Image::gifDisposeMethod(void) const
986 return(constImage()->dispose);
989 bool Magick::Image::hasChannel(const PixelChannel channel) const
991 if (GetPixelChannelTraits(constImage(),channel) == UndefinedPixelTrait)
994 if (channel == GreenPixelChannel || channel == BluePixelChannel)
995 return (GetPixelChannelOffset(constImage(),channel) == (ssize_t)channel);
1000 void Magick::Image::highlightColor(const Color color_)
1006 artifact("highlight-color",value);
1009 void Magick::Image::iccColorProfile(const Magick::Blob &colorProfile_)
1011 profile("icc",colorProfile_);
1014 Magick::Blob Magick::Image::iccColorProfile(void) const
1019 color_profile=GetImageProfile(constImage(),"icc");
1020 if (color_profile == (StringInfo *) NULL)
1022 return(Blob(GetStringInfoDatum(color_profile),GetStringInfoLength(
1026 void Magick::Image::interlaceType(const Magick::InterlaceType interlace_)
1029 image()->interlace=interlace_;
1030 options()->interlaceType(interlace_);
1033 Magick::InterlaceType Magick::Image::interlaceType(void) const
1035 return(constImage()->interlace);
1038 void Magick::Image::interpolate(const PixelInterpolateMethod interpolate_)
1041 image()->interpolate=interpolate_;
1044 Magick::PixelInterpolateMethod Magick::Image::interpolate(void) const
1046 return constImage()->interpolate;
1049 void Magick::Image::iptcProfile(const Magick::Blob &iptcProfile_)
1052 if (iptcProfile_.data() != 0)
1057 iptc_profile=AcquireStringInfo(iptcProfile_.length());
1058 SetStringInfoDatum(iptc_profile,(unsigned char *) iptcProfile_.data());
1060 (void) SetImageProfile(image(),"iptc",iptc_profile,exceptionInfo);
1061 iptc_profile=DestroyStringInfo(iptc_profile);
1062 ThrowImageException;
1066 Magick::Blob Magick::Image::iptcProfile(void) const
1071 iptc_profile=GetImageProfile(constImage(),"iptc");
1072 if (iptc_profile == (StringInfo *) NULL)
1074 return(Blob(GetStringInfoDatum(iptc_profile),GetStringInfoLength(
1078 bool Magick::Image::isOpaque(void) const
1084 result=IsImageOpaque(constImage(),exceptionInfo);
1085 ThrowImageException;
1086 return(result != MagickFalse ? true : false);
1089 void Magick::Image::isValid(const bool isValid_)
1094 _imgRef=new ImageRef;
1096 else if (!isValid())
1098 // Construct with single-pixel black image to make
1099 // image valid. This is an obvious hack.
1100 size(Geometry(1,1));
1105 bool Magick::Image::isValid(void) const
1107 return rows() && columns();
1110 void Magick::Image::label(const std::string &label_)
1114 (void) SetImageProperty(image(),"Label",NULL,exceptionInfo);
1115 if (label_.length() > 0)
1116 (void) SetImageProperty(image(),"Label",label_.c_str(),exceptionInfo);
1117 ThrowImageException;
1120 std::string Magick::Image::label(void) const
1126 value=GetImageProperty(constImage(),"Label",exceptionInfo);
1127 ThrowImageException;
1130 return(std::string(value));
1132 return(std::string());
1135 void Magick::Image::lowlightColor(const Color color_)
1141 artifact("lowlight-color",value);
1144 void Magick::Image::mask(const Magick::Image &mask_)
1149 if (mask_.isValid())
1150 SetImageMask(image(),ReadPixelMask,mask_.constImage(),exceptionInfo);
1152 SetImageMask(image(),ReadPixelMask,(MagickCore::Image *) NULL,
1154 ThrowImageException;
1157 Magick::Image Magick::Image::mask(void) const
1163 image=GetImageMask(constImage(),exceptionInfo);
1164 ThrowImageException;
1166 if (image == (MagickCore::Image *) NULL)
1167 return(Magick::Image());
1169 return(Magick::Image(image));
1172 void Magick::Image::magick(const std::string &magick_)
1179 length=sizeof(image()->magick)-1;
1180 if (magick_.length() < length)
1181 length=magick_.length();
1183 if (!magick_.empty())
1184 magick_.copy(image()->magick,length);
1185 image()->magick[length]=0;
1187 options()->magick(magick_);
1190 std::string Magick::Image::magick(void) const
1192 if (*(constImage()->magick) != '\0')
1193 return(std::string(constImage()->magick));
1195 return(constOptions()->magick());
1198 double Magick::Image::meanErrorPerPixel(void) const
1200 return(constImage()->error.mean_error_per_pixel);
1203 void Magick::Image::modulusDepth(const size_t depth_)
1207 SetImageDepth(image(),depth_,exceptionInfo);
1208 ThrowImageException;
1209 options()->depth(depth_);
1212 size_t Magick::Image::modulusDepth(void) const
1218 depth=GetImageDepth(constImage(),exceptionInfo);
1219 ThrowImageException;
1223 void Magick::Image::monochrome(const bool monochromeFlag_)
1226 options()->monochrome(monochromeFlag_);
1229 bool Magick::Image::monochrome(void) const
1231 return(constOptions()->monochrome());
1234 Magick::Geometry Magick::Image::montageGeometry(void) const
1236 if (constImage()->montage)
1237 return Magick::Geometry(constImage()->montage);
1240 throwExceptionExplicit(MagickCore::CorruptImageWarning,
1241 "Image does not contain a montage");
1243 return(Magick::Geometry());
1246 double Magick::Image::normalizedMaxError(void) const
1248 return(constImage()->error.normalized_maximum_error);
1251 double Magick::Image::normalizedMeanError(void) const
1253 return(constImage()->error.normalized_mean_error);
1256 void Magick::Image::orientation(const Magick::OrientationType orientation_)
1259 image()->orientation=orientation_;
1262 Magick::OrientationType Magick::Image::orientation(void) const
1264 return(constImage()->orientation);
1267 void Magick::Image::page(const Magick::Geometry &pageSize_)
1270 options()->page(pageSize_);
1271 image()->page=pageSize_;
1274 Magick::Geometry Magick::Image::page(void) const
1276 return(Geometry(constImage()->page.width,constImage()->page.height,
1277 constImage()->page.x,constImage()->page.y));
1280 void Magick::Image::quality(const size_t quality_)
1283 image()->quality=quality_;
1284 options()->quality(quality_);
1287 size_t Magick::Image::quality(void) const
1289 return(constImage()->quality);
1292 void Magick::Image::quantizeColors(const size_t colors_)
1295 options()->quantizeColors(colors_);
1298 size_t Magick::Image::quantizeColors(void) const
1300 return(constOptions()->quantizeColors());
1303 void Magick::Image::quantizeColorSpace(
1304 const Magick::ColorspaceType colorSpace_)
1307 options()->quantizeColorSpace(colorSpace_);
1310 Magick::ColorspaceType Magick::Image::quantizeColorSpace(void) const
1312 return(constOptions()->quantizeColorSpace());
1315 void Magick::Image::quantizeDither(const bool ditherFlag_)
1318 options()->quantizeDither(ditherFlag_);
1321 bool Magick::Image::quantizeDither(void) const
1323 return(constOptions()->quantizeDither());
1326 void Magick::Image::quantizeDitherMethod(const DitherMethod ditherMethod_)
1329 options()->quantizeDitherMethod(ditherMethod_);
1332 MagickCore::DitherMethod Magick::Image::quantizeDitherMethod(void) const
1334 return(constOptions()->quantizeDitherMethod());
1337 void Magick::Image::quantizeTreeDepth(const size_t treeDepth_)
1340 options()->quantizeTreeDepth(treeDepth_);
1343 size_t Magick::Image::quantizeTreeDepth() const
1345 return(constOptions()->quantizeTreeDepth());
1348 void Magick::Image::quiet(const bool quiet_)
1351 options()->quiet(quiet_);
1354 bool Magick::Image::quiet(void) const
1356 return(constOptions()->quiet());
1359 void Magick::Image::renderingIntent(
1360 const Magick::RenderingIntent renderingIntent_)
1363 image()->rendering_intent=renderingIntent_;
1366 Magick::RenderingIntent Magick::Image::renderingIntent(void) const
1368 return(static_cast<Magick::RenderingIntent>(constImage()->rendering_intent));
1371 void Magick::Image::resolutionUnits(
1372 const Magick::ResolutionType resolutionUnits_)
1375 image()->units=resolutionUnits_;
1376 options()->resolutionUnits(resolutionUnits_);
1379 Magick::ResolutionType Magick::Image::resolutionUnits(void) const
1381 return(static_cast<Magick::ResolutionType>(constImage()->units));
1384 size_t Magick::Image::rows(void) const
1386 return(constImage()->rows);
1389 void Magick::Image::scene(const size_t scene_)
1392 image()->scene=scene_;
1395 size_t Magick::Image::scene(void) const
1397 return(constImage()->scene);
1400 void Magick::Image::size(const Geometry &geometry_)
1403 options()->size(geometry_);
1404 image()->rows=geometry_.height();
1405 image()->columns=geometry_.width();
1408 Magick::Geometry Magick::Image::size(void) const
1410 return(Magick::Geometry(constImage()->columns,constImage()->rows));
1413 void Magick::Image::strokeAntiAlias(const bool flag_)
1416 options()->strokeAntiAlias(flag_);
1419 bool Magick::Image::strokeAntiAlias(void) const
1421 return(constOptions()->strokeAntiAlias());
1424 void Magick::Image::strokeColor(const Magick::Color &strokeColor_)
1430 options()->strokeColor(strokeColor_);
1432 artifact("stroke",value);
1435 Magick::Color Magick::Image::strokeColor(void) const
1437 return(constOptions()->strokeColor());
1440 void Magick::Image::strokeDashArray(const double *strokeDashArray_)
1443 options()->strokeDashArray(strokeDashArray_);
1446 const double* Magick::Image::strokeDashArray(void) const
1448 return(constOptions()->strokeDashArray());
1451 void Magick::Image::strokeDashOffset(const double strokeDashOffset_)
1454 options()->strokeDashOffset(strokeDashOffset_);
1457 double Magick::Image::strokeDashOffset(void) const
1459 return(constOptions()->strokeDashOffset());
1462 void Magick::Image::strokeLineCap(const Magick::LineCap lineCap_)
1465 options()->strokeLineCap(lineCap_);
1468 Magick::LineCap Magick::Image::strokeLineCap(void) const
1470 return(constOptions()->strokeLineCap());
1473 void Magick::Image::strokeLineJoin(const Magick::LineJoin lineJoin_)
1476 options()->strokeLineJoin(lineJoin_);
1479 Magick::LineJoin Magick::Image::strokeLineJoin(void) const
1481 return(constOptions()->strokeLineJoin());
1484 void Magick::Image::strokeMiterLimit(const size_t strokeMiterLimit_)
1487 options()->strokeMiterLimit(strokeMiterLimit_);
1490 size_t Magick::Image::strokeMiterLimit(void) const
1492 return(constOptions()->strokeMiterLimit());
1495 void Magick::Image::strokePattern(const Image &strokePattern_)
1498 if(strokePattern_.isValid())
1499 options()->strokePattern(strokePattern_.constImage());
1501 options()->strokePattern(static_cast<MagickCore::Image*>(NULL));
1504 Magick::Image Magick::Image::strokePattern(void) const
1506 // FIXME: This is inordinately innefficient
1507 const MagickCore::Image
1513 tmpTexture=constOptions()->strokePattern();
1521 image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
1522 texture.replaceImage(image);
1523 ThrowImageException;
1528 void Magick::Image::strokeWidth(const double strokeWidth_)
1531 value[MagickPathExtent];
1534 options()->strokeWidth(strokeWidth_);
1535 FormatLocaleString(value,MagickPathExtent,"%.20g",strokeWidth_);
1536 (void) SetImageArtifact(image(),"strokewidth",value);
1539 double Magick::Image::strokeWidth(void) const
1541 return(constOptions()->strokeWidth());
1544 void Magick::Image::subImage(const size_t subImage_)
1547 options()->subImage(subImage_);
1550 size_t Magick::Image::subImage(void) const
1552 return(constOptions()->subImage());
1555 void Magick::Image::subRange(const size_t subRange_)
1558 options()->subRange(subRange_);
1561 size_t Magick::Image::subRange(void) const
1563 return(constOptions()->subRange());
1566 void Magick::Image::textDirection(DirectionType direction_)
1569 options()->textDirection(direction_);
1572 Magick::DirectionType Magick::Image::textDirection(void) const
1574 return(constOptions()->textDirection());
1577 void Magick::Image::textEncoding(const std::string &encoding_)
1580 options()->textEncoding(encoding_);
1583 std::string Magick::Image::textEncoding(void) const
1585 return(constOptions()->textEncoding());
1588 void Magick::Image::textGravity(GravityType gravity_)
1591 options()->textGravity(gravity_);
1594 Magick::GravityType Magick::Image::textGravity(void) const
1596 return(constOptions()->textGravity());
1599 void Magick::Image::textInterlineSpacing(double spacing_)
1602 options()->textInterlineSpacing(spacing_);
1605 double Magick::Image::textInterlineSpacing(void) const
1607 return(constOptions()->textInterlineSpacing());
1610 void Magick::Image::textInterwordSpacing(double spacing_)
1613 options()->textInterwordSpacing(spacing_);
1616 double Magick::Image::textInterwordSpacing(void) const
1618 return(constOptions()->textInterwordSpacing());
1621 void Magick::Image::textKerning(double kerning_)
1624 options()->textKerning(kerning_);
1627 double Magick::Image::textKerning(void) const
1629 return(constOptions()->textKerning());
1632 void Magick::Image::textUnderColor(const Color &underColor_)
1635 options()->textUnderColor(underColor_);
1638 Magick::Color Magick::Image::textUnderColor(void) const
1640 return(constOptions()->textUnderColor());
1643 size_t Magick::Image::totalColors(void) const
1649 colors=GetNumberColors(constImage(),(FILE *) NULL,exceptionInfo);
1650 ThrowImageException;
1654 void Magick::Image::transformRotation(const double angle_)
1657 options()->transformRotation(angle_);
1660 void Magick::Image::transformSkewX(const double skewx_)
1663 options()->transformSkewX(skewx_);
1666 void Magick::Image::transformSkewY(const double skewy_)
1669 options()->transformSkewY(skewy_);
1672 Magick::ImageType Magick::Image::type(void) const
1674 if (constOptions()->type() != UndefinedType)
1675 return(constOptions()->type());
1676 return(GetImageType(constImage()));
1679 void Magick::Image::type(const Magick::ImageType type_)
1682 options()->type(type_);
1684 SetImageType(image(),type_,exceptionInfo);
1685 ThrowImageException;
1688 void Magick::Image::verbose(const bool verboseFlag_)
1691 options()->verbose(verboseFlag_);
1694 bool Magick::Image::verbose(void) const
1696 return(constOptions()->verbose());
1699 void Magick::Image::view(const std::string &view_)
1702 options()->view(view_);
1705 std::string Magick::Image::view(void) const
1707 return(constOptions()->view());
1710 void Magick::Image::virtualPixelMethod(
1711 const VirtualPixelMethod virtualPixelMethod_)
1715 SetImageVirtualPixelMethod(image(),virtualPixelMethod_,exceptionInfo);
1716 ThrowImageException;
1719 Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod(void) const
1721 return(GetImageVirtualPixelMethod(constImage()));
1724 void Magick::Image::x11Display(const std::string &display_)
1727 options()->x11Display(display_);
1730 std::string Magick::Image::x11Display(void) const
1732 return(constOptions()->x11Display());
1735 double Magick::Image::xResolution(void) const
1737 return(constImage()->resolution.x);
1740 double Magick::Image::yResolution(void) const
1742 return(constImage()->resolution.y);
1745 void Magick::Image::adaptiveBlur(const double radius_,const double sigma_)
1751 newImage=AdaptiveBlurImage(constImage(),radius_,sigma_,exceptionInfo);
1752 replaceImage(newImage);
1753 ThrowImageException;
1756 void Magick::Image::adaptiveResize(const Geometry &geometry_)
1769 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
1773 newImage=AdaptiveResizeImage(constImage(),width,height,exceptionInfo);
1774 replaceImage(newImage);
1775 ThrowImageException;
1778 void Magick::Image::adaptiveSharpen(const double radius_,const double sigma_)
1784 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1785 replaceImage(newImage);
1786 ThrowImageException;
1789 void Magick::Image::adaptiveSharpenChannel(const ChannelType channel_,
1790 const double radius_,const double sigma_ )
1796 GetAndSetPPChannelMask(channel_);
1797 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1798 RestorePPChannelMask;
1799 replaceImage(newImage);
1800 ThrowImageException;
1803 void Magick::Image::adaptiveThreshold(const size_t width_,const size_t height_,
1811 newImage=AdaptiveThresholdImage(constImage(),width_,height_,bias_,
1813 replaceImage(newImage);
1814 ThrowImageException;
1817 void Magick::Image::addNoise(const NoiseType noiseType_)
1823 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1824 replaceImage(newImage);
1825 ThrowImageException;
1828 void Magick::Image::addNoiseChannel(const ChannelType channel_,
1829 const NoiseType noiseType_)
1835 GetAndSetPPChannelMask(channel_);
1836 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1837 RestorePPChannelMask;
1838 replaceImage(newImage);
1839 ThrowImageException;
1842 void Magick::Image::affineTransform(const DrawableAffine &affine_)
1850 _affine.sx=affine_.sx();
1851 _affine.sy=affine_.sy();
1852 _affine.rx=affine_.rx();
1853 _affine.ry=affine_.ry();
1854 _affine.tx=affine_.tx();
1855 _affine.ty=affine_.ty();
1858 newImage=AffineTransformImage(constImage(),&_affine,exceptionInfo);
1859 replaceImage(newImage);
1860 ThrowImageException;
1863 void Magick::Image::alpha(const unsigned int alpha_)
1867 SetImageAlpha(image(),alpha_,exceptionInfo);
1868 ThrowImageException;
1871 void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
1875 SetImageAlphaChannel(image(),alphaOption_,exceptionInfo);
1876 ThrowImageException;
1879 void Magick::Image::annotate(const std::string &text_,
1880 const Geometry &location_)
1882 annotate(text_,location_,NorthWestGravity,0.0);
1885 void Magick::Image::annotate(const std::string &text_,
1886 const Geometry &boundingArea_,const GravityType gravity_)
1888 annotate(text_,boundingArea_,gravity_,0.0);
1891 void Magick::Image::annotate(const std::string &text_,
1892 const Geometry &boundingArea_,const GravityType gravity_,
1893 const double degrees_)
1899 boundingArea[MagickPathExtent];
1906 drawInfo=options()->drawInfo();
1907 drawInfo->text=const_cast<char *>(text_.c_str());
1908 drawInfo->geometry=0;
1910 if (boundingArea_.isValid())
1912 if (boundingArea_.width() == 0 || boundingArea_.height() == 0)
1914 FormatLocaleString(boundingArea,MagickPathExtent,"%+.20g%+.20g",
1915 (double) boundingArea_.xOff(),(double) boundingArea_.yOff());
1919 (void) CopyMagickString(boundingArea,
1920 std::string(boundingArea_).c_str(), MagickPathExtent);
1922 drawInfo->geometry=boundingArea;
1925 drawInfo->gravity=gravity_;
1927 oaffine=drawInfo->affine;
1928 if (degrees_ != 0.0)
1941 current=drawInfo->affine;
1942 affine.sx=cos(DegreesToRadians(fmod(degrees_,360.0)));
1943 affine.rx=sin(DegreesToRadians(fmod(degrees_,360.0)));
1944 affine.ry=(-sin(DegreesToRadians(fmod(degrees_,360.0))));
1945 affine.sy=cos(DegreesToRadians(fmod(degrees_,360.0)));
1947 drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
1948 drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
1949 drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
1950 drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
1951 drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty
1956 AnnotateImage(image(),drawInfo,exceptionInfo);
1958 // Restore original values
1959 drawInfo->affine=oaffine;
1961 drawInfo->geometry=0;
1963 ThrowImageException;
1966 void Magick::Image::annotate(const std::string &text_,
1967 const GravityType gravity_)
1974 drawInfo=options()->drawInfo();
1975 drawInfo->text=const_cast<char *>(text_.c_str());
1976 drawInfo->gravity=gravity_;
1979 AnnotateImage(image(),drawInfo,exceptionInfo);
1981 drawInfo->gravity=NorthWestGravity;
1984 ThrowImageException;
1987 void Magick::Image::artifact(const std::string &name_,const std::string &value_)
1990 (void) SetImageArtifact(image(),name_.c_str(),value_.c_str());
1993 std::string Magick::Image::artifact(const std::string &name_) const
1998 value=GetImageArtifact(constImage(),name_.c_str());
2000 return(std::string(value));
2001 return(std::string());
2004 void Magick::Image::attribute(const std::string name_,const std::string value_)
2008 SetImageProperty(image(),name_.c_str(),value_.c_str(),exceptionInfo);
2009 ThrowImageException;
2012 std::string Magick::Image::attribute(const std::string name_) const
2018 value=GetImageProperty(constImage(),name_.c_str(),exceptionInfo);
2019 ThrowImageException;
2022 return(std::string(value));
2024 return(std::string()); // Intentionally no exception
2027 void Magick::Image::autoGamma(void)
2031 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2032 (void) AutoGammaImage(image(),exceptionInfo);
2033 ThrowImageException;
2036 void Magick::Image::autoGammaChannel(const ChannelType channel_)
2040 GetAndSetPPChannelMask(channel_);
2041 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2042 (void) AutoGammaImage(image(),exceptionInfo);
2043 RestorePPChannelMask;
2044 ThrowImageException;
2047 void Magick::Image::autoLevel(void)
2051 (void) AutoLevelImage(image(),exceptionInfo);
2052 ThrowImageException;
2055 void Magick::Image::autoLevelChannel(const ChannelType channel_)
2059 GetAndSetPPChannelMask(channel_);
2060 (void) AutoLevelImage(image(),exceptionInfo);
2061 RestorePPChannelMask;
2062 ThrowImageException;
2065 void Magick::Image::autoOrient(void)
2070 if (image()->orientation == UndefinedOrientation ||
2071 image()->orientation == TopLeftOrientation)
2075 newImage=AutoOrientImage(constImage(),image()->orientation,exceptionInfo);
2076 replaceImage(newImage);
2077 ThrowImageException;
2080 void Magick::Image::blackThreshold(const std::string &threshold_)
2084 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2085 ThrowImageException;
2088 void Magick::Image::blackThresholdChannel(const ChannelType channel_,
2089 const std::string &threshold_)
2093 GetAndSetPPChannelMask(channel_);
2094 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2095 RestorePPChannelMask;
2096 ThrowImageException;
2099 void Magick::Image::blueShift(const double factor_)
2105 newImage=BlueShiftImage(constImage(),factor_,exceptionInfo);
2106 replaceImage(newImage);
2107 ThrowImageException;
2110 void Magick::Image::blur(const double radius_,const double sigma_)
2116 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2117 replaceImage(newImage);
2118 ThrowImageException;
2121 void Magick::Image::blurChannel(const ChannelType channel_,
2122 const double radius_,const double sigma_)
2128 GetAndSetPPChannelMask(channel_);
2129 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2130 RestorePPChannelMask;
2131 replaceImage(newImage);
2132 ThrowImageException;
2135 void Magick::Image::border(const Geometry &geometry_)
2141 borderInfo=geometry_;
2144 newImage=BorderImage(constImage(),&borderInfo,image()->compose,
2146 replaceImage(newImage);
2147 ThrowImageException;
2150 void Magick::Image::brightnessContrast(const double brightness_,
2151 const double contrast_)
2155 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2156 ThrowImageException;
2159 void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
2160 const double brightness_,const double contrast_)
2164 GetAndSetPPChannelMask(channel_);
2165 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2166 RestorePPChannelMask;
2167 ThrowImageException;
2170 void Magick::Image::cannyEdge(const double radius_,const double sigma_,
2171 const double lowerPercent_,const double upperPercent_)
2178 newImage=CannyEdgeImage(constImage(),radius_,sigma_,lowerPercent_,
2179 upperPercent_,exceptionInfo);
2180 replaceImage(newImage);
2181 ThrowImageException;
2184 void Magick::Image::cdl(const std::string &cdl_)
2188 (void) ColorDecisionListImage(image(),cdl_.c_str(),exceptionInfo);
2189 ThrowImageException;
2192 void Magick::Image::channel(const ChannelType channel_)
2198 newImage=SeparateImage(image(),channel_,exceptionInfo);
2199 replaceImage(newImage);
2200 ThrowImageException;
2203 void Magick::Image::charcoal(const double radius_,const double sigma_)
2209 newImage=CharcoalImage(image(),radius_,sigma_,exceptionInfo);
2210 replaceImage(newImage);
2211 ThrowImageException;
2214 void Magick::Image::chop(const Geometry &geometry_)
2223 newImage=ChopImage(image(),&chopInfo,exceptionInfo);
2224 replaceImage(newImage);
2225 ThrowImageException;
2228 void Magick::Image::chromaBluePrimary(const double x_,const double y_)
2231 image()->chromaticity.blue_primary.x=x_;
2232 image()->chromaticity.blue_primary.y=y_;
2235 void Magick::Image::chromaBluePrimary(double *x_,double *y_) const
2237 *x_=constImage()->chromaticity.blue_primary.x;
2238 *y_=constImage()->chromaticity.blue_primary.y;
2241 void Magick::Image::chromaGreenPrimary(const double x_,const double y_)
2244 image()->chromaticity.green_primary.x=x_;
2245 image()->chromaticity.green_primary.y=y_;
2248 void Magick::Image::chromaGreenPrimary(double *x_,double *y_) const
2250 *x_=constImage()->chromaticity.green_primary.x;
2251 *y_=constImage()->chromaticity.green_primary.y;
2254 void Magick::Image::chromaRedPrimary(const double x_,const double y_)
2257 image()->chromaticity.red_primary.x=x_;
2258 image()->chromaticity.red_primary.y=y_;
2261 void Magick::Image::chromaRedPrimary(double *x_,double *y_) const
2263 *x_=constImage()->chromaticity.red_primary.x;
2264 *y_=constImage()->chromaticity.red_primary.y;
2267 void Magick::Image::chromaWhitePoint(const double x_,const double y_)
2270 image()->chromaticity.white_point.x=x_;
2271 image()->chromaticity.white_point.y=y_;
2274 void Magick::Image::chromaWhitePoint(double *x_,double *y_) const
2276 *x_=constImage()->chromaticity.white_point.x;
2277 *y_=constImage()->chromaticity.white_point.y;
2280 void Magick::Image::clamp(void)
2284 ClampImage(image(),exceptionInfo);
2285 ThrowImageException;
2288 void Magick::Image::clampChannel(const ChannelType channel_)
2292 GetAndSetPPChannelMask(channel_);
2293 ClampImage(image(),exceptionInfo);
2294 RestorePPChannelMask;
2295 ThrowImageException;
2298 void Magick::Image::clip(void)
2302 ClipImage(image(),exceptionInfo);
2303 ThrowImageException;
2306 void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
2310 ClipImagePath(image(),pathname_.c_str(),(MagickBooleanType) inside_,
2312 ThrowImageException;
2315 void Magick::Image::clut(const Image &clutImage_,
2316 const PixelInterpolateMethod method)
2320 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2321 ThrowImageException;
2324 void Magick::Image::clutChannel(const ChannelType channel_,
2325 const Image &clutImage_,const PixelInterpolateMethod method)
2329 GetAndSetPPChannelMask(channel_);
2330 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2331 RestorePPChannelMask;
2332 ThrowImageException;
2335 void Magick::Image::colorize(const unsigned int alpha_,const Color &penColor_)
2337 colorize(alpha_,alpha_,alpha_,penColor_);
2340 void Magick::Image::colorize(const unsigned int alphaRed_,
2341 const unsigned int alphaGreen_,const unsigned int alphaBlue_,
2342 const Color &penColor_)
2345 blend[MagickPathExtent];
2353 if (!penColor_.isValid())
2354 throwExceptionExplicit(MagickCore::OptionError,
2355 "Pen color argument is invalid");
2357 FormatLocaleString(blend,MagickPathExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
2360 target=static_cast<PixelInfo>(penColor_);
2362 newImage=ColorizeImage(image(),blend,&target,exceptionInfo);
2363 replaceImage(newImage);
2364 ThrowImageException;
2367 void Magick::Image::colorMap(const size_t index_,const Color &color_)
2374 if (index_ > (MaxColormapSize-1))
2375 throwExceptionExplicit(MagickCore::OptionError,
2376 "Colormap index must be less than MaxColormapSize");
2378 if (!color_.isValid())
2379 throwExceptionExplicit(MagickCore::OptionError,
2380 "Color argument is invalid");
2384 // Ensure that colormap size is large enough
2385 if (colorMapSize() < (index_+1))
2386 colorMapSize(index_+1);
2388 // Set color at index in colormap
2389 (imageptr->colormap)[index_]=color_;
2392 Magick::Color Magick::Image::colorMap(const size_t index_) const
2394 if (!constImage()->colormap)
2396 throwExceptionExplicit(MagickCore::OptionError,
2397 "Image does not contain a colormap");
2401 if (index_ > constImage()->colors-1)
2402 throwExceptionExplicit(MagickCore::OptionError,"Index out of range");
2404 return(Magick::Color((constImage()->colormap)[index_]));
2407 void Magick::Image::colorMatrix(const size_t order_,
2408 const double *color_matrix_)
2414 kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2415 if (kernel_info != (KernelInfo *) NULL)
2417 kernel_info->width=order_;
2418 kernel_info->height=order_;
2419 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2420 order_*sizeof(*kernel_info->values));
2421 if (kernel_info->values != (MagickRealType *) NULL)
2426 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2427 kernel_info->values[i]=color_matrix_[i];
2428 newImage=ColorMatrixImage(image(),kernel_info,exceptionInfo);
2429 replaceImage(newImage);
2431 kernel_info=DestroyKernelInfo(kernel_info);
2433 ThrowImageException;
2436 bool Magick::Image::compare(const Image &reference_)
2446 status=static_cast<bool>(IsImagesEqual(image(),ref.constImage(),
2448 ThrowImageException;
2452 double Magick::Image::compare(const Image &reference_,const MetricType metric_)
2458 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2460 ThrowImageException;
2464 double Magick::Image::compareChannel(const ChannelType channel_,
2465 const Image &reference_,const MetricType metric_)
2471 GetAndSetPPChannelMask(channel_);
2472 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2474 RestorePPChannelMask;
2475 ThrowImageException;
2479 Magick::Image Magick::Image::compare(const Image &reference_,
2480 const MetricType metric_,double *distortion)
2486 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2488 ThrowImageException;
2489 if (newImage == (MagickCore::Image *) NULL)
2490 return(Magick::Image());
2492 return(Magick::Image(newImage));
2495 Magick::Image Magick::Image::compareChannel(const ChannelType channel_,
2496 const Image &reference_,const MetricType metric_,double *distortion)
2502 GetAndSetPPChannelMask(channel_);
2503 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2505 RestorePPChannelMask;
2506 ThrowImageException;
2507 if (newImage == (MagickCore::Image *) NULL)
2508 return(Magick::Image());
2510 return(Magick::Image(newImage));
2513 void Magick::Image::composite(const Image &compositeImage_,
2514 const Geometry &offset_,const CompositeOperator compose_)
2524 ParseMetaGeometry(static_cast<std::string>(offset_).c_str(),&x,&y,&width,
2529 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2531 ThrowImageException;
2534 void Magick::Image::composite(const Image &compositeImage_,
2535 const GravityType gravity_,const CompositeOperator compose_)
2541 SetGeometry(compositeImage_.constImage(),&geometry);
2542 GravityAdjustGeometry(columns(),rows(),gravity_,&geometry);
2545 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2546 geometry.x,geometry.y,exceptionInfo);
2547 ThrowImageException;
2550 void Magick::Image::composite(const Image &compositeImage_,
2551 const ssize_t xOffset_,const ssize_t yOffset_,
2552 const CompositeOperator compose_)
2554 // Image supplied as compositeImage is composited with current image and
2555 // results in updating current image.
2558 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2559 xOffset_,yOffset_,exceptionInfo);
2560 ThrowImageException;
2563 void Magick::Image::connectedComponents(const size_t connectivity_)
2569 newImage=ConnectedComponentsImage(constImage(),connectivity_,exceptionInfo);
2570 replaceImage(newImage);
2571 ThrowImageException;
2574 void Magick::Image::contrast(const bool sharpen_)
2578 ContrastImage(image(),(MagickBooleanType) sharpen_,exceptionInfo);
2579 ThrowImageException;
2582 void Magick::Image::contrastStretch(const double blackPoint_,
2583 const double whitePoint_)
2587 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2588 ThrowImageException;
2591 void Magick::Image::contrastStretchChannel(const ChannelType channel_,
2592 const double blackPoint_,const double whitePoint_)
2596 GetAndSetPPChannelMask(channel_);
2597 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2598 RestorePPChannelMask;
2599 ThrowImageException;
2602 void Magick::Image::convolve(const size_t order_,const double *kernel_)
2608 kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2609 kernel_info->width=order_;
2610 kernel_info->height=order_;
2611 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2612 order_*sizeof(*kernel_info->values));
2613 if (kernel_info->values != (MagickRealType *) NULL)
2618 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2619 kernel_info->values[i]=kernel_[i];
2620 newImage=ConvolveImage(image(),kernel_info,exceptionInfo);
2621 replaceImage(newImage);
2623 kernel_info=DestroyKernelInfo(kernel_info);
2624 ThrowImageException;
2627 void Magick::Image::copyPixels(const Image &source_,const Geometry &geometry_,
2628 const Offset &offset_)
2637 (void) CopyImagePixels(image(),source_.constImage(),&geometry,&offset,
2639 ThrowImageException;
2642 void Magick::Image::crop(const Geometry &geometry_)
2651 newImage=CropImage(constImage(),&cropInfo,exceptionInfo);
2652 replaceImage(newImage);
2653 ThrowImageException;
2656 void Magick::Image::cycleColormap(const ssize_t amount_)
2660 CycleColormapImage(image(),amount_,exceptionInfo);
2661 ThrowImageException;
2664 void Magick::Image::decipher(const std::string &passphrase_)
2668 DecipherImage(image(),passphrase_.c_str(),exceptionInfo);
2669 ThrowImageException;
2672 void Magick::Image::defineSet(const std::string &magick_,
2673 const std::string &key_,bool flag_)
2679 definition=magick_ + ":" + key_;
2681 (void) SetImageOption(imageInfo(),definition.c_str(),"");
2683 DeleteImageOption(imageInfo(),definition.c_str());
2686 bool Magick::Image::defineSet(const std::string &magick_,
2687 const std::string &key_ ) const
2695 key=magick_ + ":" + key_;
2696 option=GetImageOption(constImageInfo(),key.c_str());
2702 void Magick::Image::defineValue(const std::string &magick_,
2703 const std::string &key_,const std::string &value_)
2710 format=magick_ + ":" + key_;
2712 (void) SetImageOption(imageInfo(),format.c_str(),option.c_str());
2715 std::string Magick::Image::defineValue(const std::string &magick_,
2716 const std::string &key_) const
2724 definition=magick_ + ":" + key_;
2725 option=GetImageOption(constImageInfo(),definition.c_str());
2727 return(std::string(option));
2728 return(std::string());
2731 void Magick::Image::deskew(const double threshold_)
2737 newImage=DeskewImage(constImage(),threshold_,exceptionInfo);
2738 replaceImage(newImage);
2739 ThrowImageException;
2742 void Magick::Image::despeckle(void)
2748 newImage=DespeckleImage(constImage(),exceptionInfo);
2749 replaceImage(newImage);
2750 ThrowImageException;
2753 void Magick::Image::display(void)
2756 DisplayImages(imageInfo(),image(),exceptionInfo);
2757 ThrowImageException;
2760 void Magick::Image::distort(const DistortImageMethod method_,
2761 const size_t numberArguments_,const double *arguments_,const bool bestfit_)
2767 newImage=DistortImage(constImage(), method_,numberArguments_,arguments_,
2768 bestfit_ == true ? MagickTrue : MagickFalse,exceptionInfo);
2769 replaceImage(newImage);
2770 ThrowImageException;
2773 void Magick::Image::draw(const Magick::Drawable &drawable_)
2780 wand=DrawAllocateWand(options()->drawInfo(),image());
2784 drawable_.operator()(wand);
2788 ClonePPDrawException(wand);
2789 wand=DestroyDrawingWand(wand);
2790 ThrowPPDrawException(quiet());
2794 void Magick::Image::draw(const std::vector<Magick::Drawable> &drawable_)
2801 wand=DrawAllocateWand(options()->drawInfo(),image());
2805 for (std::vector<Magick::Drawable>::const_iterator p = drawable_.begin();
2806 p != drawable_.end(); p++ )
2808 p->operator()(wand);
2809 if (DrawGetExceptionType(wand) != MagickCore::UndefinedException)
2813 if (DrawGetExceptionType(wand) == MagickCore::UndefinedException)
2816 ClonePPDrawException(wand);
2817 wand=DestroyDrawingWand(wand);
2818 ThrowPPDrawException(quiet());
2822 void Magick::Image::edge(const double radius_)
2828 newImage=EdgeImage(constImage(),radius_,exceptionInfo);
2829 replaceImage(newImage);
2830 ThrowImageException;
2833 void Magick::Image::emboss(const double radius_,const double sigma_)
2839 newImage=EmbossImage(constImage(),radius_,sigma_,exceptionInfo);
2840 replaceImage(newImage);
2841 ThrowImageException;
2844 void Magick::Image::encipher(const std::string &passphrase_)
2848 EncipherImage(image(),passphrase_.c_str(),exceptionInfo);
2849 ThrowImageException;
2852 void Magick::Image::enhance(void)
2858 newImage=EnhanceImage(constImage(),exceptionInfo);
2859 replaceImage(newImage);
2860 ThrowImageException;
2863 void Magick::Image::equalize(void)
2867 EqualizeImage(image(),exceptionInfo);
2868 ThrowImageException;
2871 void Magick::Image::erase(void)
2875 (void) SetImageBackgroundColor(image(),exceptionInfo);
2876 ThrowImageException;
2879 void Magick::Image::evaluate(const ChannelType channel_,
2880 const MagickEvaluateOperator operator_,double rvalue_)
2883 GetAndSetPPChannelMask(channel_);
2884 EvaluateImage(image(),operator_,rvalue_,exceptionInfo);
2885 RestorePPChannelMask;
2886 ThrowImageException;
2889 void Magick::Image::evaluate(const ChannelType channel_,
2890 const MagickFunction function_,const size_t number_parameters_,
2891 const double *parameters_)
2894 GetAndSetPPChannelMask(channel_);
2895 FunctionImage(image(),function_,number_parameters_,parameters_,
2897 RestorePPChannelMask;
2898 ThrowImageException;
2901 void Magick::Image::evaluate(const ChannelType channel_,const ssize_t x_,
2902 const ssize_t y_,const size_t columns_,const size_t rows_,
2903 const MagickEvaluateOperator operator_,const double rvalue_)
2911 geometry.width = columns_;
2912 geometry.height = rows_;
2917 cropImage=CropImage(image(),&geometry,exceptionInfo);
2918 GetAndSetPPChannelMask(channel_);
2919 EvaluateImage(cropImage,operator_,rvalue_,exceptionInfo);
2920 RestorePPChannelMask;
2921 (void) CompositeImage(image(),cropImage,image()->alpha_trait ==
2922 BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
2923 geometry.x,geometry.y,exceptionInfo );
2924 cropImage=DestroyImageList(cropImage);
2925 ThrowImageException;
2928 void Magick::Image::extent(const Geometry &geometry_ )
2934 extentInfo=geometry_;
2937 extentInfo.x=geometry_.xOff();
2938 extentInfo.y=geometry_.yOff();
2940 newImage=ExtentImage(image(),&extentInfo,exceptionInfo);
2941 replaceImage(newImage);
2942 ThrowImageException;
2945 void Magick::Image::extent(const Geometry &geometry_,
2946 const Color &backgroundColor_)
2948 backgroundColor(backgroundColor_);
2952 void Magick::Image::extent(const Geometry &geometry_,
2953 const Color &backgroundColor_,const GravityType gravity_)
2955 backgroundColor(backgroundColor_);
2956 extent(geometry_,gravity_);
2959 void Magick::Image::extent(const Geometry &geometry_,
2960 const GravityType gravity_)
2965 SetGeometry(image(),&geometry);
2966 geometry.width=geometry_.width();
2967 geometry.height=geometry_.height();
2968 GravityAdjustGeometry(image()->columns,image()->rows,gravity_,&geometry);
2972 void Magick::Image::flip(void)
2978 newImage=FlipImage(constImage(),exceptionInfo);
2979 replaceImage(newImage);
2980 ThrowImageException;
2983 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2984 const unsigned int alpha_,const bool invert_)
2991 target=static_cast<PixelInfo>(pixelColor(x_,y_));
2992 target.alpha=alpha_;
2994 GetAndSetPPChannelMask(AlphaChannel);
2995 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2996 (MagickBooleanType)invert_,exceptionInfo);
2997 RestorePPChannelMask;
2998 ThrowImageException;
3001 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
3002 const unsigned int alpha_,const Color &target_,const bool invert_)
3009 target=static_cast<PixelInfo>(target_);
3010 target.alpha=alpha_;
3012 GetAndSetPPChannelMask(AlphaChannel);
3013 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
3014 (MagickBooleanType)invert_,exceptionInfo);
3015 RestorePPChannelMask;
3016 ThrowImageException;
3019 void Magick::Image::floodFillColor(const Geometry &point_,
3020 const Magick::Color &fillColor_,const bool invert_)
3022 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,invert_);
3025 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
3026 const Magick::Color &fillColor_,const bool invert_)
3033 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
3034 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
3037 void Magick::Image::floodFillColor(const Geometry &point_,
3038 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
3041 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,borderColor_,invert_);
3044 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
3045 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
3053 pixel=static_cast<PixelInfo>(borderColor_);
3054 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
3057 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
3058 const Magick::Image &texture_,const bool invert_)
3060 floodFillTexture(point_.xOff(),point_.yOff(),texture_,invert_);
3063 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
3064 const Magick::Image &texture_,const bool invert_)
3071 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
3072 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
3075 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
3076 const Magick::Image &texture_,const Magick::Color &borderColor_,
3079 floodFillTexture(point_.xOff(),point_.yOff(),texture_,borderColor_,invert_);
3082 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
3083 const Magick::Image &texture_,const Magick::Color &borderColor_,
3091 pixel=static_cast<PixelInfo>(borderColor_);
3092 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
3095 void Magick::Image::flop(void)
3101 newImage=FlopImage(constImage(),exceptionInfo);
3102 replaceImage(newImage);
3103 ThrowImageException;
3106 void Magick::Image::fontTypeMetrics(const std::string &text_,
3107 TypeMetric *metrics)
3112 drawInfo=options()->drawInfo();
3113 drawInfo->text=const_cast<char *>(text_.c_str());
3115 GetTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3117 ThrowImageException;
3120 void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
3121 TypeMetric *metrics)
3126 drawInfo=options()->drawInfo();
3127 drawInfo->text=const_cast<char *>(text_.c_str());
3129 GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3131 ThrowImageException;
3134 void Magick::Image::frame(const Geometry &geometry_)
3142 info.x=static_cast<ssize_t>(geometry_.width());
3143 info.y=static_cast<ssize_t>(geometry_.height());
3144 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3145 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3146 info.outer_bevel=geometry_.xOff();
3147 info.inner_bevel=geometry_.yOff();
3150 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3151 replaceImage(newImage);
3152 ThrowImageException;
3155 void Magick::Image::frame(const size_t width_,const size_t height_,
3156 const ssize_t innerBevel_,const ssize_t outerBevel_)
3164 info.x=static_cast<ssize_t>(width_);
3165 info.y=static_cast<ssize_t>(height_);
3166 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3167 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3168 info.outer_bevel=static_cast<ssize_t>(outerBevel_);
3169 info.inner_bevel=static_cast<ssize_t>(innerBevel_);
3172 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3173 replaceImage(newImage);
3174 ThrowImageException;
3177 void Magick::Image::fx(const std::string expression_)
3183 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3184 replaceImage(newImage);
3185 ThrowImageException;
3188 void Magick::Image::fx(const std::string expression_,
3189 const Magick::ChannelType channel_)
3195 GetAndSetPPChannelMask(channel_);
3196 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3197 RestorePPChannelMask;
3198 replaceImage(newImage);
3199 ThrowImageException;
3202 void Magick::Image::gamma(const double gamma_)
3206 GammaImage(image(),gamma_,exceptionInfo);
3207 ThrowImageException;
3210 void Magick::Image::gamma(const double gammaRed_,const double gammaGreen_,
3211 const double gammaBlue_)
3215 GetAndSetPPChannelMask(RedChannel);
3216 (void) GammaImage(image(),gammaRed_,exceptionInfo);
3217 SetPPChannelMask(GreenChannel);
3218 (void) GammaImage(image(),gammaGreen_,exceptionInfo);
3219 SetPPChannelMask(BlueChannel);
3220 (void) GammaImage(image(),gammaBlue_,exceptionInfo);
3221 RestorePPChannelMask;
3222 ThrowImageException;
3225 void Magick::Image::gaussianBlur(const double width_,const double sigma_)
3231 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3232 replaceImage(newImage);
3233 ThrowImageException;
3236 void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
3237 const double width_,const double sigma_)
3243 GetAndSetPPChannelMask(channel_);
3244 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3245 RestorePPChannelMask;
3246 replaceImage(newImage);
3247 ThrowImageException;
3250 const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
3251 const ssize_t y_,const size_t columns_,const size_t rows_) const
3257 p=GetVirtualPixels(constImage(),x_, y_,columns_, rows_,exceptionInfo);
3258 ThrowImageException;
3262 const void *Magick::Image::getConstMetacontent(void) const
3267 result=GetVirtualMetacontent(constImage());
3270 throwExceptionExplicit(MagickCore::OptionError,
3271 "Unable to retrieve meta content.");
3276 void *Magick::Image::getMetacontent(void )
3281 result=GetAuthenticMetacontent(image());
3284 throwExceptionExplicit(MagickCore::OptionError,
3285 "Unable to retrieve meta content.");
3290 Magick::Quantum *Magick::Image::getPixels(const ssize_t x_,const ssize_t y_,
3291 const size_t columns_,const size_t rows_)
3298 result=GetAuthenticPixels(image(),x_, y_,columns_,rows_,exceptionInfo);
3299 ThrowImageException;
3304 void Magick::Image::grayscale(const PixelIntensityMethod method_)
3308 (void) GrayscaleImage(image(),method_,exceptionInfo);
3309 ThrowImageException;
3312 void Magick::Image::haldClut(const Image &clutImage_)
3316 (void) HaldClutImage(image(),clutImage_.constImage(),exceptionInfo);
3317 ThrowImageException;
3320 void Magick::Image::houghLine(const size_t width_,const size_t height_,
3321 const size_t threshold_)
3327 newImage=HoughLineImage(constImage(),width_,height_,threshold_,
3329 replaceImage(newImage);
3330 ThrowImageException;
3333 Magick::ImageType Magick::Image::identifyType(void) const
3339 image_type=IdentifyImageType(constImage(),exceptionInfo);
3340 ThrowImageException;
3344 void Magick::Image::implode(const double factor_)
3350 newImage=ImplodeImage(constImage(),factor_,image()->interpolate,
3352 replaceImage(newImage);
3353 ThrowImageException;
3356 void Magick::Image::inverseFourierTransform(const Image &phase_)
3358 inverseFourierTransform(phase_,true);
3361 void Magick::Image::inverseFourierTransform(const Image &phase_,
3362 const bool magnitude_)
3368 newImage=InverseFourierTransformImage(constImage(),phase_.constImage(),
3369 magnitude_ == true ? MagickTrue : MagickFalse,exceptionInfo);
3370 replaceImage(newImage);
3371 ThrowImageException;
3374 void Magick::Image::kuwahara(const double radius_,const double sigma_)
3380 newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3381 replaceImage(newImage);
3382 ThrowImageException;
3385 void Magick::Image::kuwaharaChannel(const ChannelType channel_,
3386 const double radius_,const double sigma_)
3392 GetAndSetPPChannelMask(channel_);
3393 newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3394 replaceImage(newImage);
3395 RestorePPChannelMask;
3396 ThrowImageException;
3399 void Magick::Image::level(const double blackPoint_,const double whitePoint_,
3400 const double gamma_)
3404 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3405 ThrowImageException;
3408 void Magick::Image::levelChannel(const ChannelType channel_,
3409 const double blackPoint_,const double whitePoint_,const double gamma_)
3413 GetAndSetPPChannelMask(channel_);
3414 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3415 RestorePPChannelMask;
3416 ThrowImageException;
3419 void Magick::Image::levelColors(const Color &blackColor_,
3420 const Color &whiteColor_,const bool invert_)
3428 black=static_cast<PixelInfo>(blackColor_);
3429 white=static_cast<PixelInfo>(whiteColor_);
3431 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3432 MagickTrue : MagickFalse,exceptionInfo);
3433 ThrowImageException;
3436 void Magick::Image::levelColorsChannel(const ChannelType channel_,
3437 const Color &blackColor_,const Color &whiteColor_,const bool invert_)
3445 black=static_cast<PixelInfo>(blackColor_);
3446 white=static_cast<PixelInfo>(whiteColor_);
3448 GetAndSetPPChannelMask(channel_);
3449 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3450 MagickTrue : MagickFalse,exceptionInfo);
3451 RestorePPChannelMask;
3452 ThrowImageException;
3455 void Magick::Image::linearStretch(const double blackPoint_,
3456 const double whitePoint_)
3460 LinearStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
3461 ThrowImageException;
3464 void Magick::Image::liquidRescale(const Geometry &geometry_)
3477 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3481 newImage=LiquidRescaleImage(image(),width,height,x,y,exceptionInfo);
3482 replaceImage(newImage);
3483 ThrowImageException;
3486 void Magick::Image::magnify(void)
3492 newImage=MagnifyImage(constImage(),exceptionInfo);
3493 replaceImage(newImage);
3494 ThrowImageException;
3497 void Magick::Image::map(const Image &mapImage_,const bool dither_)
3501 options()->quantizeDither(dither_);
3502 RemapImage(options()->quantizeInfo(),image(),mapImage_.constImage(),
3504 ThrowImageException;
3507 void Magick::Image::medianFilter(const double radius_)
3513 newImage=StatisticImage(image(),MedianStatistic,(size_t) radius_,
3514 (size_t) radius_,exceptionInfo);
3515 replaceImage(newImage);
3516 ThrowImageException;
3519 void Magick::Image::minify(void)
3525 newImage=MinifyImage(constImage(),exceptionInfo);
3526 replaceImage(newImage);
3527 ThrowImageException;
3530 void Magick::Image::modulate(const double brightness_,const double saturation_,
3534 modulate[MagickPathExtent + 1];
3536 FormatLocaleString(modulate,MagickPathExtent,"%3.6f,%3.6f,%3.6f",brightness_,
3541 ModulateImage(image(),modulate,exceptionInfo);
3542 ThrowImageException;
3545 Magick::ImageMoments Magick::Image::moments(void) const
3547 return(ImageMoments(*this));
3550 void Magick::Image::morphology(const MorphologyMethod method_,
3551 const std::string kernel_,const ssize_t iterations_)
3560 kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3561 if (kernel == (KernelInfo *) NULL)
3562 throwExceptionExplicit(MagickCore::OptionError,"Unable to parse kernel.");
3563 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3565 replaceImage(newImage);
3566 kernel=DestroyKernelInfo(kernel);
3567 ThrowImageException;
3570 void Magick::Image::morphology(const MorphologyMethod method_,
3571 const KernelInfoType kernel_,const std::string arguments_,
3572 const ssize_t iterations_)
3580 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3581 if (option == (const char *)NULL)
3583 throwExceptionExplicit(MagickCore::OptionError,
3584 "Unable to determine kernel type.");
3587 kernel=std::string(option);
3588 if (!arguments_.empty())
3589 kernel+=":"+arguments_;
3591 morphology(method_,kernel,iterations_);
3594 void Magick::Image::morphologyChannel(const ChannelType channel_,
3595 const MorphologyMethod method_,const std::string kernel_,
3596 const ssize_t iterations_)
3606 kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3607 if (kernel == (KernelInfo *)NULL)
3609 throwExceptionExplicit(MagickCore::OptionError,
3610 "Unable to parse kernel.");
3613 GetAndSetPPChannelMask(channel_);
3614 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3616 RestorePPChannelMask;
3617 replaceImage(newImage);
3618 kernel=DestroyKernelInfo(kernel);
3619 ThrowImageException;
3622 void Magick::Image::morphologyChannel(const ChannelType channel_,
3623 const MorphologyMethod method_,const KernelInfoType kernel_,
3624 const std::string arguments_,const ssize_t iterations_)
3632 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3633 if (option == (const char *)NULL)
3635 throwExceptionExplicit(MagickCore::OptionError,
3636 "Unable to determine kernel type.");
3640 kernel=std::string(option);
3641 if (!arguments_.empty())
3642 kernel+=":"+arguments_;
3644 morphologyChannel(channel_,method_,kernel,iterations_);
3647 void Magick::Image::motionBlur(const double radius_,const double sigma_,
3648 const double angle_)
3654 newImage=MotionBlurImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
3655 replaceImage(newImage);
3656 ThrowImageException;
3659 void Magick::Image::negate(const bool grayscale_)
3663 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3664 ThrowImageException;
3667 void Magick::Image::negateChannel(const ChannelType channel_,
3668 const bool grayscale_)
3672 GetAndSetPPChannelMask(channel_);
3673 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3674 RestorePPChannelMask;
3675 ThrowImageException;
3678 void Magick::Image::normalize(void)
3682 NormalizeImage(image(),exceptionInfo);
3683 ThrowImageException;
3686 void Magick::Image::oilPaint(const double radius_,const double sigma_)
3692 newImage=OilPaintImage(constImage(),radius_,sigma_,exceptionInfo);
3693 replaceImage(newImage);
3694 ThrowImageException;
3697 void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_,
3708 if (!opaqueColor_.isValid())
3709 throwExceptionExplicit(MagickCore::OptionError,
3710 "Opaque color argument is invalid");
3712 if (!penColor_.isValid())
3713 throwExceptionExplicit(MagickCore::OptionError,
3714 "Pen color argument is invalid");
3717 opaqueColor=opaqueColor_;
3721 (void) QueryColorCompliance(opaqueColor.c_str(),AllCompliance,&opaque,
3723 (void) QueryColorCompliance(penColor.c_str(),AllCompliance,&pen,
3725 OpaquePaintImage(image(),&opaque,&pen,invert_ ? MagickTrue : MagickFalse,
3727 ThrowImageException;
3730 void Magick::Image::orderedDither(std::string thresholdMap_)
3734 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3735 ThrowImageException;
3738 void Magick::Image::orderedDitherChannel(const ChannelType channel_,
3739 std::string thresholdMap_)
3743 GetAndSetPPChannelMask(channel_);
3744 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3745 RestorePPChannelMask;
3746 ThrowImageException;
3749 void Magick::Image::perceptible(const double epsilon_)
3753 PerceptibleImage(image(),epsilon_,exceptionInfo);
3754 ThrowImageException;
3757 void Magick::Image::perceptibleChannel(const ChannelType channel_,
3758 const double epsilon_)
3762 GetAndSetPPChannelMask(channel_);
3763 PerceptibleImage(image(),epsilon_,exceptionInfo);
3764 RestorePPChannelMask;
3765 ThrowImageException;
3768 Magick::ImagePerceptualHash Magick::Image::perceptualHash() const
3770 return(ImagePerceptualHash(*this));
3773 void Magick::Image::ping(const std::string &imageSpec_)
3779 options()->fileName(imageSpec_);
3780 newImage=PingImage(imageInfo(),exceptionInfo);
3781 read(newImage,exceptionInfo);
3784 void Magick::Image::ping(const Blob& blob_)
3790 newImage=PingBlob(imageInfo(),blob_.data(),blob_.length(),exceptionInfo);
3791 read(newImage,exceptionInfo);
3794 void Magick::Image::pixelColor(const ssize_t x_,const ssize_t y_,
3795 const Color &color_)
3803 // Test arguments to ensure they are within the image.
3804 if (y_ > (ssize_t) rows() || x_ > (ssize_t) columns())
3805 throwExceptionExplicit(MagickCore::OptionError,
3806 "Access outside of image boundary");
3810 // Set image to DirectClass
3811 classType(DirectClass );
3814 Pixels pixels(*this);
3816 pixel=pixels.get(x_, y_, 1, 1 );
3818 MagickCore::SetPixelViaPixelInfo(constImage(),&packet,pixel);
3819 // Tell ImageMagick that pixels have been updated
3823 Magick::Color Magick::Image::pixelColor(const ssize_t x_,
3824 const ssize_t y_) const
3829 pixel=getConstPixels(x_,y_,1,1);
3835 MagickCore::GetPixelInfoPixel(constImage(),pixel,&packet);
3836 return(Color(packet));
3839 return(Color()); // invalid
3842 void Magick::Image::polaroid(const std::string &caption_,const double angle_,
3843 const PixelInterpolateMethod method_)
3849 newImage=PolaroidImage(constImage(),options()->drawInfo(),caption_.c_str(),
3850 angle_,method_,exceptionInfo);
3851 replaceImage(newImage);
3852 ThrowImageException;
3855 void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
3859 PosterizeImage(image(),levels_,method_,exceptionInfo);
3860 ThrowImageException;
3863 void Magick::Image::posterizeChannel(const ChannelType channel_,
3864 const size_t levels_,const DitherMethod method_)
3868 GetAndSetPPChannelMask(channel_);
3869 PosterizeImage(image(),levels_,method_,exceptionInfo);
3870 RestorePPChannelMask;
3871 ThrowImageException;
3874 void Magick::Image::process(std::string name_,const ssize_t argc,
3880 (void) InvokeDynamicImageFilter(name_.c_str(),&image(),argc,argv,
3882 ThrowImageException;
3885 void Magick::Image::profile(const std::string name_,
3886 const Magick::Blob &profile_)
3890 (void) ProfileImage(image(),name_.c_str(),(unsigned char *)profile_.data(),
3891 profile_.length(),exceptionInfo);
3892 ThrowImageException;
3895 Magick::Blob Magick::Image::profile(const std::string name_) const
3900 profile=GetImageProfile(constImage(),name_.c_str());
3902 if (profile == (StringInfo *) NULL)
3904 return(Blob((void*) GetStringInfoDatum(profile),GetStringInfoLength(
3908 void Magick::Image::quantize(const bool measureError_)
3913 options()->quantizeInfo()->measure_error=MagickTrue;
3915 options()->quantizeInfo()->measure_error=MagickFalse;
3918 QuantizeImage(options()->quantizeInfo(),image(),exceptionInfo);
3919 ThrowImageException;
3922 void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
3925 raiseInfo=geometry_;
3929 RaiseImage(image(),&raiseInfo,raisedFlag_ == true ? MagickTrue : MagickFalse,
3931 ThrowImageException;
3934 void Magick::Image::randomThreshold(const Geometry &thresholds_)
3937 (void) RandomThresholdImage(image(),static_cast<std::string>(
3938 thresholds_).c_str(),exceptionInfo);
3939 ThrowImageException;
3942 void Magick::Image::randomThresholdChannel(const ChannelType channel_,
3943 const Geometry &thresholds_)
3947 GetAndSetPPChannelMask(channel_);
3948 (void) RandomThresholdImage(image(),static_cast<std::string>(
3949 thresholds_).c_str(),exceptionInfo);
3950 RestorePPChannelMask;
3951 ThrowImageException;
3954 void Magick::Image::read(const Blob &blob_)
3960 newImage=BlobToImage(imageInfo(),static_cast<const void *>(blob_.data()),
3961 blob_.length(),exceptionInfo);
3962 read(newImage,exceptionInfo);
3965 void Magick::Image::read(const Blob &blob_,const Geometry &size_)
3971 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3972 const size_t depth_)
3979 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3980 const size_t depth_,const std::string &magick_)
3985 // Set explicit image format
3986 fileName(magick_ + ':');
3990 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3991 const std::string &magick_)
3995 // Set explicit image format
3996 fileName(magick_ + ':');
4000 void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_)
4006 void Magick::Image::read(const size_t width_,const size_t height_,
4007 const std::string &map_,const StorageType type_,const void *pixels_)
4013 newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
4015 replaceImage(newImage);
4016 ThrowImageException;
4019 void Magick::Image::read(const std::string &imageSpec_)
4025 options()->fileName(imageSpec_);
4026 newImage=ReadImage(imageInfo(),exceptionInfo);
4027 read(newImage,exceptionInfo);
4030 void Magick::Image::readPixels(const Magick::QuantumType quantum_,
4031 const unsigned char *source_)
4036 quantum_info=AcquireQuantumInfo(imageInfo(),image());
4038 ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4039 quantum_,source_,exceptionInfo);
4040 quantum_info=DestroyQuantumInfo(quantum_info);
4041 ThrowImageException;
4044 void Magick::Image::reduceNoise(void)
4049 void Magick::Image::reduceNoise(const size_t order_)
4055 newImage=StatisticImage(constImage(),NonpeakStatistic,order_,
4056 order_,exceptionInfo);
4057 replaceImage(newImage);
4058 ThrowImageException;
4061 void Magick::Image::repage()
4064 options()->page(Geometry());
4065 image()->page.width = 0;
4066 image()->page.height = 0;
4067 image()->page.x = 0;
4068 image()->page.y = 0;
4071 void Magick::Image::resample(const Point &density_)
4077 newImage=ResampleImage(constImage(),density_.x(),density_.y(),
4078 image()->filter,exceptionInfo);
4079 replaceImage(newImage);
4080 ThrowImageException;
4083 void Magick::Image::resize(const Geometry &geometry_)
4096 // Calculate new size. This code should be supported using binary arguments
4097 // in the ImageMagick library.
4098 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4102 newImage=ResizeImage(constImage(),width,height,image()->filter,
4104 replaceImage(newImage);
4105 ThrowImageException;
4108 void Magick::Image::roll(const Geometry &roll_)
4114 newImage=RollImage(constImage(),roll_.xOff(),roll_.yOff(),exceptionInfo);
4115 replaceImage(newImage);
4116 ThrowImageException;
4119 void Magick::Image::roll(const size_t columns_,const size_t rows_)
4125 newImage=RollImage(constImage(),static_cast<ssize_t>(columns_),
4126 static_cast<ssize_t>(rows_),exceptionInfo);
4127 replaceImage(newImage);
4128 ThrowImageException;
4131 void Magick::Image::rotate(const double degrees_)
4137 newImage=RotateImage(constImage(),degrees_,exceptionInfo);
4138 replaceImage(newImage);
4139 ThrowImageException;
4142 void Magick::Image::rotationalBlur(const double angle_)
4148 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4149 replaceImage(newImage);
4150 ThrowImageException;
4153 void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
4154 const double angle_)
4160 GetAndSetPPChannelMask(channel_);
4161 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4162 RestorePPChannelMask;
4163 replaceImage(newImage);
4164 ThrowImageException;
4167 void Magick::Image::sample(const Geometry &geometry_)
4180 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4184 newImage=SampleImage(constImage(),width,height,exceptionInfo);
4185 replaceImage(newImage);
4186 ThrowImageException;
4189 void Magick::Image::scale(const Geometry &geometry_)
4202 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4206 newImage=ScaleImage(constImage(),width,height,exceptionInfo);
4207 replaceImage(newImage);
4208 ThrowImageException;
4211 void Magick::Image::segment(const double clusterThreshold_,
4212 const double smoothingThreshold_)
4216 SegmentImage(image(),options()->quantizeColorSpace(),
4217 (MagickBooleanType) options()->verbose(),clusterThreshold_,
4218 smoothingThreshold_,exceptionInfo);
4219 SyncImage(image(),exceptionInfo);
4220 ThrowImageException;
4223 void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
4224 const double threshold_)
4230 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4232 replaceImage(newImage);
4233 ThrowImageException;
4236 void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
4237 const double radius_,const double sigma_,const double threshold_)
4243 GetAndSetPPChannelMask(channel_);
4244 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4246 RestorePPChannelMask;
4247 replaceImage(newImage);
4248 ThrowImageException;
4251 Magick::Image Magick::Image::separate(const ChannelType channel_) const
4257 image=SeparateImage(constImage(),channel_,exceptionInfo);
4258 ThrowImageException;
4259 if (image == (MagickCore::Image *) NULL)
4260 return(Magick::Image());
4262 return(Magick::Image(image));
4265 void Magick::Image::sepiaTone(const double threshold_)
4271 newImage=SepiaToneImage(constImage(),threshold_,exceptionInfo);
4272 replaceImage(newImage);
4273 ThrowImageException;
4276 Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
4277 const size_t columns_,const size_t rows_)
4284 result=QueueAuthenticPixels(image(),x_,y_,columns_,rows_,exceptionInfo);
4285 ThrowImageException;
4289 void Magick::Image::shade(const double azimuth_,const double elevation_,
4290 const bool colorShading_)
4296 newImage=ShadeImage(constImage(),colorShading_ == true ?
4297 MagickTrue : MagickFalse,azimuth_,elevation_,exceptionInfo);
4298 replaceImage(newImage);
4299 ThrowImageException;
4302 void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
4303 const ssize_t x_,const ssize_t y_)
4309 newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
4311 replaceImage(newImage);
4312 ThrowImageException;
4315 void Magick::Image::sharpen(const double radius_,const double sigma_)
4321 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4322 replaceImage(newImage);
4323 ThrowImageException;
4326 void Magick::Image::sharpenChannel(const ChannelType channel_,
4327 const double radius_,const double sigma_)
4333 GetAndSetPPChannelMask(channel_);
4334 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4335 RestorePPChannelMask;
4336 replaceImage(newImage);
4337 ThrowImageException;
4340 void Magick::Image::shave(const Geometry &geometry_)
4346 shaveInfo=geometry_;
4349 newImage=ShaveImage(constImage(),&shaveInfo,exceptionInfo);
4350 replaceImage(newImage);
4351 ThrowImageException;
4354 void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
4360 newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,exceptionInfo);
4361 replaceImage(newImage);
4362 ThrowImageException;
4365 void Magick::Image::sigmoidalContrast(const bool sharpen_,
4366 const double contrast,const double midpoint)
4370 (void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
4371 midpoint,exceptionInfo);
4372 ThrowImageException;
4375 std::string Magick::Image::signature(const bool force_) const
4377 return(_imgRef->signature());
4380 void Magick::Image::sketch(const double radius_,const double sigma_,
4381 const double angle_)
4387 newImage=SketchImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
4388 replaceImage(newImage);
4389 ThrowImageException;
4392 void Magick::Image::solarize(const double factor_)
4396 SolarizeImage(image(),factor_,exceptionInfo);
4397 ThrowImageException;
4400 void Magick::Image::sparseColor(const ChannelType channel_,
4401 const SparseColorMethod method_,const size_t numberArguments_,
4402 const double *arguments_)
4408 GetAndSetPPChannelMask(channel_);
4409 newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
4411 RestorePPChannelMask;
4412 replaceImage(newImage);
4413 ThrowImageException;
4416 void Magick::Image::splice(const Geometry &geometry_)
4422 spliceInfo=geometry_;
4425 newImage=SpliceImage(constImage(),&spliceInfo,exceptionInfo);
4426 replaceImage(newImage);
4427 ThrowImageException;
4430 void Magick::Image::splice(const Geometry &geometry_,
4431 const Color &backgroundColor_)
4433 backgroundColor(backgroundColor_);
4437 void Magick::Image::splice(const Geometry &geometry_,
4438 const Color &backgroundColor_,const GravityType gravity_)
4440 backgroundColor(backgroundColor_);
4441 image()->gravity=gravity_;
4445 void Magick::Image::spread(const size_t amount_)
4451 newImage=SpreadImage(constImage(),image()->interpolate,amount_,exceptionInfo);
4452 replaceImage(newImage);
4453 ThrowImageException;
4456 Magick::ImageStatistics Magick::Image::statistics() const
4458 return(ImageStatistics(*this));
4461 void Magick::Image::stegano(const Image &watermark_)
4467 newImage=SteganoImage(constImage(),watermark_.constImage(),exceptionInfo);
4468 replaceImage(newImage);
4469 ThrowImageException;
4472 void Magick::Image::stereo(const Image &rightImage_)
4478 newImage=StereoImage(constImage(),rightImage_.constImage(),exceptionInfo);
4479 replaceImage(newImage);
4480 ThrowImageException;
4483 void Magick::Image::strip(void)
4487 StripImage(image(),exceptionInfo);
4488 ThrowImageException;
4491 Magick::Image Magick::Image::subImageSearch(const Image &reference_,
4492 const MetricType metric_,Geometry *offset_,double *similarityMetric_,
4493 const double similarityThreshold)
4502 newImage=SimilarityImage(image(),reference_.constImage(),metric_,
4503 similarityThreshold,&offset,similarityMetric_,exceptionInfo);
4504 ThrowImageException;
4505 if (offset_ != (Geometry *) NULL)
4507 if (newImage == (MagickCore::Image *) NULL)
4508 return(Magick::Image());
4510 return(Magick::Image(newImage));
4513 void Magick::Image::swirl(const double degrees_)
4519 newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
4521 replaceImage(newImage);
4522 ThrowImageException;
4525 void Magick::Image::syncPixels(void)
4528 (void) SyncAuthenticPixels(image(),exceptionInfo);
4529 ThrowImageException;
4532 void Magick::Image::texture(const Image &texture_)
4536 TextureImage(image(),texture_.constImage(),exceptionInfo);
4537 ThrowImageException;
4540 void Magick::Image::threshold(const double threshold_)
4544 BilevelImage(image(),threshold_,exceptionInfo);
4545 ThrowImageException;
4548 void Magick::Image::thumbnail(const Geometry &geometry_)
4561 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4565 newImage=ThumbnailImage(constImage(),width,height,exceptionInfo);
4566 replaceImage(newImage);
4567 ThrowImageException;
4570 void Magick::Image::tint(const std::string opacity_)
4579 color=static_cast<PixelInfo>(constOptions()->fillColor());
4580 newImage=TintImage(constImage(),opacity_.c_str(),&color,exceptionInfo);
4581 replaceImage(newImage);
4582 ThrowImageException;
4585 void Magick::Image::transform(const Geometry &imageGeometry_)
4589 TransformImage(&(image()),0,std::string(imageGeometry_).c_str(),
4591 ThrowImageException;
4594 void Magick::Image::transform(const Geometry &imageGeometry_,
4595 const Geometry &cropGeometry_)
4599 TransformImage(&(image()),std::string(cropGeometry_).c_str(),std::string(
4600 imageGeometry_).c_str(), exceptionInfo);
4601 ThrowImageException;
4604 void Magick::Image::transformOrigin(const double x_,const double y_)
4607 options()->transformOrigin(x_,y_);
4610 void Magick::Image::transformReset(void)
4613 options()->transformReset();
4616 void Magick::Image::transformScale(const double sx_,const double sy_)
4619 options()->transformScale(sx_,sy_);
4622 void Magick::Image::transparent(const Color &color_)
4630 if (!color_.isValid())
4631 throwExceptionExplicit(MagickCore::OptionError,
4632 "Color argument is invalid");
4636 (void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
4639 TransparentPaintImage(image(),&target,TransparentAlpha,MagickFalse,
4641 ThrowImageException;
4644 void Magick::Image::transparentChroma(const Color &colorLow_,
4645 const Color &colorHigh_)
4655 if (!colorLow_.isValid() || !colorHigh_.isValid())
4656 throwExceptionExplicit(MagickCore::OptionError,
4657 "Color argument is invalid");
4660 colorHigh=colorHigh_;
4663 (void) QueryColorCompliance(colorLow.c_str(),AllCompliance,&targetLow,
4665 (void) QueryColorCompliance(colorHigh.c_str(),AllCompliance,&targetHigh,
4668 TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
4669 MagickFalse,exceptionInfo);
4670 ThrowImageException;
4673 void Magick::Image::transpose(void)
4679 newImage=TransposeImage(constImage(),exceptionInfo);
4680 replaceImage(newImage);
4681 ThrowImageException;
4684 void Magick::Image::transverse(void)
4690 newImage=TransverseImage(constImage(),exceptionInfo);
4691 replaceImage(newImage);
4692 ThrowImageException;
4695 void Magick::Image::trim(void)
4701 newImage=TrimImage(constImage(),exceptionInfo);
4702 replaceImage(newImage);
4703 ThrowImageException;
4706 Magick::Image Magick::Image::uniqueColors(void) const
4712 image=UniqueImageColors(constImage(),exceptionInfo);
4713 ThrowImageException;
4714 if (image == (MagickCore::Image *) NULL)
4715 return(Magick::Image());
4717 return(Magick::Image(image));
4720 void Magick::Image::unsharpmask(const double radius_,const double sigma_,
4721 const double amount_,const double threshold_)
4727 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4729 replaceImage(newImage);
4730 ThrowImageException;
4733 void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
4734 const double radius_,const double sigma_,const double amount_,
4735 const double threshold_)
4741 GetAndSetPPChannelMask(channel_);
4742 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4744 RestorePPChannelMask;
4745 replaceImage(newImage);
4746 ThrowImageException;
4749 void Magick::Image::vignette(const double radius_,const double sigma_,
4750 const ssize_t x_,const ssize_t y_)
4756 newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,exceptionInfo);
4757 replaceImage(newImage);
4758 ThrowImageException;
4761 void Magick::Image::wave(const double amplitude_,const double wavelength_)
4767 newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
4769 replaceImage(newImage);
4770 ThrowImageException;
4773 void Magick::Image::whiteThreshold(const std::string &threshold_)
4777 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4778 ThrowImageException;
4781 void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
4782 const std::string &threshold_)
4786 GetAndSetPPChannelMask(channel_);
4787 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4788 RestorePPChannelMask;
4789 ThrowImageException;
4792 void Magick::Image::write(Blob *blob_)
4802 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4804 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4805 ThrowImageException;
4808 void Magick::Image::write(Blob *blob_,const std::string &magick_)
4819 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4821 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4822 ThrowImageException;
4825 void Magick::Image::write(Blob *blob_,const std::string &magick_,
4826 const size_t depth_)
4838 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4840 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4841 ThrowImageException;
4844 void Magick::Image::write(const ssize_t x_,const ssize_t y_,
4845 const size_t columns_,const size_t rows_,const std::string &map_,
4846 const StorageType type_,void *pixels_)
4849 ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
4851 ThrowImageException;
4854 void Magick::Image::write(const std::string &imageSpec_)
4857 fileName(imageSpec_);
4859 WriteImage(constImageInfo(),image(),exceptionInfo);
4860 ThrowImageException;
4863 void Magick::Image::writePixels(const Magick::QuantumType quantum_,
4864 unsigned char *destination_)
4869 quantum_info=AcquireQuantumInfo(imageInfo(),image());
4871 ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4872 quantum_,destination_, exceptionInfo);
4873 quantum_info=DestroyQuantumInfo(quantum_info);
4874 ThrowImageException;
4877 void Magick::Image::zoom(const Geometry &geometry_)
4890 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4894 newImage=ResizeImage(constImage(),width,height,image()->filter,exceptionInfo);
4895 replaceImage(newImage);
4896 ThrowImageException;
4899 Magick::Image::Image(MagickCore::Image *image_)
4900 : _imgRef(new ImageRef(image_))
4904 MagickCore::Image *&Magick::Image::image(void)
4906 return(_imgRef->image());
4909 const MagickCore::Image *Magick::Image::constImage(void) const
4911 return(_imgRef->image());
4914 MagickCore::ImageInfo *Magick::Image::imageInfo(void)
4916 return(_imgRef->options()->imageInfo());
4919 const MagickCore::ImageInfo *Magick::Image::constImageInfo(void) const
4921 return(_imgRef->options()->imageInfo());
4924 Magick::Options *Magick::Image::options(void)
4926 return(_imgRef->options());
4929 const Magick::Options *Magick::Image::constOptions(void) const
4931 return(_imgRef->options());
4934 MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)
4936 return(_imgRef->options()->quantizeInfo());
4939 const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
4941 return(_imgRef->options()->quantizeInfo());
4944 void Magick::Image::modifyImage(void)
4946 if (!_imgRef->isShared())
4950 replaceImage(CloneImage(image(),0,0,MagickTrue,exceptionInfo));
4951 ThrowImageException;
4954 MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
4964 image=AcquireImage(constImageInfo(),exceptionInfo);
4965 ThrowImageException;
4968 _imgRef=ImageRef::replaceImage(_imgRef,image);
4972 void Magick::Image::read(MagickCore::Image *image,
4973 MagickCore::ExceptionInfo *exceptionInfo)
4975 // Ensure that multiple image frames were not read.
4976 if (image != (MagickCore::Image *) NULL &&
4977 image->next != (MagickCore::Image *) NULL)
4982 // Destroy any extra image frames
4984 image->next=(MagickCore::Image *) NULL;
4985 next->previous=(MagickCore::Image *) NULL;
4986 DestroyImageList(next);
4988 replaceImage(image);
4989 if (exceptionInfo->severity == MagickCore::UndefinedException &&
4990 image == (MagickCore::Image *) NULL)
4992 (void) MagickCore::DestroyExceptionInfo(exceptionInfo);
4994 throwExceptionExplicit(MagickCore::ImageWarning,
4995 "No image was loaded.");
4997 ThrowImageException;
5000 void Magick::Image::floodFill(const ssize_t x_,const ssize_t y_,
5001 const Magick::Image *fillPattern_,const Magick::Color &fill_,
5002 const MagickCore::PixelInfo *target_,const bool invert_)
5010 // Set drawing fill pattern or fill color
5011 fillColor=options()->fillColor();
5012 fillPattern=(MagickCore::Image *)NULL;
5013 if (options()->fillPattern() != (MagickCore::Image *)NULL)
5016 fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
5018 ThrowImageException;
5021 if (fillPattern_ == (Magick::Image *)NULL)
5023 options()->fillPattern((MagickCore::Image *)NULL);
5024 options()->fillColor(fill_);
5027 options()->fillPattern(fillPattern_->constImage());
5030 (void) FloodfillPaintImage(image(),options()->drawInfo(),
5031 target_,static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),
5032 (MagickBooleanType) invert_,exceptionInfo);
5034 options()->fillColor(fillColor);
5035 options()->fillPattern(fillPattern);
5036 ThrowImageException;