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),
83 Magick::Image::Image(const Blob &blob_)
84 : _imgRef(new ImageRef),
89 // Initialize, Allocate and Read images
92 catch(const Warning &/*warning_*/)
94 // FIXME: need a way to report warnings in constructor
96 catch (const Error &/*error_*/)
104 Magick::Image::Image(const Blob &blob_,const Geometry &size_)
105 : _imgRef(new ImageRef),
113 catch(const Warning &/*warning_*/)
115 // FIXME: need a way to report warnings in constructor
117 catch(const Error &/*error_*/)
125 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
127 : _imgRef(new ImageRef),
133 read(blob_,size_,depth_);
135 catch(const Warning &/*warning_*/)
137 // FIXME: need a way to report warnings in constructor
139 catch(const Error &/*error_*/)
147 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
148 const size_t depth_,const std::string &magick_)
149 : _imgRef(new ImageRef),
155 read(blob_,size_,depth_,magick_);
157 catch(const Warning &/*warning_*/)
159 // FIXME: need a way to report warnings in constructor
161 catch(const Error &/*error_*/)
169 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
170 const std::string &magick_)
171 : _imgRef(new ImageRef),
177 read(blob_,size_,magick_);
179 catch(const Warning &/*warning_*/)
181 // FIXME: need a way to report warnings in constructor
183 catch(const Error &/*error_*/)
191 Magick::Image::Image(const Geometry &size_,const Color &color_)
192 : _imgRef(new ImageRef),
195 // xc: prefix specifies an X11 color string
196 std::string imageSpec("xc:");
204 // Initialize, Allocate and Read images
207 catch(const Warning &/*warning_*/)
209 // FIXME: need a way to report warnings in constructor
211 catch(const Error & /*error_*/)
219 Magick::Image::Image(const Image &image_)
220 : _imgRef(image_._imgRef),
221 _quiet(image_._quiet)
226 Magick::Image::Image(const size_t width_,const size_t height_,
227 const std::string &map_,const StorageType type_,const void *pixels_)
228 : _imgRef(new ImageRef),
233 read(width_,height_,map_.c_str(),type_,pixels_);
235 catch(const Warning &/*warning_*/)
237 // FIXME: need a way to report warnings in constructor
239 catch(const Error &/*error_*/)
247 Magick::Image::Image(const std::string &imageSpec_)
248 : _imgRef(new ImageRef),
253 // Initialize, Allocate and Read images
256 catch(const Warning &/*warning_*/)
258 // FIXME: need a way to report warnings in constructor
260 catch(const Error &/*error_*/)
268 Magick::Image::~Image()
270 if (_imgRef->decrease() == 0)
273 _imgRef=(Magick::ImageRef *) NULL;
276 Magick::Image& Magick::Image::operator=(const Magick::Image &image_)
280 image_._imgRef->increase();
281 if (_imgRef->decrease() == 0)
284 // Use new image reference
285 _imgRef=image_._imgRef;
290 void Magick::Image::adjoin(const bool flag_)
293 options()->adjoin(flag_);
296 bool Magick::Image::adjoin(void) const
298 return(constOptions()->adjoin());
301 void Magick::Image::alpha(const bool matteFlag_)
305 // If matte channel is requested, but image doesn't already have a
306 // matte channel, then create an opaque matte channel. Likewise, if
307 // the image already has a matte channel but a matte channel is not
308 // desired, then set the matte channel to opaque.
310 if ((matteFlag_ && !constImage()->alpha_trait) ||
311 (constImage()->alpha_trait && !matteFlag_))
312 SetImageAlpha(image(),OpaqueAlpha,exceptionInfo);
315 image()->alpha_trait=matteFlag_ ? BlendPixelTrait : UndefinedPixelTrait;
318 bool Magick::Image::alpha(void) const
320 if (constImage()->alpha_trait == BlendPixelTrait)
326 void Magick::Image::alphaColor(const Color &alphaColor_)
330 if (alphaColor_.isValid())
332 image()->matte_color=alphaColor_;
333 options()->matteColor(alphaColor_);
337 // Set to default matte color
338 Color tmpColor("#BDBDBD");
339 image()->matte_color=tmpColor;
340 options()->matteColor(tmpColor);
344 Magick::Color Magick::Image::alphaColor(void) const
346 return(Color(constImage()->matte_color));
349 void Magick::Image::antiAlias(const bool flag_)
352 options()->antiAlias(static_cast<size_t>(flag_));
355 bool Magick::Image::antiAlias(void)
357 return(static_cast<bool>(options()->antiAlias()));
360 void Magick::Image::animationDelay(const size_t delay_)
363 image()->delay=delay_;
366 size_t Magick::Image::animationDelay(void) const
368 return(constImage()->delay);
371 void Magick::Image::animationIterations(const size_t iterations_)
374 image()->iterations=iterations_;
377 size_t Magick::Image::animationIterations(void) const
379 return(constImage()->iterations);
382 void Magick::Image::attenuate(const double attenuate_)
385 value[MaxTextExtent];
388 FormatLocaleString(value,MaxTextExtent,"%.20g",attenuate_);
389 (void) SetImageArtifact(image(),"attenuate",value);
392 void Magick::Image::backgroundColor(const Color &backgroundColor_)
396 if (backgroundColor_.isValid())
397 image()->background_color=backgroundColor_;
399 image()->background_color=Color();
401 options()->backgroundColor(backgroundColor_);
404 Magick::Color Magick::Image::backgroundColor(void) const
406 return(constOptions()->backgroundColor());
409 void Magick::Image::backgroundTexture(const std::string &backgroundTexture_)
412 options()->backgroundTexture(backgroundTexture_);
415 std::string Magick::Image::backgroundTexture(void) const
417 return(constOptions()->backgroundTexture());
420 size_t Magick::Image::baseColumns(void) const
422 return(constImage()->magick_columns);
425 std::string Magick::Image::baseFilename(void) const
427 return(std::string(constImage()->magick_filename));
430 size_t Magick::Image::baseRows(void) const
432 return(constImage()->magick_rows);
435 void Magick::Image::blackPointCompensation(const bool flag_)
437 image()->black_point_compensation=(MagickBooleanType) flag_;
440 bool Magick::Image::blackPointCompensation(void) const
442 return(static_cast<bool>(constImage()->black_point_compensation));
445 void Magick::Image::borderColor(const Color &borderColor_)
449 if (borderColor_.isValid())
450 image()->border_color=borderColor_;
452 image()->border_color=Color();
454 options()->borderColor(borderColor_);
457 Magick::Color Magick::Image::borderColor(void) const
459 return(constOptions()->borderColor());
462 Magick::Geometry Magick::Image::boundingBox(void) const
468 bbox=GetImageBoundingBox(constImage(),exceptionInfo);
470 return(Geometry(bbox));
473 void Magick::Image::boxColor(const Color &boxColor_)
476 options()->boxColor(boxColor_);
479 Magick::Color Magick::Image::boxColor(void) const
481 return(constOptions()->boxColor());
484 void Magick::Image::channelDepth(const ChannelType channel_,
489 SetPPChannelMask(channel_);
490 SetImageDepth(image(),depth_,exceptionInfo);
491 RestorePPChannelMask;
495 size_t Magick::Image::channelDepth(const ChannelType channel_)
501 SetPPChannelMask(channel_);
502 channel_depth=GetImageDepth(constImage(),exceptionInfo);
503 RestorePPChannelMask;
505 return(channel_depth);
508 size_t Magick::Image::channels() const
510 return(constImage()->number_channels);
513 void Magick::Image::classType(const ClassType class_)
515 if (classType() == PseudoClass && class_ == DirectClass)
517 // Use SyncImage to synchronize the DirectClass pixels with the
518 // color map and then set to DirectClass type.
521 SyncImage(image(),exceptionInfo);
523 image()->colormap=(PixelInfo *)RelinquishMagickMemory(image()->colormap);
524 image()->storage_class=static_cast<MagickCore::ClassType>(DirectClass);
528 if (classType() == DirectClass && class_ == PseudoClass)
530 // Quantize to create PseudoClass color map
532 quantizeColors(MaxColormapSize);
534 image()->storage_class=static_cast<MagickCore::ClassType>(PseudoClass);
538 Magick::ClassType Magick::Image::classType(void) const
540 return static_cast<Magick::ClassType>(constImage()->storage_class);
543 void Magick::Image::colorFuzz(const double fuzz_)
547 options()->colorFuzz(fuzz_);
550 double Magick::Image::colorFuzz(void) const
552 return(constOptions()->colorFuzz());
555 void Magick::Image::colorMapSize(const size_t entries_)
557 if (entries_ >MaxColormapSize)
558 throwExceptionExplicit(MagickCore::OptionError,
559 "Colormap entries must not exceed MaxColormapSize");
563 (void) AcquireImageColormap(image(),entries_,exceptionInfo);
567 size_t Magick::Image::colorMapSize(void) const
569 if (!constImage()->colormap)
570 throwExceptionExplicit(MagickCore::OptionError,
571 "Image does not contain a colormap");
573 return(constImage()->colors);
576 void Magick::Image::colorSpace(const ColorspaceType colorSpace_)
578 if (image()->colorspace == colorSpace_)
583 TransformImageColorspace(image(),colorSpace_,exceptionInfo);
587 Magick::ColorspaceType Magick::Image::colorSpace(void) const
589 return (constImage()->colorspace);
592 void Magick::Image::colorSpaceType(const ColorspaceType colorSpace_)
596 SetImageColorspace(image(),colorSpace_,exceptionInfo);
598 options()->colorspaceType(colorSpace_);
601 Magick::ColorspaceType Magick::Image::colorSpaceType(void) const
603 return(constOptions()->colorspaceType());
606 size_t Magick::Image::columns(void) const
608 return(constImage()->columns);
611 void Magick::Image::comment(const std::string &comment_)
615 SetImageProperty(image(),"Comment",NULL,exceptionInfo);
616 if (comment_.length() > 0)
617 SetImageProperty(image(),"Comment",comment_.c_str(),exceptionInfo);
621 std::string Magick::Image::comment(void) const
627 value=GetImageProperty(constImage(),"Comment",exceptionInfo);
631 return(std::string(value));
633 return(std::string()); // Intentionally no exception
636 void Magick::Image::compose(const CompositeOperator compose_)
638 image()->compose=compose_;
641 Magick::CompositeOperator Magick::Image::compose(void) const
643 return(constImage()->compose);
646 void Magick::Image::compressType(const CompressionType compressType_)
649 image()->compression=compressType_;
650 options()->compressType(compressType_);
653 Magick::CompressionType Magick::Image::compressType(void) const
655 return(constImage()->compression);
658 void Magick::Image::debug(const bool flag_)
661 options()->debug(flag_);
664 bool Magick::Image::debug(void) const
666 return(constOptions()->debug());
669 void Magick::Image::density(const Point &density_)
672 options()->density(density_);
673 if (density_.isValid())
675 image()->resolution.x=density_.x();
676 if (density_.y() != 0.0)
677 image()->resolution.y=density_.y();
679 image()->resolution.y=density_.x();
684 image()->resolution.x=0.0;
685 image()->resolution.y=0.0;
689 Magick::Point Magick::Image::density(void) const
697 if (constImage()->resolution.x > 0.0)
698 x_resolution=constImage()->resolution.x;
700 if (constImage()->resolution.y > 0.0)
701 y_resolution=constImage()->resolution.y;
703 return(Point(x_resolution,y_resolution));
706 return(constOptions()->density());
709 void Magick::Image::depth(const size_t depth_)
714 if (depth > MAGICKCORE_QUANTUM_DEPTH)
715 depth=MAGICKCORE_QUANTUM_DEPTH;
718 image()->depth=depth;
719 options()->depth(depth);
722 size_t Magick::Image::depth(void) const
724 return(constImage()->depth);
727 std::string Magick::Image::directory(void) const
729 if (constImage()->directory)
730 return(std::string(constImage()->directory));
733 throwExceptionExplicit(MagickCore::CorruptImageWarning,
734 "Image does not contain a directory");
736 return(std::string());
739 void Magick::Image::endian(const Magick::EndianType endian_)
742 options()->endian(endian_);
743 image()->endian=endian_;
746 Magick::EndianType Magick::Image::endian(void) const
748 return(constImage()->endian);
751 void Magick::Image::exifProfile(const Magick::Blob &exifProfile_)
755 if (exifProfile_.data() != 0)
760 exif_profile=AcquireStringInfo(exifProfile_.length());
761 SetStringInfoDatum(exif_profile,(unsigned char *) exifProfile_.data());
763 (void) SetImageProfile(image(),"exif",exif_profile,exceptionInfo);
764 exif_profile=DestroyStringInfo(exif_profile);
769 Magick::Blob Magick::Image::exifProfile(void) const
774 exif_profile=GetImageProfile(constImage(),"exif");
775 if (exif_profile == (StringInfo *) NULL)
777 return(Blob(GetStringInfoDatum(exif_profile),
778 GetStringInfoLength(exif_profile)));
781 void Magick::Image::fileName(const std::string &fileName_)
785 fileName_.copy(image()->filename,sizeof(image()->filename)-1);
786 image()->filename[fileName_.length()]=0; // Null terminate
788 options()->fileName(fileName_);
791 std::string Magick::Image::fileName(void) const
793 return(constOptions()->fileName());
796 MagickCore::MagickSizeType Magick::Image::fileSize(void) const
798 return(GetBlobSize(constImage()));
801 void Magick::Image::fillColor(const Magick::Color &fillColor_)
807 options()->fillColor(fillColor_);
809 artifact("fill",value);
812 Magick::Color Magick::Image::fillColor(void) const
814 return(constOptions()->fillColor());
817 void Magick::Image::fillRule(const Magick::FillRule &fillRule_)
820 options()->fillRule(fillRule_);
823 Magick::FillRule Magick::Image::fillRule(void) const
825 return constOptions()->fillRule();
828 void Magick::Image::fillPattern(const Image &fillPattern_)
831 if (fillPattern_.isValid())
832 options()->fillPattern(fillPattern_.constImage());
834 options()->fillPattern(static_cast<MagickCore::Image*>(NULL));
837 Magick::Image Magick::Image::fillPattern(void) const
839 // FIXME: This is inordinately innefficient
840 const MagickCore::Image
846 tmpTexture=constOptions()->fillPattern();
854 image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
855 texture.replaceImage(image);
861 void Magick::Image::filterType(const Magick::FilterTypes filterType_)
864 image()->filter=filterType_;
867 Magick::FilterTypes Magick::Image::filterType(void) const
869 return(constImage()->filter);
872 void Magick::Image::font(const std::string &font_)
875 options()->font(font_);
878 std::string Magick::Image::font(void) const
880 return(constOptions()->font());
883 void Magick::Image::fontPointsize(const double pointSize_)
886 options()->fontPointsize(pointSize_);
889 double Magick::Image::fontPointsize(void) const
891 return(constOptions()->fontPointsize());
894 std::string Magick::Image::format(void) const
900 magick_info=GetMagickInfo(constImage()->magick,exceptionInfo);
903 if ((magick_info != 0) && (*magick_info->description != '\0'))
904 return(std::string(magick_info->description));
907 throwExceptionExplicit(MagickCore::CorruptImageWarning,
908 "Unrecognized image magick type");
910 return(std::string());
913 std::string Magick::Image::formatExpression(const std::string expression)
923 text=InterpretImageProperties(imageInfo(),image(),expression.c_str(),
925 if (text != (char *) NULL)
927 text_string=std::string(text);
928 text=DestroyString(text);
934 double Magick::Image::gamma(void) const
936 return(constImage()->gamma);
939 Magick::Geometry Magick::Image::geometry(void) const
941 if (constImage()->geometry)
942 return Geometry(constImage()->geometry);
945 throwExceptionExplicit(MagickCore::OptionWarning,
946 "Image does not contain a geometry");
951 void Magick::Image::gifDisposeMethod(
952 const MagickCore::DisposeType disposeMethod_)
955 image()->dispose=disposeMethod_;
958 MagickCore::DisposeType Magick::Image::gifDisposeMethod(void) const
960 return(constImage()->dispose);
963 void Magick::Image::highlightColor(const Color color_)
969 artifact("highlight-color",value);
972 void Magick::Image::iccColorProfile(const Magick::Blob &colorProfile_)
974 profile("icm",colorProfile_);
977 Magick::Blob Magick::Image::iccColorProfile(void) const
982 color_profile=GetImageProfile(constImage(),"icc");
983 if (color_profile == (StringInfo *) NULL)
985 return(Blob(GetStringInfoDatum(color_profile),GetStringInfoLength(
989 void Magick::Image::interlaceType(const Magick::InterlaceType interlace_)
992 image()->interlace=interlace_;
993 options()->interlaceType(interlace_);
996 Magick::InterlaceType Magick::Image::interlaceType(void) const
998 return(constImage()->interlace);
1001 void Magick::Image::interpolate(const PixelInterpolateMethod interpolate_)
1004 image()->interpolate=interpolate_;
1007 Magick::PixelInterpolateMethod Magick::Image::interpolate(void) const
1009 return constImage()->interpolate;
1012 void Magick::Image::iptcProfile(const Magick::Blob &iptcProfile_)
1015 if (iptcProfile_.data() != 0)
1020 iptc_profile=AcquireStringInfo(iptcProfile_.length());
1021 SetStringInfoDatum(iptc_profile,(unsigned char *) iptcProfile_.data());
1023 (void) SetImageProfile(image(),"iptc",iptc_profile,exceptionInfo);
1024 iptc_profile=DestroyStringInfo(iptc_profile);
1025 ThrowImageException;
1029 Magick::Blob Magick::Image::iptcProfile(void) const
1034 iptc_profile=GetImageProfile(constImage(),"iptc");
1035 if (iptc_profile == (StringInfo *) NULL)
1037 return(Blob(GetStringInfoDatum(iptc_profile),GetStringInfoLength(
1041 void Magick::Image::isValid(const bool isValid_)
1046 _imgRef=new ImageRef;
1048 else if (!isValid())
1050 // Construct with single-pixel black image to make
1051 // image valid. This is an obvious hack.
1052 size(Geometry(1,1));
1057 bool Magick::Image::isValid(void) const
1059 return rows() && columns();
1062 void Magick::Image::label(const std::string &label_)
1066 (void) SetImageProperty(image(),"Label",NULL,exceptionInfo);
1067 if (label_.length() > 0)
1068 (void) SetImageProperty(image(),"Label",label_.c_str(),exceptionInfo);
1069 ThrowImageException;
1072 std::string Magick::Image::label(void) const
1078 value=GetImageProperty(constImage(),"Label",exceptionInfo);
1079 ThrowImageException;
1082 return(std::string(value));
1084 return(std::string());
1087 void Magick::Image::lowlightColor(const Color color_)
1093 artifact("lowlight-color",value);
1096 void Magick::Image::mask(const Magick::Image &mask_)
1101 if (mask_.isValid())
1102 SetImageMask(image(),mask_.constImage(),exceptionInfo);
1104 SetImageMask(image(),(MagickCore::Image *) NULL,exceptionInfo);
1105 ThrowImageException;
1108 Magick::Image Magick::Image::mask(void) const
1114 image=GetImageMask(constImage(),exceptionInfo);
1115 ThrowImageException;
1117 if (image == (MagickCore::Image *) NULL)
1118 return(Magick::Image());
1120 return(Magick::Image(image));
1123 void Magick::Image::magick(const std::string &magick_)
1127 magick_.copy(image()->magick,sizeof(image()->magick)-1);
1128 image()->magick[magick_.length()]=0;
1130 options()->magick(magick_);
1133 std::string Magick::Image::magick(void) const
1135 if (*(constImage()->magick) != '\0')
1136 return(std::string(constImage()->magick));
1138 return(constOptions()->magick());
1141 double Magick::Image::meanErrorPerPixel(void) const
1143 return(constImage()->error.mean_error_per_pixel);
1146 void Magick::Image::modulusDepth(const size_t depth_)
1150 SetImageDepth(image(),depth_,exceptionInfo);
1151 ThrowImageException;
1152 options()->depth(depth_);
1155 size_t Magick::Image::modulusDepth(void) const
1161 depth=GetImageDepth(constImage(),exceptionInfo);
1162 ThrowImageException;
1166 void Magick::Image::monochrome(const bool monochromeFlag_)
1169 options()->monochrome(monochromeFlag_);
1172 bool Magick::Image::monochrome(void) const
1174 return(constOptions()->monochrome());
1177 Magick::Geometry Magick::Image::montageGeometry(void) const
1179 if (constImage()->montage)
1180 return Magick::Geometry(constImage()->montage);
1183 throwExceptionExplicit(MagickCore::CorruptImageWarning,
1184 "Image does not contain a montage");
1186 return(Magick::Geometry());
1189 double Magick::Image::normalizedMaxError(void) const
1191 return(constImage()->error.normalized_maximum_error);
1194 double Magick::Image::normalizedMeanError(void) const
1196 return(constImage()->error.normalized_mean_error);
1199 void Magick::Image::orientation(const Magick::OrientationType orientation_)
1202 image()->orientation=orientation_;
1205 Magick::OrientationType Magick::Image::orientation(void) const
1207 return(constImage()->orientation);
1210 void Magick::Image::page(const Magick::Geometry &pageSize_)
1213 options()->page(pageSize_);
1214 image()->page=pageSize_;
1217 Magick::Geometry Magick::Image::page(void) const
1219 return(Geometry(constImage()->page.width,constImage()->page.height,
1220 AbsoluteValue(constImage()->page.x),AbsoluteValue(constImage()->page.y)));
1223 void Magick::Image::quality(const size_t quality_)
1226 image()->quality=quality_;
1227 options()->quality(quality_);
1230 size_t Magick::Image::quality(void) const
1232 return(constImage()->quality);
1235 void Magick::Image::quantizeColors(const size_t colors_)
1238 options()->quantizeColors(colors_);
1241 size_t Magick::Image::quantizeColors(void) const
1243 return(constOptions()->quantizeColors());
1246 void Magick::Image::quantizeColorSpace(
1247 const Magick::ColorspaceType colorSpace_)
1250 options()->quantizeColorSpace(colorSpace_);
1253 Magick::ColorspaceType Magick::Image::quantizeColorSpace(void) const
1255 return(constOptions()->quantizeColorSpace());
1258 void Magick::Image::quantizeDither(const bool ditherFlag_)
1261 options()->quantizeDither(ditherFlag_);
1264 bool Magick::Image::quantizeDither(void) const
1266 return(constOptions()->quantizeDither());
1269 void Magick::Image::quantizeDitherMethod(const DitherMethod ditherMethod_)
1272 options()->quantizeDitherMethod(ditherMethod_);
1275 MagickCore::DitherMethod Magick::Image::quantizeDitherMethod(void) const
1277 return(constOptions()->quantizeDitherMethod());
1280 void Magick::Image::quantizeTreeDepth(const size_t treeDepth_)
1283 options()->quantizeTreeDepth(treeDepth_);
1286 size_t Magick::Image::quantizeTreeDepth() const
1288 return(constOptions()->quantizeTreeDepth());
1291 void Magick::Image::quiet(const bool quiet_)
1296 bool Magick::Image::quiet(void) const
1301 void Magick::Image::renderingIntent(
1302 const Magick::RenderingIntent renderingIntent_)
1305 image()->rendering_intent=renderingIntent_;
1308 Magick::RenderingIntent Magick::Image::renderingIntent(void) const
1310 return(static_cast<Magick::RenderingIntent>(constImage()->rendering_intent));
1313 void Magick::Image::resolutionUnits(
1314 const Magick::ResolutionType resolutionUnits_)
1317 image()->units=resolutionUnits_;
1318 options()->resolutionUnits(resolutionUnits_);
1321 Magick::ResolutionType Magick::Image::resolutionUnits(void) const
1323 return(static_cast<Magick::ResolutionType>(constImage()->units));
1326 size_t Magick::Image::rows(void) const
1328 return(constImage()->rows);
1331 void Magick::Image::scene(const size_t scene_)
1334 image()->scene=scene_;
1337 size_t Magick::Image::scene(void) const
1339 return(constImage()->scene);
1342 void Magick::Image::size(const Geometry &geometry_)
1345 options()->size(geometry_);
1346 image()->rows=geometry_.height();
1347 image()->columns=geometry_.width();
1350 Magick::Geometry Magick::Image::size(void) const
1352 return(Magick::Geometry(constImage()->columns,constImage()->rows));
1355 void Magick::Image::strokeAntiAlias(const bool flag_)
1358 options()->strokeAntiAlias(flag_);
1361 bool Magick::Image::strokeAntiAlias(void) const
1363 return(constOptions()->strokeAntiAlias());
1366 void Magick::Image::strokeColor(const Magick::Color &strokeColor_)
1372 options()->strokeColor(strokeColor_);
1374 artifact("stroke",value);
1377 Magick::Color Magick::Image::strokeColor(void) const
1379 return(constOptions()->strokeColor());
1382 void Magick::Image::strokeDashArray(const double *strokeDashArray_)
1385 options()->strokeDashArray(strokeDashArray_);
1388 const double* Magick::Image::strokeDashArray(void) const
1390 return(constOptions()->strokeDashArray());
1393 void Magick::Image::strokeDashOffset(const double strokeDashOffset_)
1396 options()->strokeDashOffset(strokeDashOffset_);
1399 double Magick::Image::strokeDashOffset(void) const
1401 return(constOptions()->strokeDashOffset());
1404 void Magick::Image::strokeLineCap(const Magick::LineCap lineCap_)
1407 options()->strokeLineCap(lineCap_);
1410 Magick::LineCap Magick::Image::strokeLineCap(void) const
1412 return(constOptions()->strokeLineCap());
1415 void Magick::Image::strokeLineJoin(const Magick::LineJoin lineJoin_)
1418 options()->strokeLineJoin(lineJoin_);
1421 Magick::LineJoin Magick::Image::strokeLineJoin(void) const
1423 return(constOptions()->strokeLineJoin());
1426 void Magick::Image::strokeMiterLimit(const size_t strokeMiterLimit_)
1429 options()->strokeMiterLimit(strokeMiterLimit_);
1432 size_t Magick::Image::strokeMiterLimit(void) const
1434 return(constOptions()->strokeMiterLimit());
1437 void Magick::Image::strokePattern(const Image &strokePattern_)
1440 if(strokePattern_.isValid())
1441 options()->strokePattern(strokePattern_.constImage());
1443 options()->strokePattern(static_cast<MagickCore::Image*>(NULL));
1446 Magick::Image Magick::Image::strokePattern(void) const
1448 // FIXME: This is inordinately innefficient
1449 const MagickCore::Image
1455 tmpTexture=constOptions()->strokePattern();
1463 image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
1464 texture.replaceImage(image);
1465 ThrowImageException;
1470 void Magick::Image::strokeWidth(const double strokeWidth_)
1473 value[MaxTextExtent];
1476 options()->strokeWidth(strokeWidth_);
1477 FormatLocaleString(value,MaxTextExtent,"%.20g",strokeWidth_);
1478 (void) SetImageArtifact(image(),"strokewidth",value);
1481 double Magick::Image::strokeWidth(void) const
1483 return(constOptions()->strokeWidth());
1486 void Magick::Image::subImage(const size_t subImage_)
1489 options()->subImage(subImage_);
1492 size_t Magick::Image::subImage(void) const
1494 return(constOptions()->subImage());
1497 void Magick::Image::subRange(const size_t subRange_)
1500 options()->subRange(subRange_);
1503 size_t Magick::Image::subRange(void) const
1505 return(constOptions()->subRange());
1508 void Magick::Image::textDirection(DirectionType direction_)
1511 options()->textDirection(direction_);
1514 Magick::DirectionType Magick::Image::textDirection(void) const
1516 return(constOptions()->textDirection());
1519 void Magick::Image::textEncoding(const std::string &encoding_)
1522 options()->textEncoding(encoding_);
1525 std::string Magick::Image::textEncoding(void) const
1527 return(constOptions()->textEncoding());
1530 void Magick::Image::textGravity(GravityType gravity_)
1533 options()->textGravity(gravity_);
1536 Magick::GravityType Magick::Image::textGravity(void) const
1538 return(constOptions()->textGravity());
1541 void Magick::Image::textInterlineSpacing(double spacing_)
1544 options()->textInterlineSpacing(spacing_);
1547 double Magick::Image::textInterlineSpacing(void) const
1549 return(constOptions()->textInterlineSpacing());
1552 void Magick::Image::textInterwordSpacing(double spacing_)
1555 options()->textInterwordSpacing(spacing_);
1558 double Magick::Image::textInterwordSpacing(void) const
1560 return(constOptions()->textInterwordSpacing());
1563 void Magick::Image::textKerning(double kerning_)
1566 options()->textKerning(kerning_);
1569 double Magick::Image::textKerning(void) const
1571 return(constOptions()->textKerning());
1574 size_t Magick::Image::totalColors(void) const
1580 colors=GetNumberColors(constImage(),0,exceptionInfo);
1581 ThrowImageException;
1585 void Magick::Image::transformRotation(const double angle_)
1588 options()->transformRotation(angle_);
1591 void Magick::Image::transformSkewX(const double skewx_)
1594 options()->transformSkewX(skewx_);
1597 void Magick::Image::transformSkewY(const double skewy_)
1600 options()->transformSkewY(skewy_);
1603 Magick::ImageType Magick::Image::type(void) const
1605 if (constOptions()->type() != UndefinedType)
1606 return(constOptions()->type());
1607 else if (constImage()->type != UndefinedType)
1608 return(constImage()->type);
1610 return(determineType());
1613 void Magick::Image::type(const Magick::ImageType type_)
1616 options()->type(type_);
1618 SetImageType(image(),type_,exceptionInfo);
1619 ThrowImageException;
1622 void Magick::Image::verbose(const bool verboseFlag_)
1625 options()->verbose(verboseFlag_);
1628 bool Magick::Image::verbose(void) const
1630 return(constOptions()->verbose());
1633 void Magick::Image::view(const std::string &view_)
1636 options()->view(view_);
1639 std::string Magick::Image::view(void) const
1641 return(constOptions()->view());
1644 void Magick::Image::virtualPixelMethod(
1645 const VirtualPixelMethod virtualPixelMethod_)
1649 SetImageVirtualPixelMethod(image(),virtualPixelMethod_,exceptionInfo);
1650 ThrowImageException;
1653 Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod(void) const
1655 return(GetImageVirtualPixelMethod(constImage()));
1658 void Magick::Image::x11Display(const std::string &display_)
1661 options()->x11Display(display_);
1664 std::string Magick::Image::x11Display(void) const
1666 return(constOptions()->x11Display());
1669 double Magick::Image::xResolution(void) const
1671 return(constImage()->resolution.x);
1674 double Magick::Image::yResolution(void) const
1676 return(constImage()->resolution.y);
1679 void Magick::Image::adaptiveBlur(const double radius_,const double sigma_)
1685 newImage=AdaptiveBlurImage(constImage(),radius_,sigma_,exceptionInfo);
1686 replaceImage(newImage);
1687 ThrowImageException;
1690 void Magick::Image::adaptiveResize(const Geometry &geometry_)
1703 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
1707 newImage=AdaptiveResizeImage(constImage(),width,height,exceptionInfo);
1708 replaceImage(newImage);
1709 ThrowImageException;
1712 void Magick::Image::adaptiveSharpen(const double radius_,const double sigma_)
1718 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1719 replaceImage(newImage);
1720 ThrowImageException;
1723 void Magick::Image::adaptiveSharpenChannel(const ChannelType channel_,
1724 const double radius_,const double sigma_ )
1730 SetPPChannelMask(channel_);
1731 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1732 RestorePPChannelMask;
1733 replaceImage(newImage);
1734 ThrowImageException;
1737 void Magick::Image::adaptiveThreshold(const size_t width_,const size_t height_,
1745 newImage=AdaptiveThresholdImage(constImage(),width_,height_,bias_,
1747 replaceImage(newImage);
1748 ThrowImageException;
1751 void Magick::Image::addNoise(const NoiseType noiseType_)
1757 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1758 replaceImage(newImage);
1759 ThrowImageException;
1762 void Magick::Image::addNoiseChannel(const ChannelType channel_,
1763 const NoiseType noiseType_)
1769 SetPPChannelMask(channel_);
1770 newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1771 RestorePPChannelMask;
1772 replaceImage(newImage);
1773 ThrowImageException;
1776 void Magick::Image::affineTransform(const DrawableAffine &affine_)
1784 _affine.sx=affine_.sx();
1785 _affine.sy=affine_.sy();
1786 _affine.rx=affine_.rx();
1787 _affine.ry=affine_.ry();
1788 _affine.tx=affine_.tx();
1789 _affine.ty=affine_.ty();
1792 newImage=AffineTransformImage(constImage(),&_affine,exceptionInfo);
1793 replaceImage(newImage);
1794 ThrowImageException;
1797 void Magick::Image::alpha(const unsigned int alpha_)
1801 SetImageAlpha(image(),alpha_,exceptionInfo);
1802 ThrowImageException;
1805 void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
1809 SetImageAlphaChannel(image(),alphaOption_,exceptionInfo);
1810 ThrowImageException;
1813 void Magick::Image::annotate(const std::string &text_,
1814 const Geometry &location_)
1816 annotate(text_,location_,NorthWestGravity,0.0);
1819 void Magick::Image::annotate(const std::string &text_,
1820 const Geometry &boundingArea_,const GravityType gravity_)
1822 annotate(text_,boundingArea_,gravity_,0.0);
1825 void Magick::Image::annotate(const std::string &text_,
1826 const Geometry &boundingArea_,const GravityType gravity_,
1827 const double degrees_)
1833 boundingArea[MaxTextExtent];
1840 drawInfo=options()->drawInfo();
1841 drawInfo->text=const_cast<char *>(text_.c_str());
1842 drawInfo->geometry=0;
1844 if (boundingArea_.isValid())
1846 if (boundingArea_.width() == 0 || boundingArea_.height() == 0)
1848 FormatLocaleString(boundingArea,MaxTextExtent,"%+.20g%+.20g",
1849 (double) boundingArea_.xOff(),(double) boundingArea_.yOff());
1853 (void) CopyMagickString(boundingArea,string(boundingArea_).c_str(),
1856 drawInfo->geometry=boundingArea;
1859 drawInfo->gravity=gravity_;
1861 oaffine=drawInfo->affine;
1862 if (degrees_ != 0.0)
1875 current=drawInfo->affine;
1876 affine.sx=cos(DegreesToRadians(fmod(degrees_,360.0)));
1877 affine.rx=sin(DegreesToRadians(fmod(degrees_,360.0)));
1878 affine.ry=(-sin(DegreesToRadians(fmod(degrees_,360.0))));
1879 affine.sy=cos(DegreesToRadians(fmod(degrees_,360.0)));
1881 drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
1882 drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
1883 drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
1884 drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
1885 drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty
1890 AnnotateImage(image(),drawInfo,exceptionInfo);
1892 // Restore original values
1893 drawInfo->affine=oaffine;
1895 drawInfo->geometry=0;
1897 ThrowImageException;
1900 void Magick::Image::annotate(const std::string &text_,
1901 const GravityType gravity_)
1908 drawInfo=options()->drawInfo();
1909 drawInfo->text=const_cast<char *>(text_.c_str());
1910 drawInfo->gravity=gravity_;
1913 AnnotateImage(image(),drawInfo,exceptionInfo);
1915 drawInfo->gravity=NorthWestGravity;
1918 ThrowImageException;
1921 void Magick::Image::artifact(const std::string &name_,const std::string &value_)
1924 (void) SetImageArtifact(image(),name_.c_str(),value_.c_str());
1927 std::string Magick::Image::artifact(const std::string &name_)
1932 value=GetImageArtifact(constImage(),name_.c_str());
1934 return(std::string(value));
1935 return(std::string());
1938 void Magick::Image::attribute(const std::string name_,const std::string value_)
1942 SetImageProperty(image(),name_.c_str(),value_.c_str(),exceptionInfo);
1943 ThrowImageException;
1946 std::string Magick::Image::attribute(const std::string name_)
1952 value=GetImageProperty(constImage(),name_.c_str(),exceptionInfo);
1953 ThrowImageException;
1956 return(std::string(value));
1958 return(std::string()); // Intentionally no exception
1961 void Magick::Image::autoGamma(void)
1965 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1966 (void) AutoGammaImage(image(),exceptionInfo);
1967 ThrowImageException;
1970 void Magick::Image::autoGammaChannel(const ChannelType channel_)
1974 SetPPChannelMask(channel_);
1975 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1976 (void) AutoGammaImage(image(),exceptionInfo);
1977 RestorePPChannelMask;
1978 ThrowImageException;
1981 void Magick::Image::autoLevel(void)
1985 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1986 (void) AutoLevelImage(image(),exceptionInfo);
1987 ThrowImageException;
1990 void Magick::Image::autoLevelChannel(const ChannelType channel_)
1994 SetPPChannelMask(channel_);
1995 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
1996 (void) AutoLevelImage(image(),exceptionInfo);
1997 RestorePPChannelMask;
1998 ThrowImageException;
2001 void Magick::Image::autoOrient(void)
2006 if (image()->orientation == UndefinedOrientation ||
2007 image()->orientation == TopLeftOrientation)
2011 (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2012 newImage=AutoOrientImage(constImage(),image()->orientation,exceptionInfo);
2013 replaceImage(newImage);
2014 ThrowImageException;
2017 void Magick::Image::blackThreshold(const std::string &threshold_)
2021 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2022 ThrowImageException;
2025 void Magick::Image::blackThresholdChannel(const ChannelType channel_,
2026 const std::string &threshold_)
2030 SetPPChannelMask(channel_);
2031 BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2032 RestorePPChannelMask;
2033 ThrowImageException;
2036 void Magick::Image::blueShift(const double factor_)
2042 newImage=BlueShiftImage(constImage(),factor_,exceptionInfo);
2043 replaceImage(newImage);
2044 ThrowImageException;
2047 void Magick::Image::blur(const double radius_,const double sigma_)
2053 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2054 replaceImage(newImage);
2055 ThrowImageException;
2058 void Magick::Image::blurChannel(const ChannelType channel_,
2059 const double radius_,const double sigma_)
2065 SetPPChannelMask(channel_);
2066 newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2067 RestorePPChannelMask;
2068 replaceImage(newImage);
2069 ThrowImageException;
2072 void Magick::Image::border(const Geometry &geometry_)
2078 borderInfo=geometry_;
2081 newImage=BorderImage(constImage(),&borderInfo,image()->compose,
2083 replaceImage(newImage);
2084 ThrowImageException;
2087 void Magick::Image::brightnessContrast(const double brightness_,
2088 const double contrast_)
2092 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2093 ThrowImageException;
2096 void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
2097 const double brightness_,const double contrast_)
2101 SetPPChannelMask(channel_);
2102 BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2103 RestorePPChannelMask;
2104 ThrowImageException;
2107 void Magick::Image::cannyEdge(const double radius_,const double sigma_,
2108 const double lowerPercent_,const double upperPercent_)
2115 newImage=CannyEdgeImage(constImage(),radius_,sigma_,lowerPercent_,
2116 upperPercent_,exceptionInfo);
2117 replaceImage(newImage);
2118 ThrowImageException;
2121 void Magick::Image::channel(const ChannelType channel_)
2127 newImage=SeparateImage(image(),channel_,exceptionInfo);
2128 replaceImage(newImage);
2129 ThrowImageException;
2132 void Magick::Image::charcoal(const double radius_,const double sigma_)
2138 newImage=CharcoalImage(image(),radius_,sigma_,exceptionInfo);
2139 replaceImage(newImage);
2140 ThrowImageException;
2143 void Magick::Image::chop(const Geometry &geometry_)
2152 newImage=ChopImage(image(),&chopInfo,exceptionInfo);
2153 replaceImage(newImage);
2154 ThrowImageException;
2157 void Magick::Image::chromaBluePrimary(const double x_,const double y_)
2160 image()->chromaticity.blue_primary.x=x_;
2161 image()->chromaticity.blue_primary.y=y_;
2164 void Magick::Image::chromaBluePrimary(double *x_,double *y_) const
2166 *x_=constImage()->chromaticity.blue_primary.x;
2167 *y_=constImage()->chromaticity.blue_primary.y;
2170 void Magick::Image::chromaGreenPrimary(const double x_,const double y_)
2173 image()->chromaticity.green_primary.x=x_;
2174 image()->chromaticity.green_primary.y=y_;
2177 void Magick::Image::chromaGreenPrimary(double *x_,double *y_) const
2179 *x_=constImage()->chromaticity.green_primary.x;
2180 *y_=constImage()->chromaticity.green_primary.y;
2183 void Magick::Image::chromaRedPrimary(const double x_,const double y_)
2186 image()->chromaticity.red_primary.x=x_;
2187 image()->chromaticity.red_primary.y=y_;
2190 void Magick::Image::chromaRedPrimary(double *x_,double *y_) const
2192 *x_=constImage()->chromaticity.red_primary.x;
2193 *y_=constImage()->chromaticity.red_primary.y;
2196 void Magick::Image::chromaWhitePoint(const double x_,const double y_)
2199 image()->chromaticity.white_point.x=x_;
2200 image()->chromaticity.white_point.y=y_;
2203 void Magick::Image::chromaWhitePoint(double *x_,double *y_) const
2205 *x_=constImage()->chromaticity.white_point.x;
2206 *y_=constImage()->chromaticity.white_point.y;
2209 void Magick::Image::cdl(const std::string &cdl_)
2213 (void) ColorDecisionListImage(image(),cdl_.c_str(),exceptionInfo);
2214 ThrowImageException;
2217 void Magick::Image::clamp(void)
2221 ClampImage(image(),exceptionInfo);
2222 ThrowImageException;
2225 void Magick::Image::clampChannel(const ChannelType channel_)
2229 SetPPChannelMask(channel_);
2230 ClampImage(image(),exceptionInfo);
2231 RestorePPChannelMask;
2232 ThrowImageException;
2235 void Magick::Image::clip(void)
2239 ClipImage(image(),exceptionInfo);
2240 ThrowImageException;
2243 void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
2247 ClipImagePath(image(),pathname_.c_str(),(MagickBooleanType) inside_,
2249 ThrowImageException;
2252 void Magick::Image::clut(const Image &clutImage_,
2253 const PixelInterpolateMethod method)
2257 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2258 ThrowImageException;
2261 void Magick::Image::clutChannel(const ChannelType channel_,
2262 const Image &clutImage_,const PixelInterpolateMethod method)
2266 SetPPChannelMask(channel_);
2267 ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2268 RestorePPChannelMask;
2269 ThrowImageException;
2272 void Magick::Image::colorize(const unsigned int alpha_,const Color &penColor_)
2274 colorize(alpha_,alpha_,alpha_,penColor_);
2277 void Magick::Image::colorize(const unsigned int alphaRed_,
2278 const unsigned int alphaGreen_,const unsigned int alphaBlue_,
2279 const Color &penColor_)
2282 blend[MaxTextExtent];
2290 if (!penColor_.isValid())
2291 throwExceptionExplicit(MagickCore::OptionError,
2292 "Pen color argument is invalid");
2294 FormatLocaleString(blend,MaxTextExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
2297 target=static_cast<PixelInfo>(penColor_);
2299 newImage=ColorizeImage(image(),blend,&target,exceptionInfo);
2300 replaceImage(newImage);
2301 ThrowImageException;
2304 void Magick::Image::colorMap(const size_t index_,const Color &color_)
2311 if (index_ > (MaxColormapSize-1))
2312 throwExceptionExplicit(MagickCore::OptionError,
2313 "Colormap index must be less than MaxColormapSize");
2315 if (!color_.isValid())
2316 throwExceptionExplicit(MagickCore::OptionError,
2317 "Color argument is invalid");
2321 // Ensure that colormap size is large enough
2322 if (colorMapSize() < (index_+1))
2323 colorMapSize(index_+1);
2325 // Set color at index in colormap
2326 (imageptr->colormap)[index_]=color_;
2329 Magick::Color Magick::Image::colorMap(const size_t index_) const
2331 if (!constImage()->colormap)
2333 throwExceptionExplicit(MagickCore::OptionError,
2334 "Image does not contain a colormap");
2338 if (index_ > constImage()->colors-1)
2339 throwExceptionExplicit(MagickCore::OptionError,"Index out of range");
2341 return(Magick::Color((constImage()->colormap)[index_]));
2344 void Magick::Image::colorMatrix(const size_t order_,
2345 const double *color_matrix_)
2351 kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2352 if (kernel_info != (KernelInfo *) NULL)
2354 kernel_info->width=order_;
2355 kernel_info->height=order_;
2356 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2357 order_*sizeof(*kernel_info->values));
2358 if (kernel_info->values != (MagickRealType *) NULL)
2363 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2364 kernel_info->values[i]=color_matrix_[i];
2365 newImage=ColorMatrixImage(image(),kernel_info,exceptionInfo);
2366 replaceImage(newImage);
2368 kernel_info=DestroyKernelInfo(kernel_info);
2370 ThrowImageException;
2373 bool Magick::Image::compare(const Image &reference_)
2384 status=static_cast<bool>(IsImagesEqual(image(),ref.image(),exceptionInfo));
2385 ThrowImageException;
2389 double Magick::Image::compare(const Image &reference_,const MetricType metric_)
2395 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2397 ThrowImageException;
2401 double Magick::Image::compareChannel(const ChannelType channel_,
2402 const Image &reference_,const MetricType metric_)
2408 SetPPChannelMask(channel_);
2409 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2411 RestorePPChannelMask;
2412 ThrowImageException;
2416 Magick::Image Magick::Image::compare(const Image &reference_,
2417 const MetricType metric_,double *distortion)
2423 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2425 ThrowImageException;
2426 if (newImage == (MagickCore::Image *) NULL)
2427 return(Magick::Image());
2429 return(Magick::Image(newImage));
2432 Magick::Image Magick::Image::compareChannel(const ChannelType channel_,
2433 const Image &reference_,const MetricType metric_,double *distortion)
2439 SetPPChannelMask(channel_);
2440 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2442 RestorePPChannelMask;
2443 ThrowImageException;
2444 if (newImage == (MagickCore::Image *) NULL)
2445 return(Magick::Image());
2447 return(Magick::Image(newImage));
2450 void Magick::Image::composite(const Image &compositeImage_,
2451 const Geometry &offset_,const CompositeOperator compose_)
2461 ParseMetaGeometry(static_cast<std::string>(offset_).c_str(),&x,&y,&width,
2466 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2468 ThrowImageException;
2471 void Magick::Image::composite(const Image &compositeImage_,
2472 const GravityType gravity_,const CompositeOperator compose_)
2478 SetGeometry(compositeImage_.constImage(),&geometry);
2479 GravityAdjustGeometry(columns(),rows(),gravity_,&geometry);
2482 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2483 geometry.x,geometry.y,exceptionInfo);
2484 ThrowImageException;
2487 void Magick::Image::composite(const Image &compositeImage_,
2488 const ssize_t xOffset_,const ssize_t yOffset_,
2489 const CompositeOperator compose_)
2491 // Image supplied as compositeImage is composited with current image and
2492 // results in updating current image.
2495 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2496 xOffset_,yOffset_,exceptionInfo);
2497 ThrowImageException;
2500 void Magick::Image::connectedComponents(const size_t connectivity_)
2506 newImage=ConnectedComponentsImage(constImage(),connectivity_,exceptionInfo);
2507 replaceImage(newImage);
2508 ThrowImageException;
2511 void Magick::Image::contrast(const size_t sharpen_)
2515 ContrastImage(image(),(MagickBooleanType) sharpen_,exceptionInfo);
2516 ThrowImageException;
2519 void Magick::Image::contrastStretch(const double blackPoint_,
2520 const double whitePoint_)
2524 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2525 ThrowImageException;
2528 void Magick::Image::contrastStretchChannel(const ChannelType channel_,
2529 const double blackPoint_,const double whitePoint_)
2533 SetPPChannelMask(channel_);
2534 ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2535 RestorePPChannelMask;
2536 ThrowImageException;
2539 void Magick::Image::convolve(const size_t order_,const double *kernel_)
2545 kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2546 kernel_info->width=order_;
2547 kernel_info->height=order_;
2548 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2549 order_*sizeof(*kernel_info->values));
2550 if (kernel_info->values != (MagickRealType *) NULL)
2555 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2556 kernel_info->values[i]=kernel_[i];
2557 newImage=ConvolveImage(image(),kernel_info,exceptionInfo);
2558 replaceImage(newImage);
2560 kernel_info=DestroyKernelInfo(kernel_info);
2561 ThrowImageException;
2564 void Magick::Image::crop(const Geometry &geometry_)
2573 newImage=CropImage(constImage(),&cropInfo,exceptionInfo);
2574 replaceImage(newImage);
2575 ThrowImageException;
2578 void Magick::Image::cycleColormap(const ssize_t amount_)
2582 CycleColormapImage(image(),amount_,exceptionInfo);
2583 ThrowImageException;
2586 void Magick::Image::decipher(const std::string &passphrase_)
2590 DecipherImage(image(),passphrase_.c_str(),exceptionInfo);
2591 ThrowImageException;
2594 void Magick::Image::defineSet(const std::string &magick_,
2595 const std::string &key_,bool flag_)
2601 definition=magick_ + ":" + key_;
2603 (void) SetImageOption(imageInfo(),definition.c_str(),"");
2605 DeleteImageOption(imageInfo(),definition.c_str());
2608 bool Magick::Image::defineSet(const std::string &magick_,
2609 const std::string &key_ ) const
2617 key=magick_ + ":" + key_;
2618 option=GetImageOption(constImageInfo(),key.c_str());
2624 void Magick::Image::defineValue(const std::string &magick_,
2625 const std::string &key_,const std::string &value_)
2632 format=magick_ + ":" + key_;
2634 (void) SetImageOption(imageInfo(),format.c_str(),option.c_str());
2637 std::string Magick::Image::defineValue(const std::string &magick_,
2638 const std::string &key_) const
2646 definition=magick_ + ":" + key_;
2647 option=GetImageOption(constImageInfo(),definition.c_str());
2649 return(std::string(option));
2650 return(std::string());
2653 void Magick::Image::deskew(const double threshold_)
2659 newImage=DeskewImage(constImage(),threshold_,exceptionInfo);
2660 replaceImage(newImage);
2661 ThrowImageException;
2664 void Magick::Image::despeckle(void)
2670 newImage=DespeckleImage(constImage(),exceptionInfo);
2671 replaceImage(newImage);
2672 ThrowImageException;
2675 Magick::ImageType Magick::Image::determineType(void) const
2681 image_type=GetImageType(constImage(),exceptionInfo);
2682 ThrowImageException;
2686 void Magick::Image::display(void)
2689 DisplayImages(imageInfo(),image(),exceptionInfo);
2690 ThrowImageException;
2693 void Magick::Image::distort(const DistortImageMethod method_,
2694 const size_t numberArguments_,const double *arguments_,const bool bestfit_)
2700 newImage=DistortImage(constImage(), method_,numberArguments_,arguments_,
2701 bestfit_ == true ? MagickTrue : MagickFalse,exceptionInfo);
2702 replaceImage(newImage);
2703 ThrowImageException;
2706 void Magick::Image::draw(const Magick::Drawable &drawable_)
2713 wand=DrawAllocateWand(options()->drawInfo(),image());
2717 drawable_.operator()(wand);
2721 ClonePPDrawException(wand);
2722 wand=DestroyDrawingWand(wand);
2723 ThrowPPDrawException(_quiet);
2727 void Magick::Image::draw(const std::vector<Magick::Drawable> &drawable_)
2734 wand=DrawAllocateWand(options()->drawInfo(),image());
2738 for (std::vector<Magick::Drawable>::const_iterator p = drawable_.begin();
2739 p != drawable_.end(); p++ )
2741 p->operator()(wand);
2742 if (DrawGetExceptionType(wand) != MagickCore::UndefinedException)
2746 if (DrawGetExceptionType(wand) == MagickCore::UndefinedException)
2749 ClonePPDrawException(wand);
2750 wand=DestroyDrawingWand(wand);
2751 ThrowPPDrawException(_quiet);
2755 void Magick::Image::edge(const double radius_)
2761 newImage=EdgeImage(constImage(),radius_,exceptionInfo);
2762 replaceImage(newImage);
2763 ThrowImageException;
2766 void Magick::Image::emboss(const double radius_,const double sigma_)
2772 newImage=EmbossImage(constImage(),radius_,sigma_,exceptionInfo);
2773 replaceImage(newImage);
2774 ThrowImageException;
2777 void Magick::Image::encipher(const std::string &passphrase_)
2781 EncipherImage(image(),passphrase_.c_str(),exceptionInfo);
2782 ThrowImageException;
2785 void Magick::Image::enhance(void)
2791 newImage=EnhanceImage(constImage(),exceptionInfo);
2792 replaceImage(newImage);
2793 ThrowImageException;
2796 void Magick::Image::equalize(void)
2800 EqualizeImage(image(),exceptionInfo);
2801 ThrowImageException;
2804 void Magick::Image::erase(void)
2808 (void) SetImageBackgroundColor(image(),exceptionInfo);
2809 ThrowImageException;
2812 void Magick::Image::extent(const Geometry &geometry_ )
2818 extentInfo=geometry_;
2821 extentInfo.x=geometry_.xOff();
2822 extentInfo.y=geometry_.yOff();
2824 newImage=ExtentImage(image(),&extentInfo,exceptionInfo);
2825 replaceImage(newImage);
2826 ThrowImageException;
2829 void Magick::Image::extent(const Geometry &geometry_,
2830 const Color &backgroundColor_)
2832 backgroundColor(backgroundColor_);
2836 void Magick::Image::extent(const Geometry &geometry_,
2837 const Color &backgroundColor_,const GravityType gravity_)
2839 backgroundColor(backgroundColor_);
2840 extent(geometry_,gravity_);
2843 void Magick::Image::extent(const Geometry &geometry_,
2844 const GravityType gravity_)
2849 SetGeometry(image(),&geometry);
2850 geometry.width=geometry_.width();
2851 geometry.height=geometry_.height();
2852 GravityAdjustGeometry(image()->columns,image()->rows,gravity_,&geometry);
2856 void Magick::Image::flip(void)
2862 newImage=FlipImage(constImage(),exceptionInfo);
2863 replaceImage(newImage);
2864 ThrowImageException;
2867 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2868 const unsigned int alpha_,const bool invert_)
2875 target=static_cast<PixelInfo>(pixelColor(x_,y_));
2876 target.alpha=alpha_;
2878 SetPPChannelMask(AlphaChannel);
2879 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2880 (MagickBooleanType)invert_,exceptionInfo);
2881 RestorePPChannelMask;
2882 ThrowImageException;
2885 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2886 const unsigned int alpha_,const Color &target_,const bool invert_)
2893 target=static_cast<PixelInfo>(target_);
2894 target.alpha=alpha_;
2896 SetPPChannelMask(AlphaChannel);
2897 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2898 (MagickBooleanType)invert_,exceptionInfo);
2899 RestorePPChannelMask;
2900 ThrowImageException;
2903 void Magick::Image::floodFillColor(const Geometry &point_,
2904 const Magick::Color &fillColor_,const bool invert_)
2906 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,invert_);
2909 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2910 const Magick::Color &fillColor_,const bool invert_)
2917 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2918 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2921 void Magick::Image::floodFillColor(const Geometry &point_,
2922 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2925 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,borderColor_,invert_);
2928 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2929 const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2937 pixel=static_cast<PixelInfo>(borderColor_);
2938 floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2941 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2942 const Magick::Image &texture_,const bool invert_)
2944 floodFillTexture(point_.xOff(),point_.yOff(),texture_,invert_);
2947 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2948 const Magick::Image &texture_,const bool invert_)
2955 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2956 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
2959 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2960 const Magick::Image &texture_,const Magick::Color &borderColor_,
2963 floodFillTexture(point_.xOff(),point_.yOff(),texture_,borderColor_,invert_);
2966 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2967 const Magick::Image &texture_,const Magick::Color &borderColor_,
2975 pixel=static_cast<PixelInfo>(borderColor_);
2976 floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
2979 void Magick::Image::flop(void)
2985 newImage=FlopImage(constImage(),exceptionInfo);
2986 replaceImage(newImage);
2987 ThrowImageException;
2990 void Magick::Image::fontTypeMetrics(const std::string &text_,
2991 TypeMetric *metrics)
2996 drawInfo=options()->drawInfo();
2997 drawInfo->text=const_cast<char *>(text_.c_str());
2999 GetTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3001 ThrowImageException;
3004 void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
3005 TypeMetric *metrics)
3010 drawInfo=options()->drawInfo();
3011 drawInfo->text=const_cast<char *>(text_.c_str());
3013 GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3015 ThrowImageException;
3018 void Magick::Image::frame(const Geometry &geometry_)
3026 info.x=static_cast<ssize_t>(geometry_.width());
3027 info.y=static_cast<ssize_t>(geometry_.height());
3028 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3029 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3030 info.outer_bevel=geometry_.xOff();
3031 info.inner_bevel=geometry_.yOff();
3034 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3035 replaceImage(newImage);
3036 ThrowImageException;
3039 void Magick::Image::frame(const size_t width_,const size_t height_,
3040 const ssize_t outerBevel_,const ssize_t innerBevel_)
3048 info.x=static_cast<ssize_t>(width_);
3049 info.y=static_cast<ssize_t>(height_);
3050 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3051 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3052 info.outer_bevel=static_cast<ssize_t>(outerBevel_);
3053 info.inner_bevel=static_cast<ssize_t>(innerBevel_);
3056 newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3057 replaceImage(newImage);
3058 ThrowImageException;
3061 void Magick::Image::fx(const std::string expression_)
3067 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3068 replaceImage(newImage);
3069 ThrowImageException;
3072 void Magick::Image::fx(const std::string expression_,
3073 const Magick::ChannelType channel_)
3079 SetPPChannelMask(channel_);
3080 newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3081 RestorePPChannelMask;
3082 replaceImage(newImage);
3083 ThrowImageException;
3086 void Magick::Image::gamma(const double gamma_)
3090 GammaImage(image(),gamma_,exceptionInfo);
3091 ThrowImageException;
3094 void Magick::Image::gamma(const double gammaRed_,const double gammaGreen_,
3095 const double gammaBlue_)
3098 gamma[MaxTextExtent + 1];
3100 FormatLocaleString(gamma,MaxTextExtent,"%3.6f/%3.6f/%3.6f/",gammaRed_,
3101 gammaGreen_,gammaBlue_);
3105 GammaImage(image(),atof(gamma),exceptionInfo);
3106 ThrowImageException;
3109 void Magick::Image::gaussianBlur(const double width_,const double sigma_)
3115 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3116 replaceImage(newImage);
3117 ThrowImageException;
3120 void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
3121 const double width_,const double sigma_)
3127 SetPPChannelMask(channel_);
3128 newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3129 RestorePPChannelMask;
3130 replaceImage(newImage);
3131 ThrowImageException;
3134 const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
3135 const ssize_t y_,const size_t columns_,const size_t rows_) const
3141 p=(*GetVirtualPixels)(constImage(),x_, y_,columns_, rows_,exceptionInfo);
3142 ThrowImageException;
3146 const void *Magick::Image::getConstMetacontent(void) const
3151 result=GetVirtualMetacontent(constImage());
3154 throwExceptionExplicit(MagickCore::OptionError,
3155 "Unable to retrieve meta content.");
3160 void *Magick::Image::getMetacontent(void )
3165 result=GetAuthenticMetacontent(image());
3168 throwExceptionExplicit(MagickCore::OptionError,
3169 "Unable to retrieve meta content.");
3174 Magick::Quantum *Magick::Image::getPixels(const ssize_t x_,const ssize_t y_,
3175 const size_t columns_,const size_t rows_)
3182 result=(*GetAuthenticPixels)(image(),x_, y_,columns_,rows_,exceptionInfo);
3183 ThrowImageException;
3188 void Magick::Image::grayscale(const PixelIntensityMethod method_)
3192 (void) GrayscaleImage(image(),method_,exceptionInfo);
3193 ThrowImageException;
3196 void Magick::Image::haldClut(const Image &clutImage_)
3200 (void) HaldClutImage(image(),clutImage_.constImage(),exceptionInfo);
3201 ThrowImageException;
3204 void Magick::Image::houghLine(const size_t width_,const size_t height_,
3205 const size_t threshold_)
3211 newImage=HoughLineImage(constImage(),width_,height_,threshold_,
3213 replaceImage(newImage);
3214 ThrowImageException;
3217 void Magick::Image::implode(const double factor_)
3223 newImage=ImplodeImage(constImage(),factor_,image()->interpolate,
3225 replaceImage(newImage);
3226 ThrowImageException;
3229 void Magick::Image::inverseFourierTransform(const Image &phase_)
3231 inverseFourierTransform(phase_,true);
3234 void Magick::Image::inverseFourierTransform(const Image &phase_,
3235 const bool magnitude_)
3241 newImage=InverseFourierTransformImage(constImage(),phase_.constImage(),
3242 magnitude_ == true ? MagickTrue : MagickFalse,exceptionInfo);
3243 replaceImage(newImage);
3244 ThrowImageException;
3247 void Magick::Image::kuwahara(const double radius_,const double sigma_)
3253 newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3254 replaceImage(newImage);
3255 ThrowImageException;
3258 void Magick::Image::kuwaharaChannel(const ChannelType channel_,
3259 const double radius_,const double sigma_)
3265 SetPPChannelMask(channel_);
3266 newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3267 replaceImage(newImage);
3268 RestorePPChannelMask;
3269 ThrowImageException;
3272 void Magick::Image::level(const double blackPoint_,const double whitePoint_,
3273 const double gamma_)
3277 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3278 ThrowImageException;
3281 void Magick::Image::levelChannel(const ChannelType channel_,
3282 const double blackPoint_,const double whitePoint_,const double gamma_)
3286 SetPPChannelMask(channel_);
3287 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3288 RestorePPChannelMask;
3289 ThrowImageException;
3292 void Magick::Image::levelColors(const Color &blackColor_,
3293 const Color &whiteColor_,const bool invert_)
3301 black=static_cast<PixelInfo>(blackColor_);
3302 white=static_cast<PixelInfo>(whiteColor_);
3304 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3305 MagickTrue : MagickFalse,exceptionInfo);
3306 ThrowImageException;
3309 void Magick::Image::levelColorsChannel(const ChannelType channel_,
3310 const Color &blackColor_,const Color &whiteColor_,const bool invert_)
3318 black=static_cast<PixelInfo>(blackColor_);
3319 white=static_cast<PixelInfo>(whiteColor_);
3321 SetPPChannelMask(channel_);
3322 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3323 MagickTrue : MagickFalse,exceptionInfo);
3324 RestorePPChannelMask;
3325 ThrowImageException;
3328 void Magick::Image::linearStretch(const double blackPoint_,
3329 const double whitePoint_)
3333 LinearStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
3334 ThrowImageException;
3337 void Magick::Image::liquidRescale(const Geometry &geometry_)
3350 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3354 newImage=LiquidRescaleImage(image(),width,height,x,y,exceptionInfo);
3355 replaceImage(newImage);
3356 ThrowImageException;
3359 void Magick::Image::magnify(void)
3365 newImage=MagnifyImage(constImage(),exceptionInfo);
3366 replaceImage(newImage);
3367 ThrowImageException;
3370 void Magick::Image::map(const Image &mapImage_,const bool dither_)
3374 options()->quantizeDither(dither_);
3375 RemapImage(options()->quantizeInfo(),image(),mapImage_.constImage(),
3377 ThrowImageException;
3380 void Magick::Image::medianFilter(const double radius_)
3386 newImage=StatisticImage(image(),MedianStatistic,(size_t) radius_,
3387 (size_t) radius_,exceptionInfo);
3388 replaceImage(newImage);
3389 ThrowImageException;
3392 void Magick::Image::minify(void)
3398 newImage=MinifyImage(constImage(),exceptionInfo);
3399 replaceImage(newImage);
3400 ThrowImageException;
3403 void Magick::Image::modulate(const double brightness_,const double saturation_,
3407 modulate[MaxTextExtent + 1];
3409 FormatLocaleString(modulate,MaxTextExtent,"%3.6f,%3.6f,%3.6f",brightness_,
3414 ModulateImage(image(),modulate,exceptionInfo);
3415 ThrowImageException;
3418 Magick::ImageMoments Magick::Image::moments(void)
3420 return(ImageMoments(*this));
3423 void Magick::Image::morphology(const MorphologyMethod method_,
3424 const std::string kernel_,const ssize_t iterations_)
3433 kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3434 if (kernel == (KernelInfo *) NULL)
3435 throwExceptionExplicit(MagickCore::OptionError,"Unable to parse kernel.");
3436 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3438 replaceImage(newImage);
3439 kernel=DestroyKernelInfo(kernel);
3440 ThrowImageException;
3443 void Magick::Image::morphology(const MorphologyMethod method_,
3444 const KernelInfoType kernel_,const std::string arguments_,
3445 const ssize_t iterations_)
3453 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3454 if (option == (const char *)NULL)
3455 throwExceptionExplicit(MagickCore::OptionError,
3456 "Unable to determine kernel type.");
3458 kernel=std::string(option);
3459 if (!arguments_.empty())
3460 kernel+=":"+arguments_;
3462 morphology(method_,kernel,iterations_);
3465 void Magick::Image::morphologyChannel(const ChannelType channel_,
3466 const MorphologyMethod method_,const std::string kernel_,
3467 const ssize_t iterations_)
3477 kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3478 if (kernel == (KernelInfo *)NULL)
3479 throwExceptionExplicit(MagickCore::OptionError,"Unable to parse kernel.");
3480 SetPPChannelMask(channel_);
3481 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3483 RestorePPChannelMask;
3484 replaceImage(newImage);
3485 kernel=DestroyKernelInfo(kernel);
3486 ThrowImageException;
3489 void Magick::Image::morphologyChannel(const ChannelType channel_,
3490 const MorphologyMethod method_,const KernelInfoType kernel_,
3491 const std::string arguments_,const ssize_t iterations_)
3499 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3500 if (option == (const char *)NULL)
3501 throwExceptionExplicit(MagickCore::OptionError,
3502 "Unable to determine kernel type.");
3504 kernel=std::string(option);
3505 if (!arguments_.empty())
3506 kernel+=":"+arguments_;
3508 morphologyChannel(channel_,method_,kernel,iterations_);
3511 void Magick::Image::motionBlur(const double radius_,const double sigma_,
3512 const double angle_)
3518 newImage=MotionBlurImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
3519 replaceImage(newImage);
3520 ThrowImageException;
3523 void Magick::Image::negate(const bool grayscale_)
3527 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3528 ThrowImageException;
3531 void Magick::Image::negateChannel(const ChannelType channel_,
3532 const bool grayscale_)
3536 SetPPChannelMask(channel_);
3537 NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3538 RestorePPChannelMask;
3539 ThrowImageException;
3542 void Magick::Image::normalize(void)
3546 NormalizeImage(image(),exceptionInfo);
3547 ThrowImageException;
3550 void Magick::Image::oilPaint(const double radius_,const double sigma_)
3556 newImage=OilPaintImage(constImage(),radius_,sigma_,exceptionInfo);
3557 replaceImage(newImage);
3558 ThrowImageException;
3561 void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_,
3572 if (!opaqueColor_.isValid())
3573 throwExceptionExplicit(MagickCore::OptionError,
3574 "Opaque color argument is invalid");
3576 if (!penColor_.isValid())
3577 throwExceptionExplicit(MagickCore::OptionError,
3578 "Pen color argument is invalid");
3581 opaqueColor=opaqueColor_;
3585 (void) QueryColorCompliance(opaqueColor.c_str(),AllCompliance,&opaque,
3587 (void) QueryColorCompliance(penColor.c_str(),AllCompliance,&pen,
3589 OpaquePaintImage(image(),&opaque,&pen,invert_ ? MagickTrue : MagickFalse,
3591 ThrowImageException;
3594 void Magick::Image::orderedDither(std::string thresholdMap_)
3598 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3599 ThrowImageException;
3602 void Magick::Image::orderedDitherChannel(const ChannelType channel_,
3603 std::string thresholdMap_)
3607 SetPPChannelMask(channel_);
3608 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3609 RestorePPChannelMask;
3610 ThrowImageException;
3613 void Magick::Image::perceptible(const double epsilon_)
3617 PerceptibleImage(image(),epsilon_,exceptionInfo);
3618 ThrowImageException;
3621 void Magick::Image::perceptibleChannel(const ChannelType channel_,
3622 const double epsilon_)
3626 SetPPChannelMask(channel_);
3627 PerceptibleImage(image(),epsilon_,exceptionInfo);
3628 RestorePPChannelMask;
3629 ThrowImageException;
3632 Magick::ImagePerceptualHash Magick::Image::perceptualHash()
3634 return(ImagePerceptualHash(*this));
3637 void Magick::Image::ping(const std::string &imageSpec_)
3643 options()->fileName(imageSpec_);
3644 newImage=PingImage(imageInfo(),exceptionInfo);
3645 read(newImage,exceptionInfo);
3648 void Magick::Image::ping(const Blob& blob_)
3654 newImage=PingBlob(imageInfo(),blob_.data(),blob_.length(),exceptionInfo);
3655 read(newImage,exceptionInfo);
3658 void Magick::Image::pixelColor(const ssize_t x_,const ssize_t y_,
3659 const Color &color_)
3667 // Test arguments to ensure they are within the image.
3668 if (y_ > (ssize_t) rows() || x_ > (ssize_t) columns())
3669 throwExceptionExplicit(MagickCore::OptionError,
3670 "Access outside of image boundary");
3674 // Set image to DirectClass
3675 classType(DirectClass );
3678 Pixels pixels(*this);
3680 pixel=pixels.get(x_, y_, 1, 1 );
3682 MagickCore::SetPixelViaPixelInfo(constImage(),&packet,pixel);
3683 // Tell ImageMagick that pixels have been updated
3687 Magick::Color Magick::Image::pixelColor(const ssize_t x_,
3688 const ssize_t y_) const
3693 pixel=getConstPixels(x_,y_,1,1);
3699 MagickCore::GetPixelInfoPixel(constImage(),pixel,&packet);
3700 return(Color(packet));
3703 return(Color()); // invalid
3706 void Magick::Image::polaroid(const std::string &caption_,const double angle_,
3707 const PixelInterpolateMethod method_)
3713 newImage=PolaroidImage(constImage(),options()->drawInfo(),caption_.c_str(),
3714 angle_,method_,exceptionInfo);
3715 replaceImage(newImage);
3716 ThrowImageException;
3719 void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
3723 PosterizeImage(image(),levels_,method_,exceptionInfo);
3724 ThrowImageException;
3727 void Magick::Image::posterizeChannel(const ChannelType channel_,
3728 const size_t levels_,const DitherMethod method_)
3732 SetPPChannelMask(channel_);
3733 PosterizeImage(image(),levels_,method_,exceptionInfo);
3734 RestorePPChannelMask;
3735 ThrowImageException;
3738 void Magick::Image::process(std::string name_,const ssize_t argc,
3744 (void) InvokeDynamicImageFilter(name_.c_str(),&image(),argc,argv,
3746 ThrowImageException;
3749 void Magick::Image::profile(const std::string name_,
3750 const Magick::Blob &profile_)
3754 (void) ProfileImage(image(),name_.c_str(),(unsigned char *)profile_.data(),
3755 profile_.length(),exceptionInfo);
3756 ThrowImageException;
3759 Magick::Blob Magick::Image::profile(const std::string name_) const
3764 profile=GetImageProfile(constImage(),name_.c_str());
3766 if (profile == (StringInfo *) NULL)
3768 return(Blob((void*) GetStringInfoDatum(profile),GetStringInfoLength(
3772 void Magick::Image::quantize(const bool measureError_)
3777 options()->quantizeInfo()->measure_error=MagickTrue;
3779 options()->quantizeInfo()->measure_error=MagickFalse;
3782 QuantizeImage(options()->quantizeInfo(),image(),exceptionInfo);
3783 ThrowImageException;
3786 void Magick::Image::quantumOperator(const ChannelType channel_,
3787 const MagickEvaluateOperator operator_,double rvalue_)
3790 SetPPChannelMask(channel_);
3791 EvaluateImage(image(),operator_,rvalue_,exceptionInfo);
3792 RestorePPChannelMask;
3793 ThrowImageException;
3796 void Magick::Image::quantumOperator(const ssize_t x_,const ssize_t y_,
3797 const size_t columns_,const size_t rows_,const ChannelType channel_,
3798 const MagickEvaluateOperator operator_,const double rvalue_)
3806 geometry.width = columns_;
3807 geometry.height = rows_;
3812 cropImage=CropImage(image(),&geometry,exceptionInfo);
3813 SetPPChannelMask(channel_);
3814 EvaluateImage(cropImage,operator_,rvalue_,exceptionInfo);
3815 RestorePPChannelMask;
3816 (void) CompositeImage(image(),cropImage,image()->alpha_trait ==
3817 BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
3818 geometry.x,geometry.y,exceptionInfo );
3819 cropImage=DestroyImageList(cropImage);
3820 ThrowImageException;
3823 void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
3826 raiseInfo=geometry_;
3830 RaiseImage(image(),&raiseInfo,raisedFlag_ == true ? MagickTrue : MagickFalse,
3832 ThrowImageException;
3835 void Magick::Image::randomThreshold(const Geometry &thresholds_)
3838 (void) RandomThresholdImage(image(),static_cast<std::string>(
3839 thresholds_).c_str(),exceptionInfo);
3840 ThrowImageException;
3843 void Magick::Image::randomThresholdChannel(const ChannelType channel_,
3844 const Geometry &thresholds_)
3848 SetPPChannelMask(channel_);
3849 (void) RandomThresholdImage(image(),static_cast<std::string>(
3850 thresholds_).c_str(),exceptionInfo);
3851 RestorePPChannelMask;
3852 ThrowImageException;
3855 void Magick::Image::read(const Blob &blob_)
3861 newImage=BlobToImage(imageInfo(),static_cast<const void *>(blob_.data()),
3862 blob_.length(),exceptionInfo);
3863 read(newImage,exceptionInfo);
3866 void Magick::Image::read(const Blob &blob_,const Geometry &size_)
3872 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3873 const size_t depth_)
3880 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3881 const size_t depth_,const std::string &magick_)
3886 // Set explicit image format
3887 fileName(magick_ + ':');
3891 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3892 const std::string &magick_)
3896 // Set explicit image format
3897 fileName(magick_ + ':');
3901 void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_)
3907 void Magick::Image::read(const size_t width_,const size_t height_,
3908 const std::string &map_,const StorageType type_,const void *pixels_)
3914 newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
3916 replaceImage(newImage);
3917 ThrowImageException;
3920 void Magick::Image::read(const std::string &imageSpec_)
3926 options()->fileName(imageSpec_);
3927 newImage=ReadImage(imageInfo(),exceptionInfo);
3928 read(newImage,exceptionInfo);
3931 void Magick::Image::readPixels(const Magick::QuantumType quantum_,
3932 const unsigned char *source_)
3937 quantum_info=AcquireQuantumInfo(imageInfo(),image());
3939 ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
3940 quantum_,source_,exceptionInfo);
3941 quantum_info=DestroyQuantumInfo(quantum_info);
3942 ThrowImageException;
3945 void Magick::Image::reduceNoise(void)
3950 void Magick::Image::reduceNoise(const double order_)
3956 newImage=StatisticImage(constImage(),NonpeakStatistic,(size_t) order_,
3957 (size_t) order_,exceptionInfo);
3958 replaceImage(newImage);
3959 ThrowImageException;
3962 void Magick::Image::resample(const Point &density_)
3968 newImage=ResampleImage(constImage(),density_.x(),density_.y(),
3969 image()->filter,exceptionInfo);
3970 replaceImage(newImage);
3971 ThrowImageException;
3974 void Magick::Image::resize(const Geometry &geometry_)
3987 // Calculate new size. This code should be supported using binary arguments
3988 // in the ImageMagick library.
3989 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3993 newImage=ResizeImage(constImage(),width,height,image()->filter,
3995 replaceImage(newImage);
3996 ThrowImageException;
3999 void Magick::Image::roll(const Geometry &roll_)
4005 newImage=RollImage(constImage(),roll_.xOff(),roll_.yOff(),exceptionInfo);
4006 replaceImage(newImage);
4007 ThrowImageException;
4010 void Magick::Image::roll(const size_t columns_,const size_t rows_)
4016 newImage=RollImage(constImage(),static_cast<ssize_t>(columns_),
4017 static_cast<ssize_t>(rows_),exceptionInfo);
4018 replaceImage(newImage);
4019 ThrowImageException;
4022 void Magick::Image::rotate(const double degrees_)
4028 newImage=RotateImage(constImage(),degrees_,exceptionInfo);
4029 replaceImage(newImage);
4030 ThrowImageException;
4033 void Magick::Image::rotationalBlur(const double angle_)
4039 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4040 replaceImage(newImage);
4041 ThrowImageException;
4044 void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
4045 const double angle_)
4051 SetPPChannelMask(channel_);
4052 newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4053 RestorePPChannelMask;
4054 replaceImage(newImage);
4055 ThrowImageException;
4058 void Magick::Image::sample(const Geometry &geometry_)
4071 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4075 newImage=SampleImage(constImage(),width,height,exceptionInfo);
4076 replaceImage(newImage);
4077 ThrowImageException;
4080 void Magick::Image::scale(const Geometry &geometry_)
4093 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4097 newImage=ScaleImage(constImage(),width,height,exceptionInfo);
4098 replaceImage(newImage);
4099 ThrowImageException;
4102 void Magick::Image::segment(const double clusterThreshold_,
4103 const double smoothingThreshold_)
4107 SegmentImage(image(),options()->quantizeColorSpace(),
4108 (MagickBooleanType) options()->verbose(),clusterThreshold_,
4109 smoothingThreshold_,exceptionInfo);
4110 SyncImage(image(),exceptionInfo);
4111 ThrowImageException;
4114 void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
4115 const double threshold_)
4121 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4123 replaceImage(newImage);
4124 ThrowImageException;
4127 void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
4128 const double radius_,const double sigma_,const double threshold_)
4134 SetPPChannelMask(channel_);
4135 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4137 RestorePPChannelMask;
4138 replaceImage(newImage);
4139 ThrowImageException;
4142 Magick::Image Magick::Image::separate(const ChannelType channel_)
4148 image=SeparateImage(constImage(),channel_,exceptionInfo);
4149 ThrowImageException;
4150 if (image == (MagickCore::Image *) NULL)
4151 return(Magick::Image());
4153 return(Magick::Image(image));
4156 void Magick::Image::sepiaTone(const double threshold_)
4162 newImage=SepiaToneImage(constImage(),threshold_,exceptionInfo);
4163 replaceImage(newImage);
4164 ThrowImageException;
4167 Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
4168 const size_t columns_,const size_t rows_)
4175 result=(*QueueAuthenticPixels)(image(),x_,y_,columns_,rows_,exceptionInfo);
4176 ThrowImageException;
4180 void Magick::Image::shade(const double azimuth_,const double elevation_,
4181 const bool colorShading_)
4187 newImage=ShadeImage(constImage(),colorShading_ == true ?
4188 MagickTrue : MagickFalse,azimuth_,elevation_,exceptionInfo);
4189 replaceImage(newImage);
4190 ThrowImageException;
4193 void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
4194 const ssize_t x_,const ssize_t y_)
4200 newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
4202 replaceImage(newImage);
4203 ThrowImageException;
4206 void Magick::Image::sharpen(const double radius_,const double sigma_)
4212 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4213 replaceImage(newImage);
4214 ThrowImageException;
4217 void Magick::Image::sharpenChannel(const ChannelType channel_,
4218 const double radius_,const double sigma_)
4224 SetPPChannelMask(channel_);
4225 newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4226 RestorePPChannelMask;
4227 replaceImage(newImage);
4228 ThrowImageException;
4231 void Magick::Image::shave(const Geometry &geometry_)
4237 shaveInfo=geometry_;
4240 newImage=ShaveImage(constImage(),&shaveInfo,exceptionInfo);
4241 replaceImage(newImage);
4242 ThrowImageException;
4245 void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
4251 newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,exceptionInfo);
4252 replaceImage(newImage);
4253 ThrowImageException;
4256 void Magick::Image::sigmoidalContrast(const size_t sharpen_,
4257 const double contrast,const double midpoint)
4261 (void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
4262 midpoint,exceptionInfo);
4263 ThrowImageException;
4266 std::string Magick::Image::signature(const bool force_) const
4268 return(_imgRef->signature());
4271 void Magick::Image::sketch(const double radius_,const double sigma_,
4272 const double angle_)
4278 newImage=SketchImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
4279 replaceImage(newImage);
4280 ThrowImageException;
4283 void Magick::Image::solarize(const double factor_)
4287 SolarizeImage(image(),factor_,exceptionInfo);
4288 ThrowImageException;
4291 void Magick::Image::sparseColor(const ChannelType channel_,
4292 const SparseColorMethod method_,const size_t numberArguments_,
4293 const double *arguments_)
4299 SetPPChannelMask(channel_);
4300 newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
4302 RestorePPChannelMask;
4303 replaceImage(newImage);
4304 ThrowImageException;
4307 void Magick::Image::splice(const Geometry &geometry_)
4313 spliceInfo=geometry_;
4316 newImage=SpliceImage(constImage(),&spliceInfo,exceptionInfo);
4317 replaceImage(newImage);
4318 ThrowImageException;
4321 void Magick::Image::spread(const size_t amount_)
4327 newImage=SpreadImage(constImage(),amount_,image()->interpolate,
4329 replaceImage(newImage);
4330 ThrowImageException;
4333 Magick::ImageStatistics Magick::Image::statistics()
4335 return(ImageStatistics(*this));
4338 void Magick::Image::stegano(const Image &watermark_)
4344 newImage=SteganoImage(constImage(),watermark_.constImage(),exceptionInfo);
4345 replaceImage(newImage);
4346 ThrowImageException;
4349 void Magick::Image::stereo(const Image &rightImage_)
4355 newImage=StereoImage(constImage(),rightImage_.constImage(),exceptionInfo);
4356 replaceImage(newImage);
4357 ThrowImageException;
4360 void Magick::Image::strip(void)
4364 StripImage(image(),exceptionInfo);
4365 ThrowImageException;
4368 Magick::Image Magick::Image::subImageSearch(const Image &reference_,
4369 const MetricType metric_,Geometry *offset_,double *similarityMetric_,
4370 const double similarityThreshold)
4379 newImage=SimilarityImage(image(),reference_.constImage(),metric_,
4380 similarityThreshold,&offset,similarityMetric_,exceptionInfo);
4381 ThrowImageException;
4382 if (offset_ != (Geometry *) NULL)
4384 if (newImage == (MagickCore::Image *) NULL)
4385 return(Magick::Image());
4387 return(Magick::Image(newImage));
4390 void Magick::Image::swirl(const double degrees_)
4396 newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
4398 replaceImage(newImage);
4399 ThrowImageException;
4402 void Magick::Image::syncPixels(void)
4405 (void) (*SyncAuthenticPixels)(image(),exceptionInfo);
4406 ThrowImageException;
4409 void Magick::Image::texture(const Image &texture_)
4413 TextureImage(image(),texture_.constImage(),exceptionInfo);
4414 ThrowImageException;
4417 void Magick::Image::threshold(const double threshold_)
4421 BilevelImage(image(),threshold_,exceptionInfo);
4422 ThrowImageException;
4425 void Magick::Image::thumbnail(const Geometry &geometry_)
4438 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4442 newImage=ThumbnailImage(constImage(),width,height,exceptionInfo);
4443 replaceImage(newImage);
4444 ThrowImageException;
4447 void Magick::Image::tint(const std::string opacity_)
4456 color=static_cast<PixelInfo>(constOptions()->fillColor());
4457 newImage=TintImage(constImage(),opacity_.c_str(),&color,exceptionInfo);
4458 replaceImage(newImage);
4459 ThrowImageException;
4462 void Magick::Image::transform(const Geometry &imageGeometry_)
4466 TransformImage(&(image()),0,std::string(imageGeometry_).c_str(),
4468 ThrowImageException;
4471 void Magick::Image::transform(const Geometry &imageGeometry_,
4472 const Geometry &cropGeometry_)
4476 TransformImage(&(image()),std::string(cropGeometry_).c_str(),std::string(
4477 imageGeometry_).c_str(), exceptionInfo);
4478 ThrowImageException;
4481 void Magick::Image::transformOrigin(const double x_,const double y_)
4484 options()->transformOrigin(x_,y_);
4487 void Magick::Image::transformReset(void)
4490 options()->transformReset();
4493 void Magick::Image::transformScale(const double sx_,const double sy_)
4496 options()->transformScale(sx_,sy_);
4499 void Magick::Image::transparent(const Color &color_)
4507 if (!color_.isValid())
4508 throwExceptionExplicit(MagickCore::OptionError,
4509 "Color argument is invalid");
4513 (void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
4516 TransparentPaintImage(image(),&target,TransparentAlpha,MagickFalse,
4518 ThrowImageException;
4521 void Magick::Image::transparentChroma(const Color &colorLow_,
4522 const Color &colorHigh_)
4532 if (!colorLow_.isValid() || !colorHigh_.isValid())
4533 throwExceptionExplicit(MagickCore::OptionError,
4534 "Color argument is invalid");
4537 colorHigh=colorHigh_;
4540 (void) QueryColorCompliance(colorLow.c_str(),AllCompliance,&targetLow,
4542 (void) QueryColorCompliance(colorHigh.c_str(),AllCompliance,&targetHigh,
4545 TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
4546 MagickFalse,exceptionInfo);
4547 ThrowImageException;
4550 void Magick::Image::transpose(void)
4556 newImage=TransposeImage(constImage(),exceptionInfo);
4557 replaceImage(newImage);
4558 ThrowImageException;
4561 void Magick::Image::transverse(void)
4567 newImage=TransverseImage(constImage(),exceptionInfo);
4568 replaceImage(newImage);
4569 ThrowImageException;
4572 void Magick::Image::trim(void)
4578 newImage=TrimImage(constImage(),exceptionInfo);
4579 replaceImage(newImage);
4580 ThrowImageException;
4583 Magick::Image Magick::Image::uniqueColors(void)
4589 image=UniqueImageColors(constImage(),exceptionInfo);
4590 ThrowImageException;
4591 if (image == (MagickCore::Image *) NULL)
4592 return(Magick::Image());
4594 return(Magick::Image(image));
4597 void Magick::Image::unsharpmask(const double radius_,const double sigma_,
4598 const double amount_,const double threshold_)
4604 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4606 replaceImage(newImage);
4607 ThrowImageException;
4610 void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
4611 const double radius_,const double sigma_,const double amount_,
4612 const double threshold_)
4618 SetPPChannelMask(channel_);
4619 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4621 RestorePPChannelMask;
4622 replaceImage(newImage);
4623 ThrowImageException;
4626 void Magick::Image::vignette(const double radius_,const double sigma_,
4627 const ssize_t x_,const ssize_t y_)
4633 newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,exceptionInfo);
4634 replaceImage(newImage);
4635 ThrowImageException;
4638 void Magick::Image::wave(const double amplitude_,const double wavelength_)
4644 newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
4646 replaceImage(newImage);
4647 ThrowImageException;
4650 void Magick::Image::whiteThreshold(const std::string &threshold_)
4654 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4655 ThrowImageException;
4658 void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
4659 const std::string &threshold_)
4663 SetPPChannelMask(channel_);
4664 WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4665 RestorePPChannelMask;
4666 ThrowImageException;
4669 void Magick::Image::write(Blob *blob_)
4679 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4681 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4682 ThrowImageException;
4685 void Magick::Image::write(Blob *blob_,const std::string &magick_)
4696 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4698 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4699 ThrowImageException;
4702 void Magick::Image::write(Blob *blob_,const std::string &magick_,
4703 const size_t depth_)
4715 data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4717 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4718 ThrowImageException;
4721 void Magick::Image::write(const ssize_t x_,const ssize_t y_,
4722 const size_t columns_,const size_t rows_,const std::string &map_,
4723 const StorageType type_,void *pixels_)
4726 ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
4728 ThrowImageException;
4731 void Magick::Image::write(const std::string &imageSpec_)
4734 fileName(imageSpec_);
4736 WriteImage(constImageInfo(),image(),exceptionInfo);
4737 ThrowImageException;
4740 void Magick::Image::writePixels(const Magick::QuantumType quantum_,
4741 unsigned char *destination_)
4746 quantum_info=AcquireQuantumInfo(imageInfo(),image());
4748 ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4749 quantum_,destination_, exceptionInfo);
4750 quantum_info=DestroyQuantumInfo(quantum_info);
4751 ThrowImageException;
4754 void Magick::Image::zoom(const Geometry &geometry_)
4767 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4771 newImage=ResizeImage(constImage(),width,height,image()->filter,exceptionInfo);
4772 replaceImage(newImage);
4773 ThrowImageException;
4776 Magick::Image::Image(MagickCore::Image *image_)
4777 : _imgRef(new ImageRef(image_)),
4782 MagickCore::Image *&Magick::Image::image(void)
4784 return(_imgRef->image());
4787 const MagickCore::Image *Magick::Image::constImage(void) const
4789 return(_imgRef->image());
4792 MagickCore::ImageInfo *Magick::Image::imageInfo(void)
4794 return(_imgRef->options()->imageInfo());
4797 const MagickCore::ImageInfo *Magick::Image::constImageInfo(void) const
4799 return(_imgRef->options()->imageInfo());
4802 Magick::Options *Magick::Image::options(void)
4804 return(_imgRef->options());
4807 const Magick::Options *Magick::Image::constOptions(void) const
4809 return(_imgRef->options());
4812 MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)
4814 return(_imgRef->options()->quantizeInfo());
4817 const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
4819 return(_imgRef->options()->quantizeInfo());
4822 void Magick::Image::modifyImage(void)
4824 if (_imgRef->isOwner())
4828 replaceImage(CloneImage(image(),0,0,MagickTrue,exceptionInfo));
4829 ThrowImageException;
4832 MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
4842 image=AcquireImage(constImageInfo(),exceptionInfo);
4843 ThrowImageException;
4846 // We can replace the image if we own it.
4847 if (!_imgRef->replaceImage(image))
4849 // We don't own the image, dereference and replace with new reference
4850 if (_imgRef->decrease() == 0)
4853 _imgRef=new ImageRef(image,constOptions());
4859 void Magick::Image::read(MagickCore::Image *image,
4860 MagickCore::ExceptionInfo *exceptionInfo)
4862 // Ensure that multiple image frames were not read.
4863 if (image != (MagickCore::Image *) NULL &&
4864 image->next != (MagickCore::Image *) NULL)
4869 // Destroy any extra image frames
4871 image->next=(MagickCore::Image *) NULL;
4872 next->previous=(MagickCore::Image *) NULL;
4873 DestroyImageList(next);
4875 replaceImage(image);
4876 if (exceptionInfo->severity == MagickCore::UndefinedException &&
4877 image == (MagickCore::Image *) NULL)
4879 (void) MagickCore::DestroyExceptionInfo(exceptionInfo);
4881 throwExceptionExplicit(MagickCore::ImageWarning,
4882 "No image was loaded.");
4884 ThrowImageException;
4887 void Magick::Image::floodFill(const ssize_t x_,const ssize_t y_,
4888 const Magick::Image *fillPattern_,const Magick::Color &fill_,
4889 const MagickCore::PixelInfo *target_,const bool invert_)
4897 // Set drawing fill pattern or fill color
4898 fillColor=options()->fillColor();
4899 fillPattern=(MagickCore::Image *)NULL;
4900 if (options()->fillPattern() != (MagickCore::Image *)NULL)
4903 fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
4905 ThrowImageException;
4908 if (fillPattern_ == (Magick::Image *)NULL)
4910 options()->fillPattern((MagickCore::Image *)NULL);
4911 options()->fillColor(fill_);
4914 options()->fillPattern(fillPattern_->constImage());
4917 (void) FloodfillPaintImage(image(),options()->drawInfo(),
4918 target_,static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),
4919 (MagickBooleanType) invert_,exceptionInfo);
4921 options()->fillColor(fillColor);
4922 options()->fillPattern(fillPattern);
4923 ThrowImageException;