1 // This may look like C code, but it is really -*- C++ -*-
3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
5 // Implementation of Image
8 #define MAGICKCORE_IMPLEMENTATION 1
9 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
11 #include "Magick++/Include.h"
20 #include "Magick++/Image.h"
21 #include "Magick++/Functions.h"
22 #include "Magick++/Pixels.h"
23 #include "Magick++/Options.h"
24 #include "Magick++/ImageRef.h"
26 #define AbsoluteValue(x) ((x) < 0 ? -(x) : (x))
27 #define MagickPI 3.14159265358979323846264338327950288419716939937510
28 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
30 MagickPPExport const char *Magick::borderGeometryDefault="6x6+0+0";
31 MagickPPExport const char *Magick::frameGeometryDefault="25x25+6+6";
32 MagickPPExport const char *Magick::raiseGeometryDefault="6x6+0+0";
34 MagickPPExport int Magick::operator == (const Magick::Image &left_,
35 const Magick::Image &right_)
37 // If image pixels and signature are the same, then the image is identical
38 return((left_.rows() == right_.rows()) &&
39 (left_.columns() == right_.columns()) &&
40 (left_.signature() == right_.signature()));
43 MagickPPExport int Magick::operator != (const Magick::Image &left_,
44 const Magick::Image &right_)
46 return(!(left_ == right_));
49 MagickPPExport int Magick::operator > (const Magick::Image &left_,
50 const Magick::Image &right_)
52 return(!(left_ < right_) && (left_ != right_));
55 MagickPPExport int Magick::operator < (const Magick::Image &left_,
56 const Magick::Image &right_)
58 // If image pixels are less, then image is smaller
59 return((left_.rows() * left_.columns()) <
60 (right_.rows() * right_.columns()));
63 MagickPPExport int Magick::operator >= (const Magick::Image &left_,
64 const Magick::Image &right_)
66 return((left_ > right_) || (left_ == right_));
69 MagickPPExport int Magick::operator <= (const Magick::Image &left_,
70 const Magick::Image &right_)
72 return((left_ < right_) || ( left_ == right_));
75 Magick::Image::Image(void)
76 : _imgRef(new ImageRef)
80 Magick::Image::Image(const Blob &blob_)
81 : _imgRef(new ImageRef)
85 // Initialize, Allocate and Read images
88 catch(const Warning &/*warning_*/)
90 // FIXME: need a way to report warnings in constructor
92 catch (const Error &/*error_*/)
100 Magick::Image::Image(const Blob &blob_,const Geometry &size_)
101 : _imgRef(new ImageRef)
108 catch(const Warning &/*warning_*/)
110 // FIXME: need a way to report warnings in constructor
112 catch(const Error &/*error_*/)
120 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
122 : _imgRef(new ImageRef)
127 read(blob_,size_,depth_);
129 catch(const Warning &/*warning_*/)
131 // FIXME: need a way to report warnings in constructor
133 catch(const Error &/*error_*/)
141 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
142 const size_t depth_,const std::string &magick_)
143 : _imgRef(new ImageRef)
148 read(blob_,size_,depth_,magick_);
150 catch(const Warning &/*warning_*/)
152 // FIXME: need a way to report warnings in constructor
154 catch(const Error &/*error_*/)
162 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
163 const std::string &magick_)
164 : _imgRef(new ImageRef)
169 read(blob_,size_,magick_);
171 catch(const Warning &/*warning_*/)
173 // FIXME: need a way to report warnings in constructor
175 catch(const Error &/*error_*/)
183 Magick::Image::Image(const Geometry &size_,const Color &color_)
184 : _imgRef(new ImageRef)
186 // xc: prefix specifies an X11 color string
187 std::string imageSpec("xc:");
195 // Initialize, Allocate and Read images
198 catch(const Warning &/*warning_*/)
200 // FIXME: need a way to report warnings in constructor
202 catch(const Error & /*error_*/)
210 Magick::Image::Image(const Image &image_)
211 : _imgRef(image_._imgRef)
213 Lock(&_imgRef->_mutexLock);
215 // Increase reference count
216 ++_imgRef->_refCount;
219 Magick::Image::Image(const size_t width_,const size_t height_,
220 const std::string &map_,const StorageType type_,const void *pixels_)
221 : _imgRef(new ImageRef)
225 read(width_,height_,map_.c_str(),type_,pixels_);
227 catch(const Warning &/*warning_*/)
229 // FIXME: need a way to report warnings in constructor
231 catch(const Error &/*error_*/)
239 Magick::Image::Image(const std::string &imageSpec_)
240 : _imgRef(new ImageRef)
244 // Initialize, Allocate and Read images
247 catch(const Warning &/*warning_*/)
249 // FIXME: need a way to report warnings in constructor
251 catch(const Error &/*error_*/)
259 Magick::Image::~Image()
265 Lock(&_imgRef->_mutexLock);
266 if (--_imgRef->_refCount == 0)
276 Magick::Image& Magick::Image::operator=(const Magick::Image &image_)
284 Lock(&image_._imgRef->_mutexLock);
285 ++image_._imgRef->_refCount;
289 Lock(&_imgRef->_mutexLock);
290 if (--_imgRef->_refCount == 0)
296 // Delete old image reference with associated image and options.
300 // Use new image reference
301 _imgRef=image_._imgRef;
307 void Magick::Image::adjoin(const bool flag_)
310 options()->adjoin(flag_);
313 bool Magick::Image::adjoin(void) const
315 return(constOptions()->adjoin());
318 void Magick::Image::alpha(const bool matteFlag_)
322 // If matte channel is requested, but image doesn't already have a
323 // matte channel, then create an opaque matte channel. Likewise, if
324 // the image already has a matte channel but a matte channel is not
325 // desired, then set the matte channel to opaque.
327 if ((matteFlag_ && !constImage()->alpha_trait) ||
328 (constImage()->alpha_trait && !matteFlag_))
329 SetImageAlpha(image(),OpaqueAlpha,&exceptionInfo);
332 image()->alpha_trait=matteFlag_ ? BlendPixelTrait : UndefinedPixelTrait;
335 bool Magick::Image::alpha(void) const
337 if (constImage()->alpha_trait == BlendPixelTrait)
343 void Magick::Image::alphaColor(const Color &alphaColor_)
347 if (alphaColor_.isValid())
349 image()->matte_color=alphaColor_;
350 options()->matteColor(alphaColor_);
354 // Set to default matte color
355 Color tmpColor("#BDBDBD");
356 image()->matte_color=tmpColor;
357 options()->matteColor(tmpColor);
361 Magick::Color Magick::Image::alphaColor(void) const
363 return(Color(ClampToQuantum(constImage()->matte_color.red),
364 ClampToQuantum(constImage()->matte_color.green),
365 ClampToQuantum(constImage()->matte_color.blue)));
368 void Magick::Image::antiAlias(const bool flag_)
371 options()->antiAlias(static_cast<size_t>(flag_));
374 bool Magick::Image::antiAlias(void)
376 return(static_cast<bool>(options()->antiAlias()));
379 void Magick::Image::animationDelay(const size_t delay_)
382 image()->delay=delay_;
385 size_t Magick::Image::animationDelay(void) const
387 return(constImage()->delay);
390 void Magick::Image::animationIterations(const size_t iterations_)
393 image()->iterations=iterations_;
396 size_t Magick::Image::animationIterations(void) const
398 return(constImage()->iterations);
401 void Magick::Image::backgroundColor(const Color &backgroundColor_)
405 if (backgroundColor_.isValid())
406 image()->background_color=backgroundColor_;
408 image()->background_color=Color();
410 options()->backgroundColor(backgroundColor_);
413 Magick::Color Magick::Image::backgroundColor(void) const
415 return(constOptions()->backgroundColor());
418 void Magick::Image::backgroundTexture(const std::string &backgroundTexture_)
421 options()->backgroundTexture(backgroundTexture_);
424 std::string Magick::Image::backgroundTexture(void) const
426 return(constOptions()->backgroundTexture());
429 size_t Magick::Image::baseColumns(void) const
431 return(constImage()->magick_columns);
434 std::string Magick::Image::baseFilename(void) const
436 return(std::string(constImage()->magick_filename));
439 size_t Magick::Image::baseRows(void) const
441 return(constImage()->magick_rows);
444 void Magick::Image::borderColor(const Color &borderColor_)
448 if (borderColor_.isValid())
449 image()->border_color=borderColor_;
451 image()->border_color=Color();
453 options()->borderColor(borderColor_);
456 Magick::Color Magick::Image::borderColor(void) const
458 return(constOptions()->borderColor());
461 Magick::Geometry Magick::Image::boundingBox(void) const
467 bbox=GetImageBoundingBox(constImage(),&exceptionInfo);
469 return(Geometry(bbox));
472 void Magick::Image::boxColor(const Color &boxColor_)
475 options()->boxColor(boxColor_);
478 Magick::Color Magick::Image::boxColor(void) const
480 return(constOptions()->boxColor());
483 void Magick::Image::channelDepth(const size_t depth_)
487 SetImageDepth(image(),depth_,&exceptionInfo);
491 size_t Magick::Image::channelDepth()
497 channel_depth=GetImageDepth(constImage(),&exceptionInfo);
499 return(channel_depth);
502 size_t Magick::Image::channels() const
504 return(constImage()->number_channels);
507 void Magick::Image::classType(const ClassType class_)
509 if (classType() == PseudoClass && class_ == DirectClass)
511 // Use SyncImage to synchronize the DirectClass pixels with the
512 // color map and then set to DirectClass type.
515 SyncImage(image(),&exceptionInfo);
517 image()->colormap=(PixelInfo *)RelinquishMagickMemory(image()->colormap);
518 image()->storage_class=static_cast<MagickCore::ClassType>(DirectClass);
522 if (classType() == DirectClass && class_ == PseudoClass)
524 // Quantize to create PseudoClass color map
526 quantizeColors(MaxColormapSize);
528 image()->storage_class=static_cast<MagickCore::ClassType>(PseudoClass);
532 Magick::ClassType Magick::Image::classType(void) const
534 return static_cast<Magick::ClassType>(constImage()->storage_class);
537 void Magick::Image::clipMask(const Magick::Image &clipMask_)
542 if (clipMask_.isValid())
543 SetImageMask(image(),clipMask_.constImage(),&exceptionInfo);
545 SetImageMask(image(),0,&exceptionInfo);
549 Magick::Image Magick::Image::clipMask(void) const
555 image=GetImageMask(constImage(),&exceptionInfo);
557 if (image == (MagickCore::Image *) NULL)
558 return(Magick::Image());
560 return(Magick::Image(image));
563 void Magick::Image::colorFuzz(const double fuzz_)
567 options()->colorFuzz(fuzz_);
570 double Magick::Image::colorFuzz(void) const
572 return(constOptions()->colorFuzz());
575 void Magick::Image::colorMapSize(const size_t entries_)
577 if (entries_ >MaxColormapSize)
578 throwExceptionExplicit(OptionError,
579 "Colormap entries must not exceed MaxColormapSize");
583 AcquireImageColormap(image(),entries_,&exceptionInfo);
587 size_t Magick::Image::colorMapSize(void) const
589 if (!constImage()->colormap)
590 throwExceptionExplicit(OptionError,"Image does not contain a colormap");
592 return(constImage()->colors);
595 void Magick::Image::colorSpace(const ColorspaceType colorSpace_)
597 if (image()->colorspace == colorSpace_)
602 TransformImageColorspace(image(),colorSpace_,&exceptionInfo);
606 Magick::ColorspaceType Magick::Image::colorSpace(void) const
608 return (constImage()->colorspace);
611 void Magick::Image::colorSpaceType(const ColorspaceType colorSpace_)
615 SetImageColorspace(image(),colorSpace_,&exceptionInfo);
617 options()->colorspaceType(colorSpace_);
620 Magick::ColorspaceType Magick::Image::colorSpaceType(void) const
622 return(constOptions()->colorspaceType());
625 size_t Magick::Image::columns(void) const
627 return(constImage()->columns);
630 void Magick::Image::comment(const std::string &comment_)
634 SetImageProperty(image(),"Comment",NULL,&exceptionInfo);
635 if (comment_.length() > 0)
636 SetImageProperty(image(),"Comment",comment_.c_str(),&exceptionInfo);
640 std::string Magick::Image::comment(void) const
646 value=GetImageProperty(constImage(),"Comment",&exceptionInfo);
650 return(std::string(value));
652 return(std::string()); // Intentionally no exception
655 void Magick::Image::compose(const CompositeOperator compose_)
657 image()->compose=compose_;
660 Magick::CompositeOperator Magick::Image::compose(void) const
662 return(constImage()->compose);
665 void Magick::Image::compressType(const CompressionType compressType_)
668 image()->compression=compressType_;
669 options()->compressType(compressType_);
672 Magick::CompressionType Magick::Image::compressType(void) const
674 return(constImage()->compression);
677 void Magick::Image::debug(const bool flag_)
680 options()->debug(flag_);
683 bool Magick::Image::debug(void) const
685 return(constOptions()->debug());
688 void Magick::Image::density(const Geometry &density_)
691 options()->density(density_);
692 if (density_.isValid())
694 image()->resolution.x=density_.width();
695 if (density_.height() != 0)
696 image()->resolution.y=density_.height();
698 image()->resolution.y=density_.width();
703 image()->resolution.x=0;
704 image()->resolution.y=0;
708 Magick::Geometry Magick::Image::density(void) const
716 if (constImage()->resolution.x > 0.0)
717 x_resolution=static_cast<ssize_t>(constImage()->resolution.x + 0.5);
719 if (constImage()->resolution.y > 0.0)
720 y_resolution=static_cast<ssize_t>(constImage()->resolution.y + 0.5);
722 return(Geometry(x_resolution,y_resolution));
725 return(constOptions()->density());
728 void Magick::Image::depth(const size_t depth_)
733 if (depth > MAGICKCORE_QUANTUM_DEPTH)
734 depth=MAGICKCORE_QUANTUM_DEPTH;
737 image()->depth=depth;
738 options()->depth(depth);
741 size_t Magick::Image::depth(void) const
743 return(constImage()->depth);
746 std::string Magick::Image::directory(void) const
748 if (constImage()->directory)
749 return(std::string(constImage()->directory));
751 throwExceptionExplicit(CorruptImageWarning,
752 "Image does not contain a directory");
754 return(std::string());
757 void Magick::Image::endian(const Magick::EndianType endian_)
760 options()->endian(endian_);
761 image()->endian=endian_;
764 Magick::EndianType Magick::Image::endian(void) const
766 return(constImage()->endian);
769 void Magick::Image::exifProfile(const Magick::Blob &exifProfile_)
773 if (exifProfile_.data() != 0)
778 exif_profile=AcquireStringInfo(exifProfile_.length());
779 SetStringInfoDatum(exif_profile,(unsigned char *) exifProfile_.data());
781 (void) SetImageProfile(image(),"exif",exif_profile,&exceptionInfo);
782 exif_profile=DestroyStringInfo(exif_profile);
787 Magick::Blob Magick::Image::exifProfile(void) const
792 exif_profile=GetImageProfile(constImage(),"exif");
793 if (exif_profile == (StringInfo *) NULL)
795 return(Blob(GetStringInfoDatum(exif_profile),
796 GetStringInfoLength(exif_profile)));
799 void Magick::Image::fileName(const std::string &fileName_)
803 fileName_.copy(image()->filename,sizeof(image()->filename)-1);
804 image()->filename[fileName_.length()]=0; // Null terminate
806 options()->fileName(fileName_);
809 std::string Magick::Image::fileName(void) const
811 return(constOptions()->fileName());
814 MagickCore::MagickSizeType Magick::Image::fileSize(void) const
816 return(GetBlobSize(constImage()));
819 void Magick::Image::fillColor(const Magick::Color &fillColor_)
822 options()->fillColor(fillColor_);
825 Magick::Color Magick::Image::fillColor(void) const
827 return(constOptions()->fillColor());
830 void Magick::Image::fillRule(const Magick::FillRule &fillRule_)
833 options()->fillRule(fillRule_);
836 Magick::FillRule Magick::Image::fillRule(void) const
838 return constOptions()->fillRule();
841 void Magick::Image::fillPattern(const Image &fillPattern_)
844 if (fillPattern_.isValid())
845 options()->fillPattern(fillPattern_.constImage());
847 options()->fillPattern(static_cast<MagickCore::Image*>(NULL));
850 Magick::Image Magick::Image::fillPattern(void) const
852 // FIXME: This is inordinately innefficient
853 const MagickCore::Image
859 tmpTexture=constOptions()->fillPattern();
867 image=CloneImage(tmpTexture,0,0,MagickTrue,&exceptionInfo);
868 texture.replaceImage(image);
874 void Magick::Image::filterType(const Magick::FilterTypes filterType_)
877 image()->filter=filterType_;
880 Magick::FilterTypes Magick::Image::filterType(void) const
882 return(constImage()->filter);
885 void Magick::Image::font(const std::string &font_)
888 options()->font(font_);
891 std::string Magick::Image::font(void) const
893 return(constOptions()->font());
896 void Magick::Image::fontPointsize(const double pointSize_)
899 options()->fontPointsize(pointSize_);
902 double Magick::Image::fontPointsize(void) const
904 return(constOptions()->fontPointsize());
907 std::string Magick::Image::format(void) const
913 magick_info=GetMagickInfo(constImage()->magick,&exceptionInfo);
916 if ((magick_info != 0) && (*magick_info->description != '\0'))
917 return(std::string(magick_info->description));
919 throwExceptionExplicit(CorruptImageWarning,"Unrecognized image magick type");
920 return(std::string());
923 std::string Magick::Image::formatExpression(const std::string expression)
932 text=InterpretImageProperties(imageInfo(),image(),expression.c_str(),
934 if (text != (char *) NULL)
936 result=std::string(text);
937 text=DestroyString(text);
943 double Magick::Image::gamma(void) const
945 return(constImage()->gamma);
948 Magick::Geometry Magick::Image::geometry(void) const
950 if (constImage()->geometry)
951 return Geometry(constImage()->geometry);
953 throwExceptionExplicit(OptionWarning,"Image does not contain a geometry");
958 void Magick::Image::gifDisposeMethod(
959 const MagickCore::DisposeType disposeMethod_)
962 image()->dispose=disposeMethod_;
965 MagickCore::DisposeType Magick::Image::gifDisposeMethod(void) const
967 return(constImage()->dispose);
970 void Magick::Image::iccColorProfile(const Magick::Blob &colorProfile_)
972 profile("icm",colorProfile_);
975 Magick::Blob Magick::Image::iccColorProfile(void) const
980 color_profile=GetImageProfile(constImage(),"icc");
981 if (color_profile == (StringInfo *) NULL)
983 return(Blob(GetStringInfoDatum(color_profile),GetStringInfoLength(
987 void Magick::Image::interlaceType(const Magick::InterlaceType interlace_)
990 image()->interlace=interlace_;
991 options()->interlaceType(interlace_);
994 Magick::InterlaceType Magick::Image::interlaceType(void) const
996 return(constImage()->interlace);
999 void Magick::Image::interpolate(const PixelInterpolateMethod interpolate_)
1002 image()->interpolate=interpolate_;
1005 Magick::PixelInterpolateMethod Magick::Image::interpolate(void) const
1007 return constImage()->interpolate;
1010 void Magick::Image::iptcProfile(const Magick::Blob &iptcProfile_)
1013 if (iptcProfile_.data() != 0)
1018 iptc_profile=AcquireStringInfo(iptcProfile_.length());
1019 SetStringInfoDatum(iptc_profile,(unsigned char *) iptcProfile_.data());
1021 (void) SetImageProfile(image(),"iptc",iptc_profile,&exceptionInfo);
1022 iptc_profile=DestroyStringInfo(iptc_profile);
1027 Magick::Blob Magick::Image::iptcProfile(void) const
1032 iptc_profile=GetImageProfile(constImage(),"iptc");
1033 if (iptc_profile == (StringInfo *) NULL)
1035 return(Blob(GetStringInfoDatum(iptc_profile),GetStringInfoLength(
1039 void Magick::Image::isValid(const bool isValid_)
1044 _imgRef=new ImageRef;
1046 else if (!isValid())
1048 // Construct with single-pixel black image to make
1049 // image valid. This is an obvious hack.
1050 size(Geometry(1,1));
1055 bool Magick::Image::isValid(void) const
1057 return rows() && columns();
1060 void Magick::Image::label(const std::string &label_)
1064 SetImageProperty(image(),"Label",NULL,&exceptionInfo);
1065 if (label_.length() > 0)
1066 SetImageProperty(image(),"Label",label_.c_str(),&exceptionInfo);
1070 std::string Magick::Image::label(void) const
1076 value=GetImageProperty(constImage(),"Label",&exceptionInfo);
1080 return(std::string(value));
1082 return(std::string());
1085 void Magick::Image::magick(const std::string &magick_)
1089 magick_.copy(image()->magick,sizeof(image()->magick)-1);
1090 image()->magick[magick_.length()]=0;
1092 options()->magick(magick_);
1095 std::string Magick::Image::magick(void) const
1097 if (*(constImage()->magick) != '\0')
1098 return(std::string(constImage()->magick));
1100 return(constOptions()->magick());
1103 double Magick::Image::meanErrorPerPixel(void) const
1105 return(constImage()->error.mean_error_per_pixel);
1108 void Magick::Image::modulusDepth(const size_t depth_)
1112 SetImageDepth(image(),depth_,&exceptionInfo);
1114 options()->depth(depth_);
1117 size_t Magick::Image::modulusDepth(void) const
1123 depth=GetImageDepth(constImage(),&exceptionInfo);
1128 void Magick::Image::monochrome(const bool monochromeFlag_)
1131 options()->monochrome(monochromeFlag_);
1134 bool Magick::Image::monochrome(void) const
1136 return(constOptions()->monochrome());
1139 Magick::Geometry Magick::Image::montageGeometry(void) const
1141 if (constImage()->montage)
1142 return Magick::Geometry(constImage()->montage);
1144 throwExceptionExplicit(CorruptImageWarning,
1145 "Image does not contain a montage");
1147 return(Magick::Geometry());
1150 double Magick::Image::normalizedMaxError(void) const
1152 return(constImage()->error.normalized_maximum_error);
1155 double Magick::Image::normalizedMeanError(void) const
1157 return(constImage()->error.normalized_mean_error);
1160 void Magick::Image::orientation(const Magick::OrientationType orientation_)
1163 image()->orientation=orientation_;
1166 Magick::OrientationType Magick::Image::orientation(void) const
1168 return(constImage()->orientation);
1171 void Magick::Image::page(const Magick::Geometry &pageSize_)
1174 options()->page(pageSize_);
1175 image()->page=pageSize_;
1178 Magick::Geometry Magick::Image::page(void) const
1180 return(Geometry(constImage()->page.width,constImage()->page.height,
1181 AbsoluteValue(constImage()->page.x),AbsoluteValue(constImage()->page.y),
1182 constImage()->page.x < 0 ? true : false,
1183 constImage()->page.y < 0 ? true : false));
1186 void Magick::Image::quality(const size_t quality_)
1189 image()->quality=quality_;
1190 options()->quality(quality_);
1193 size_t Magick::Image::quality(void) const
1195 return(constImage()->quality);
1198 void Magick::Image::quantizeColors(const size_t colors_)
1201 options()->quantizeColors(colors_);
1204 size_t Magick::Image::quantizeColors(void) const
1206 return(constOptions()->quantizeColors());
1209 void Magick::Image::quantizeColorSpace(
1210 const Magick::ColorspaceType colorSpace_)
1213 options()->quantizeColorSpace(colorSpace_);
1216 Magick::ColorspaceType Magick::Image::quantizeColorSpace(void) const
1218 return(constOptions()->quantizeColorSpace());
1221 void Magick::Image::quantizeDither(const bool ditherFlag_)
1224 options()->quantizeDither(ditherFlag_);
1227 bool Magick::Image::quantizeDither(void) const
1229 return(constOptions()->quantizeDither());
1232 void Magick::Image::quantizeDitherMethod(const DitherMethod ditherMethod_)
1235 options()->quantizeDitherMethod(ditherMethod_);
1238 MagickCore::DitherMethod Magick::Image::quantizeDitherMethod(void) const
1240 return(constOptions()->quantizeDitherMethod());
1243 void Magick::Image::quantizeTreeDepth(const size_t treeDepth_)
1246 options()->quantizeTreeDepth(treeDepth_);
1249 size_t Magick::Image::quantizeTreeDepth() const
1251 return(constOptions()->quantizeTreeDepth());
1254 void Magick::Image::renderingIntent(
1255 const Magick::RenderingIntent renderingIntent_)
1258 image()->rendering_intent=renderingIntent_;
1261 Magick::RenderingIntent Magick::Image::renderingIntent(void) const
1263 return(static_cast<Magick::RenderingIntent>(constImage()->rendering_intent));
1266 void Magick::Image::resolutionUnits(
1267 const Magick::ResolutionType resolutionUnits_)
1270 image()->units=resolutionUnits_;
1271 options()->resolutionUnits(resolutionUnits_);
1274 Magick::ResolutionType Magick::Image::resolutionUnits(void) const
1276 return(constOptions()->resolutionUnits());
1279 size_t Magick::Image::rows(void) const
1281 return(constImage()->rows);
1284 void Magick::Image::scene(const size_t scene_)
1287 image()->scene=scene_;
1290 size_t Magick::Image::scene(void) const
1292 return(constImage()->scene);
1295 void Magick::Image::size(const Geometry &geometry_)
1298 options()->size(geometry_);
1299 image()->rows=geometry_.height();
1300 image()->columns=geometry_.width();
1303 Magick::Geometry Magick::Image::size(void) const
1305 return(Magick::Geometry(constImage()->columns,constImage()->rows));
1308 void Magick::Image::strokeAntiAlias(const bool flag_)
1311 options()->strokeAntiAlias(flag_);
1314 bool Magick::Image::strokeAntiAlias(void) const
1316 return(constOptions()->strokeAntiAlias());
1319 void Magick::Image::strokeColor(const Magick::Color &strokeColor_)
1322 options()->strokeColor(strokeColor_);
1325 Magick::Color Magick::Image::strokeColor(void) const
1327 return(constOptions()->strokeColor());
1330 void Magick::Image::strokeDashArray(const double *strokeDashArray_)
1333 options()->strokeDashArray(strokeDashArray_);
1336 const double* Magick::Image::strokeDashArray(void) const
1338 return(constOptions()->strokeDashArray());
1341 void Magick::Image::strokeDashOffset(const double strokeDashOffset_)
1344 options()->strokeDashOffset(strokeDashOffset_);
1347 double Magick::Image::strokeDashOffset(void) const
1349 return(constOptions()->strokeDashOffset());
1352 void Magick::Image::strokeLineCap(const Magick::LineCap lineCap_)
1355 options()->strokeLineCap(lineCap_);
1358 Magick::LineCap Magick::Image::strokeLineCap(void) const
1360 return(constOptions()->strokeLineCap());
1363 void Magick::Image::strokeLineJoin(const Magick::LineJoin lineJoin_)
1366 options()->strokeLineJoin(lineJoin_);
1369 Magick::LineJoin Magick::Image::strokeLineJoin(void) const
1371 return(constOptions()->strokeLineJoin());
1374 void Magick::Image::strokeMiterLimit(const size_t strokeMiterLimit_)
1377 options()->strokeMiterLimit(strokeMiterLimit_);
1380 size_t Magick::Image::strokeMiterLimit(void) const
1382 return(constOptions()->strokeMiterLimit());
1385 void Magick::Image::strokePattern(const Image &strokePattern_)
1388 if(strokePattern_.isValid())
1389 options()->strokePattern(strokePattern_.constImage());
1391 options()->strokePattern(static_cast<MagickCore::Image*>(NULL));
1394 Magick::Image Magick::Image::strokePattern(void) const
1396 // FIXME: This is inordinately innefficient
1397 const MagickCore::Image
1403 tmpTexture=constOptions()->strokePattern();
1411 image=CloneImage(tmpTexture,0,0,MagickTrue,&exceptionInfo);
1412 texture.replaceImage(image);
1418 void Magick::Image::strokeWidth(const double strokeWidth_)
1421 options()->strokeWidth(strokeWidth_);
1424 double Magick::Image::strokeWidth(void) const
1426 return(constOptions()->strokeWidth());
1429 void Magick::Image::subImage(const size_t subImage_)
1432 options()->subImage(subImage_);
1435 size_t Magick::Image::subImage(void) const
1437 return(constOptions()->subImage());
1440 void Magick::Image::subRange(const size_t subRange_)
1443 options()->subRange(subRange_);
1446 size_t Magick::Image::subRange(void) const
1448 return(constOptions()->subRange());
1451 void Magick::Image::textDirection(DirectionType direction_)
1454 options()->textDirection(direction_);
1457 Magick::DirectionType Magick::Image::textDirection(void) const
1459 return(constOptions()->textDirection());
1462 void Magick::Image::textEncoding(const std::string &encoding_)
1465 options()->textEncoding(encoding_);
1468 std::string Magick::Image::textEncoding(void) const
1470 return(constOptions()->textEncoding());
1473 void Magick::Image::textGravity(GravityType gravity_)
1476 options()->textGravity(gravity_);
1479 Magick::GravityType Magick::Image::textGravity(void) const
1481 return(constOptions()->textGravity());
1484 void Magick::Image::textInterlineSpacing(double spacing_)
1487 options()->textInterlineSpacing(spacing_);
1490 double Magick::Image::textInterlineSpacing(void) const
1492 return(constOptions()->textInterlineSpacing());
1495 void Magick::Image::textInterwordSpacing(double spacing_)
1498 options()->textInterwordSpacing(spacing_);
1501 double Magick::Image::textInterwordSpacing(void) const
1503 return(constOptions()->textInterwordSpacing());
1506 void Magick::Image::textKerning(double kerning_)
1509 options()->textKerning(kerning_);
1512 double Magick::Image::textKerning(void) const
1514 return(constOptions()->textKerning());
1517 size_t Magick::Image::totalColors(void) const
1523 colors=GetNumberColors(constImage(),0,&exceptionInfo);
1528 void Magick::Image::transformRotation(const double angle_)
1531 options()->transformRotation(angle_);
1534 void Magick::Image::transformSkewX(const double skewx_)
1537 options()->transformSkewX(skewx_);
1540 void Magick::Image::transformSkewY(const double skewy_)
1543 options()->transformSkewY(skewy_);
1546 Magick::ImageType Magick::Image::type(void) const
1552 image_type=constOptions()->type();
1553 if (image_type == UndefinedType)
1554 image_type=GetImageType(constImage(),&exceptionInfo);
1559 void Magick::Image::type(const Magick::ImageType type_)
1562 options()->type(type_);
1564 SetImageType(image(),type_,&exceptionInfo);
1568 void Magick::Image::verbose(const bool verboseFlag_)
1571 options()->verbose(verboseFlag_);
1574 bool Magick::Image::verbose(void) const
1576 return(constOptions()->verbose());
1579 void Magick::Image::view(const std::string &view_)
1582 options()->view(view_);
1585 std::string Magick::Image::view(void) const
1587 return(constOptions()->view());
1590 void Magick::Image::virtualPixelMethod(
1591 const VirtualPixelMethod virtualPixelMethod_)
1595 SetImageVirtualPixelMethod(image(),virtualPixelMethod_,&exceptionInfo);
1599 Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod(void) const
1601 return(GetImageVirtualPixelMethod(constImage()));
1604 void Magick::Image::x11Display(const std::string &display_)
1607 options()->x11Display(display_);
1610 std::string Magick::Image::x11Display(void) const
1612 return(constOptions()->x11Display());
1615 double Magick::Image::xResolution(void) const
1617 return(constImage()->resolution.x);
1620 double Magick::Image::yResolution(void) const
1622 return(constImage()->resolution.y);
1625 void Magick::Image::adaptiveBlur(const double radius_,const double sigma_)
1631 newImage=AdaptiveBlurImage(constImage(),radius_,sigma_,&exceptionInfo);
1632 replaceImage(newImage);
1636 void Magick::Image::adaptiveResize(const Geometry &geometry_)
1649 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
1653 newImage=AdaptiveResizeImage(constImage(),width,height,&exceptionInfo);
1654 replaceImage(newImage);
1658 void Magick::Image::adaptiveSharpen(const double radius_,const double sigma_)
1664 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,&exceptionInfo);
1665 replaceImage(newImage);
1669 void Magick::Image::adaptiveSharpenChannel(const ChannelType channel_,
1670 const double radius_,const double sigma_ )
1676 SetPPChannelMask(channel_);
1677 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,&exceptionInfo);
1678 RestorePPChannelMask;
1679 replaceImage(newImage);
1683 void Magick::Image::adaptiveThreshold(const size_t width_,const size_t height_,
1684 const ssize_t offset_)
1691 newImage=AdaptiveThresholdImage(constImage(),width_,height_,offset_,
1693 replaceImage(newImage);
1697 void Magick::Image::addNoise(const NoiseType noiseType_)
1703 newImage=AddNoiseImage(constImage(),noiseType_,1.0,&exceptionInfo);
1704 replaceImage(newImage);
1708 void Magick::Image::addNoiseChannel(const ChannelType channel_,
1709 const NoiseType noiseType_)
1715 SetPPChannelMask(channel_);
1716 newImage=AddNoiseImage(constImage(),noiseType_,1.0,&exceptionInfo);
1717 RestorePPChannelMask;
1718 replaceImage(newImage);
1722 void Magick::Image::affineTransform(const DrawableAffine &affine_)
1730 _affine.sx=affine_.sx();
1731 _affine.sy=affine_.sy();
1732 _affine.rx=affine_.rx();
1733 _affine.ry=affine_.ry();
1734 _affine.tx=affine_.tx();
1735 _affine.ty=affine_.ty();
1738 newImage=AffineTransformImage(constImage(),&_affine,&exceptionInfo);
1739 replaceImage(newImage);
1743 void Magick::Image::alpha(const unsigned int alpha_)
1747 SetImageAlpha(image(),alpha_,&exceptionInfo);
1751 void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
1755 SetImageAlphaChannel(image(),alphaOption_,&exceptionInfo);
1759 void Magick::Image::alphaFloodfill(const Color &target_,
1760 const unsigned int alpha_,const ssize_t x_,const ssize_t y_,
1761 const Magick::PaintMethod method_)
1767 GetPixelInfo(constImage(),&target);
1768 target.red=static_cast<PixelInfo>(target_).red;
1769 target.green=static_cast<PixelInfo>(target_).green;
1770 target.blue=static_cast<PixelInfo>(target_).blue;
1771 target.alpha=alpha_;
1773 SetPPChannelMask(AlphaChannel);
1774 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
1775 method_ == FloodfillMethod ? MagickFalse : MagickTrue,&exceptionInfo);
1776 RestorePPChannelMask;
1780 void Magick::Image::annotate(const std::string &text_,
1781 const Geometry &location_)
1783 annotate(text_,location_,NorthWestGravity,0.0);
1786 void Magick::Image::annotate(const std::string &text_,
1787 const Geometry &boundingArea_,const GravityType gravity_)
1789 annotate(text_,boundingArea_,gravity_,0.0);
1792 void Magick::Image::annotate(const std::string &text_,
1793 const Geometry &boundingArea_,const GravityType gravity_,
1794 const double degrees_)
1800 boundingArea[MaxTextExtent];
1807 drawInfo=options()->drawInfo();
1808 drawInfo->text=const_cast<char *>(text_.c_str());
1809 drawInfo->geometry=0;
1811 if (boundingArea_.isValid())
1813 if (boundingArea_.width() == 0 || boundingArea_.height() == 0)
1815 FormatLocaleString(boundingArea,MaxTextExtent,"%+.20g%+.20g",
1816 (double) boundingArea_.xOff(),(double) boundingArea_.yOff());
1820 (void) CopyMagickString(boundingArea,string(boundingArea_).c_str(),
1823 drawInfo->geometry=boundingArea;
1826 drawInfo->gravity=gravity_;
1828 oaffine=drawInfo->affine;
1829 if (degrees_ != 0.0)
1842 current=drawInfo->affine;
1843 affine.sx=cos(DegreesToRadians(fmod(degrees_,360.0)));
1844 affine.rx=sin(DegreesToRadians(fmod(degrees_,360.0)));
1845 affine.ry=(-sin(DegreesToRadians(fmod(degrees_,360.0))));
1846 affine.sy=cos(DegreesToRadians(fmod(degrees_,360.0)));
1848 drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
1849 drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
1850 drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
1851 drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
1852 drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty
1857 AnnotateImage(image(),drawInfo,&exceptionInfo);
1859 // Restore original values
1860 drawInfo->affine=oaffine;
1862 drawInfo->geometry=0;
1867 void Magick::Image::annotate(const std::string &text_,
1868 const GravityType gravity_)
1875 drawInfo=options()->drawInfo();
1876 drawInfo->text=const_cast<char *>(text_.c_str());
1877 drawInfo->gravity=gravity_;
1880 AnnotateImage(image(),drawInfo,&exceptionInfo);
1882 drawInfo->gravity=NorthWestGravity;
1888 void Magick::Image::artifact(const std::string &name_,const std::string &value_)
1891 (void) SetImageArtifact(image(),name_.c_str(),value_.c_str());
1894 std::string Magick::Image::artifact(const std::string &name_)
1899 value=GetImageArtifact(constImage(),name_.c_str());
1901 return(std::string(value));
1902 return(std::string());
1905 void Magick::Image::attribute(const std::string name_,const std::string value_)
1909 SetImageProperty(image(),name_.c_str(),value_.c_str(),&exceptionInfo);
1913 std::string Magick::Image::attribute(const std::string name_)
1919 value=GetImageProperty(constImage(),name_.c_str(),&exceptionInfo);
1923 return(std::string(value));
1925 return(std::string()); // Intentionally no exception
1928 void Magick::Image::autoGamma(void)
1932 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
1933 (void) AutoGammaImage(image(),&exceptionInfo);
1937 void Magick::Image::autoGammaChannel(const ChannelType channel_)
1941 SetPPChannelMask(channel_);
1942 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
1943 (void) AutoGammaImage(image(),&exceptionInfo);
1944 RestorePPChannelMask;
1948 void Magick::Image::autoLevel(void)
1952 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
1953 (void) AutoLevelImage(image(),&exceptionInfo);
1957 void Magick::Image::autoLevelChannel(const ChannelType channel_)
1961 SetPPChannelMask(channel_);
1962 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
1963 (void) AutoLevelImage(image(),&exceptionInfo);
1964 RestorePPChannelMask;
1968 void Magick::Image::autoOrient(void)
1973 if (image()->orientation == UndefinedOrientation ||
1974 image()->orientation == TopLeftOrientation)
1978 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
1979 newImage=AutoOrientImage(constImage(),image()->orientation,&exceptionInfo);
1980 replaceImage(newImage);
1984 void Magick::Image::blackThreshold(const std::string &threshold_)
1988 BlackThresholdImage(image(),threshold_.c_str(),&exceptionInfo);
1992 void Magick::Image::blackThresholdChannel(const ChannelType channel_,
1993 const std::string &threshold_)
1997 SetPPChannelMask(channel_);
1998 BlackThresholdImage(image(),threshold_.c_str(),&exceptionInfo);
1999 RestorePPChannelMask;
2003 void Magick::Image::blueShift(const double factor_)
2009 newImage=BlueShiftImage(constImage(),factor_,&exceptionInfo);
2010 replaceImage(newImage);
2014 void Magick::Image::blur(const double radius_,const double sigma_)
2020 newImage=BlurImage(constImage(),radius_,sigma_,&exceptionInfo);
2021 replaceImage(newImage);
2025 void Magick::Image::blurChannel(const ChannelType channel_,
2026 const double radius_,const double sigma_)
2032 SetPPChannelMask(channel_);
2033 newImage=BlurImage(constImage(),radius_,sigma_,&exceptionInfo);
2034 RestorePPChannelMask;
2035 replaceImage(newImage);
2039 void Magick::Image::border(const Geometry &geometry_)
2045 borderInfo=geometry_;
2048 newImage=BorderImage(constImage(),&borderInfo,image()->compose,
2050 replaceImage(newImage);
2054 void Magick::Image::brightnessContrast(const double brightness_,
2055 const double contrast_)
2059 BrightnessContrastImage(image(),brightness_,contrast_,&exceptionInfo);
2063 void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
2064 const double brightness_,const double contrast_)
2068 SetPPChannelMask(channel_);
2069 BrightnessContrastImage(image(),brightness_,contrast_,&exceptionInfo);
2070 RestorePPChannelMask;
2074 void Magick::Image::channel(const ChannelType channel_)
2080 newImage=SeparateImage(image(),channel_,&exceptionInfo);
2081 replaceImage(newImage);
2085 void Magick::Image::charcoal(const double radius_,const double sigma_)
2091 newImage=CharcoalImage(image(),radius_,sigma_,&exceptionInfo);
2092 replaceImage(newImage);
2096 void Magick::Image::chop(const Geometry &geometry_)
2105 newImage=ChopImage(image(),&chopInfo,&exceptionInfo);
2106 replaceImage(newImage);
2110 void Magick::Image::chromaBluePrimary(const double x_,const double y_)
2113 image()->chromaticity.blue_primary.x=x_;
2114 image()->chromaticity.blue_primary.y=y_;
2117 void Magick::Image::chromaBluePrimary(double *x_,double *y_) const
2119 *x_=constImage()->chromaticity.blue_primary.x;
2120 *y_=constImage()->chromaticity.blue_primary.y;
2123 void Magick::Image::chromaGreenPrimary(const double x_,const double y_)
2126 image()->chromaticity.green_primary.x=x_;
2127 image()->chromaticity.green_primary.y=y_;
2130 void Magick::Image::chromaGreenPrimary(double *x_,double *y_) const
2132 *x_=constImage()->chromaticity.green_primary.x;
2133 *y_=constImage()->chromaticity.green_primary.y;
2136 void Magick::Image::chromaRedPrimary(const double x_,const double y_)
2139 image()->chromaticity.red_primary.x=x_;
2140 image()->chromaticity.red_primary.y=y_;
2143 void Magick::Image::chromaRedPrimary(double *x_,double *y_) const
2145 *x_=constImage()->chromaticity.red_primary.x;
2146 *y_=constImage()->chromaticity.red_primary.y;
2149 void Magick::Image::chromaWhitePoint(const double x_,const double y_)
2152 image()->chromaticity.white_point.x=x_;
2153 image()->chromaticity.white_point.y=y_;
2156 void Magick::Image::chromaWhitePoint(double *x_,double *y_) const
2158 *x_=constImage()->chromaticity.white_point.x;
2159 *y_=constImage()->chromaticity.white_point.y;
2162 void Magick::Image::cdl(const std::string &cdl_)
2166 (void) ColorDecisionListImage(image(),cdl_.c_str(),&exceptionInfo);
2170 void Magick::Image::clamp(void)
2174 ClampImage(image(),&exceptionInfo);
2178 void Magick::Image::clampChannel(const ChannelType channel_)
2182 SetPPChannelMask(channel_);
2183 ClampImage(image(),&exceptionInfo);
2184 RestorePPChannelMask;
2188 void Magick::Image::clip(void)
2192 ClipImage(image(),&exceptionInfo);
2196 void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
2200 ClipImagePath(image(),pathname_.c_str(),(MagickBooleanType) inside_,
2205 void Magick::Image::clut(const Image &clutImage_,
2206 const PixelInterpolateMethod method)
2210 ClutImage(image(),clutImage_.constImage(),method,&exceptionInfo);
2214 void Magick::Image::clutChannel(const ChannelType channel_,
2215 const Image &clutImage_,const PixelInterpolateMethod method)
2219 SetPPChannelMask(channel_);
2220 ClutImage(image(),clutImage_.constImage(),method,&exceptionInfo);
2221 RestorePPChannelMask;
2225 void Magick::Image::colorize(const unsigned int alpha_,const Color &penColor_)
2227 colorize(alpha_,alpha_,alpha_,penColor_);
2230 void Magick::Image::colorize(const unsigned int alphaRed_,
2231 const unsigned int alphaGreen_,const unsigned int alphaBlue_,
2232 const Color &penColor_)
2235 blend[MaxTextExtent];
2244 if (!penColor_.isValid())
2245 throwExceptionExplicit(OptionError,"Pen color argument is invalid");
2247 FormatLocaleString(blend,MaxTextExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
2250 GetPixelInfo(image(),&target);
2251 pixel=static_cast<PixelInfo>(penColor_);
2252 target.red=pixel.red;
2253 target.green=pixel.green;
2254 target.blue=pixel.blue;
2255 target.alpha=pixel.alpha;
2257 newImage=ColorizeImage(image(),blend,&target,&exceptionInfo);
2258 replaceImage(newImage);
2262 void Magick::Image::colorMap(const size_t index_,const Color &color_)
2269 if (index_ > (MaxColormapSize-1))
2270 throwExceptionExplicit(OptionError,
2271 "Colormap index must be less than MaxColormapSize");
2273 if (!color_.isValid())
2274 throwExceptionExplicit(OptionError,"Color argument is invalid");
2278 // Ensure that colormap size is large enough
2279 if (colorMapSize() < (index_+1))
2280 colorMapSize(index_+1);
2282 // Set color at index in colormap
2283 (imageptr->colormap)[index_]=color_;
2286 Magick::Color Magick::Image::colorMap(const size_t index_) const
2288 if (!constImage()->colormap)
2290 throwExceptionExplicit(OptionError,"Image does not contain a colormap");
2294 if (index_ > constImage()->colors-1)
2295 throwExceptionExplicit(OptionError,"Index out of range");
2297 return(Magick::Color((constImage()->colormap)[index_]));
2300 void Magick::Image::colorMatrix(const size_t order_,
2301 const double *color_matrix_)
2307 kernel_info=AcquireKernelInfo((const char *) NULL);
2308 kernel_info->width=order_;
2309 kernel_info->height=order_;
2310 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2311 order_*sizeof(*kernel_info->values));
2312 if (kernel_info->values != (MagickRealType *) NULL)
2317 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2318 kernel_info->values[i]=color_matrix_[i];
2319 newImage=ColorMatrixImage(image(),kernel_info,&exceptionInfo);
2320 replaceImage(newImage);
2322 kernel_info=DestroyKernelInfo(kernel_info);
2326 bool Magick::Image::compare(const Image &reference_)
2337 status=static_cast<bool>(IsImagesEqual(image(),ref.image(),&exceptionInfo));
2342 double Magick::Image::compare(const Image &reference_,const MetricType metric_)
2348 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2354 double Magick::Image::compareChannel(const ChannelType channel_,
2355 const Image &reference_,const MetricType metric_)
2361 SetPPChannelMask(channel_);
2362 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2364 RestorePPChannelMask;
2369 Magick::Image Magick::Image::compare(const Image &reference_,
2370 const MetricType metric_,double *distortion)
2376 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2379 if (newImage == (MagickCore::Image *) NULL)
2380 return(Magick::Image());
2382 return(Magick::Image(newImage));
2385 Magick::Image Magick::Image::compareChannel(const ChannelType channel_,
2386 const Image &reference_,const MetricType metric_,double *distortion)
2392 SetPPChannelMask(channel_);
2393 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2395 RestorePPChannelMask;
2397 if (newImage == (MagickCore::Image *) NULL)
2398 return(Magick::Image());
2400 return(Magick::Image(newImage));
2403 void Magick::Image::composite(const Image &compositeImage_,
2404 const Geometry &offset_,const CompositeOperator compose_)
2414 ParseMetaGeometry(static_cast<std::string>(offset_).c_str(),&x,&y,&width,
2419 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickFalse,
2420 x,y,&exceptionInfo);
2424 void Magick::Image::composite(const Image &compositeImage_,
2425 const GravityType gravity_,const CompositeOperator compose_)
2431 SetGeometry(compositeImage_.constImage(),&geometry);
2432 GravityAdjustGeometry(columns(),rows(),gravity_,&geometry);
2435 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickFalse,
2436 geometry.x,geometry.y,&exceptionInfo);
2440 void Magick::Image::composite(const Image &compositeImage_,
2441 const ssize_t xOffset_,const ssize_t yOffset_,
2442 const CompositeOperator compose_)
2444 // Image supplied as compositeImage is composited with current image and
2445 // results in updating current image.
2448 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickFalse,
2449 xOffset_,yOffset_,&exceptionInfo);
2453 void Magick::Image::contrast(const size_t sharpen_)
2457 ContrastImage(image(),(MagickBooleanType) sharpen_,&exceptionInfo);
2461 void Magick::Image::contrastStretch(const double blackPoint_,
2462 const double whitePoint_)
2466 ContrastStretchImage(image(),blackPoint_,whitePoint_,&exceptionInfo);
2470 void Magick::Image::contrastStretchChannel(const ChannelType channel_,
2471 const double blackPoint_,const double whitePoint_)
2475 SetPPChannelMask(channel_);
2476 ContrastStretchImage(image(),blackPoint_,whitePoint_,&exceptionInfo);
2477 RestorePPChannelMask;
2481 void Magick::Image::convolve(const size_t order_,const double *kernel_)
2487 kernel_info=AcquireKernelInfo((const char *) NULL);
2488 kernel_info->width=order_;
2489 kernel_info->height=order_;
2490 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2491 order_*sizeof(*kernel_info->values));
2492 if (kernel_info->values != (MagickRealType *) NULL)
2497 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2498 kernel_info->values[i]=kernel_[i];
2499 newImage=ConvolveImage(image(),kernel_info,&exceptionInfo);
2500 replaceImage(newImage);
2502 kernel_info=DestroyKernelInfo(kernel_info);
2506 void Magick::Image::crop(const Geometry &geometry_)
2515 newImage=CropImage(constImage(),&cropInfo,&exceptionInfo);
2516 replaceImage(newImage);
2520 void Magick::Image::cycleColormap(const ssize_t amount_)
2524 CycleColormapImage(image(),amount_,&exceptionInfo);
2528 void Magick::Image::decipher(const std::string &passphrase_)
2532 DecipherImage(image(),passphrase_.c_str(),&exceptionInfo);
2536 void Magick::Image::defineSet(const std::string &magick_,
2537 const std::string &key_,bool flag_)
2543 definition=magick_ + ":" + key_;
2545 (void) SetImageOption(imageInfo(),definition.c_str(),"");
2547 DeleteImageOption(imageInfo(),definition.c_str());
2550 bool Magick::Image::defineSet(const std::string &magick_,
2551 const std::string &key_ ) const
2559 key=magick_ + ":" + key_;
2560 option=GetImageOption(constImageInfo(),key.c_str());
2566 void Magick::Image::defineValue(const std::string &magick_,
2567 const std::string &key_,const std::string &value_)
2574 format=magick_ + ":" + key_;
2576 (void) SetImageOption(imageInfo(),format.c_str(),option.c_str());
2579 std::string Magick::Image::defineValue(const std::string &magick_,
2580 const std::string &key_) const
2588 definition=magick_ + ":" + key_;
2589 option=GetImageOption(constImageInfo(),definition.c_str());
2591 return(std::string(option));
2592 return(std::string());
2595 void Magick::Image::deskew(const double threshold_)
2601 newImage=DeskewImage(constImage(),threshold_,&exceptionInfo);
2602 replaceImage(newImage);
2606 void Magick::Image::despeckle(void)
2612 newImage=DespeckleImage(constImage(),&exceptionInfo);
2613 replaceImage(newImage);
2617 void Magick::Image::display(void)
2620 DisplayImages(imageInfo(),image(),&exceptionInfo);
2624 void Magick::Image::distort(const DistortImageMethod method_,
2625 const size_t numberArguments_,const double *arguments_,const bool bestfit_)
2631 newImage=DistortImage(constImage(), method_,numberArguments_,arguments_,
2632 bestfit_ == true ? MagickTrue : MagickFalse,&exceptionInfo);
2633 replaceImage(newImage);
2637 void Magick::Image::draw(const Magick::Drawable &drawable_)
2644 wand=DrawAllocateWand(options()->drawInfo(),image());
2648 drawable_.operator()(wand);
2652 ClonePPDrawException(wand);
2653 wand=DestroyDrawingWand(wand);
2654 ThrowPPDrawException;
2658 void Magick::Image::draw(const std::list<Magick::Drawable> &drawable_)
2665 wand=DrawAllocateWand(options()->drawInfo(),image());
2669 for (std::list<Magick::Drawable>::const_iterator p = drawable_.begin();
2670 p != drawable_.end(); p++ )
2672 p->operator()(wand);
2673 if (DrawGetExceptionType(wand) != UndefinedException)
2677 if (DrawGetExceptionType(wand) == UndefinedException)
2680 ClonePPDrawException(wand);
2681 wand=DestroyDrawingWand(wand);
2682 ThrowPPDrawException;
2686 void Magick::Image::edge(const double radius_)
2692 newImage=EdgeImage(constImage(),radius_,&exceptionInfo);
2693 replaceImage(newImage);
2697 void Magick::Image::emboss(const double radius_,const double sigma_)
2703 newImage=EmbossImage(constImage(),radius_,sigma_,&exceptionInfo);
2704 replaceImage(newImage);
2708 void Magick::Image::encipher(const std::string &passphrase_)
2712 EncipherImage(image(),passphrase_.c_str(),&exceptionInfo);
2716 void Magick::Image::enhance(void)
2722 newImage=EnhanceImage(constImage(),&exceptionInfo);
2723 replaceImage(newImage);
2727 void Magick::Image::equalize(void)
2731 EqualizeImage(image(),&exceptionInfo);
2735 void Magick::Image::erase(void)
2739 SetImageBackgroundColor(image(),&exceptionInfo);
2743 void Magick::Image::extent(const Geometry &geometry_ )
2749 extentInfo=geometry_;
2752 extentInfo.x=geometry_.xOff();
2753 extentInfo.y=geometry_.yOff();
2755 newImage=ExtentImage(image(),&extentInfo,&exceptionInfo);
2756 replaceImage(newImage);
2760 void Magick::Image::extent(const Geometry &geometry_,
2761 const Color &backgroundColor_)
2763 backgroundColor(backgroundColor_);
2767 void Magick::Image::extent(const Geometry &geometry_,
2768 const Color &backgroundColor_,const GravityType gravity_)
2770 backgroundColor(backgroundColor_);
2771 extent(geometry_,gravity_);
2774 void Magick::Image::extent(const Geometry &geometry_,
2775 const GravityType gravity_)
2780 SetGeometry(image(),&geometry);
2781 geometry.width=geometry_.width();
2782 geometry.height=geometry_.height();
2783 GravityAdjustGeometry(image()->columns,image()->rows,gravity_,&geometry);
2787 void Magick::Image::flip(void)
2793 newImage=FlipImage(constImage(),&exceptionInfo);
2794 replaceImage(newImage);
2798 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2799 const unsigned int alpha_,const PaintMethod method_)
2806 GetPixelInfo(image(),&target);
2807 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2808 target.red=pixel.red;
2809 target.green=pixel.green;
2810 target.blue=pixel.blue;
2811 target.alpha=alpha_;
2814 FloodfillPaintImage(image(),options()->drawInfo(),&target,
2815 static_cast<ssize_t>(x_), static_cast<ssize_t>(y_),
2816 method_ == FloodfillMethod ? MagickFalse : MagickTrue,&exceptionInfo);
2820 void Magick::Image::floodFillColor(const Geometry &point_,
2821 const Magick::Color &fillColor_)
2823 floodFillTexture(point_,Image(Geometry(1,1),fillColor_));
2826 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2827 const Magick::Color &fillColor_)
2829 floodFillTexture(x_,y_,Image(Geometry(1,1),fillColor_));
2832 void Magick::Image::floodFillColor(const Geometry &point_,
2833 const Magick::Color &fillColor_,const Magick::Color &borderColor_)
2835 floodFillTexture(point_,Image(Geometry(1,1),fillColor_),borderColor_);
2838 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2839 const Magick::Color &fillColor_,const Magick::Color &borderColor_)
2841 floodFillTexture(x_,y_,Image(Geometry(1,1),fillColor_),borderColor_);
2844 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2845 const Magick::Image &texture_)
2847 floodFillTexture(point_.xOff(),point_.yOff(),texture_);
2850 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2851 const Magick::Image &texture_)
2861 // Set drawing fill pattern
2862 fillPattern=(MagickCore::Image *)NULL;
2863 if (options()->fillPattern() != (MagickCore::Image *)NULL)
2866 fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
2870 options()->fillPattern(texture_.constImage());
2873 Pixels pixels(*this);
2875 p=pixels.get(x_,y_,1,1);
2882 GetPixelInfo(constImage(),&target);
2883 target.red=GetPixelRed(constImage(),p);
2884 target.green=GetPixelGreen(constImage(),p);
2885 target.blue=GetPixelBlue(constImage(),p);
2887 FloodfillPaintImage(image(),options()->drawInfo(),&target,
2888 static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),MagickFalse,
2890 options()->fillPattern(fillPattern);
2894 options()->fillPattern(fillPattern);
2897 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2898 const Magick::Image &texture_,const Magick::Color &borderColor_)
2900 floodFillTexture(point_.xOff(),point_.yOff(),texture_,borderColor_);
2903 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2904 const Magick::Image &texture_,const Magick::Color &borderColor_)
2914 // Set drawing fill pattern
2915 fillPattern=(MagickCore::Image *)NULL;
2916 if (options()->fillPattern() != (MagickCore::Image *)NULL)
2919 fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
2923 options()->fillPattern(texture_.constImage());
2925 GetPixelInfo(constImage(),&target);
2926 target.red=static_cast<PixelInfo>(borderColor_).red;
2927 target.green=static_cast<PixelInfo>(borderColor_).green;
2928 target.blue=static_cast<PixelInfo>(borderColor_).blue;
2930 FloodfillPaintImage(image(),options()->drawInfo(),&target,
2931 static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),MagickTrue,
2933 options()->fillPattern(fillPattern);
2937 void Magick::Image::flop(void)
2943 newImage=FlopImage(constImage(),&exceptionInfo);
2944 replaceImage(newImage);
2948 void Magick::Image::fontTypeMetrics(const std::string &text_,
2949 TypeMetric *metrics)
2954 drawInfo=options()->drawInfo();
2955 drawInfo->text=const_cast<char *>(text_.c_str());
2957 GetTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),&exceptionInfo);
2962 void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
2963 TypeMetric *metrics)
2968 drawInfo=options()->drawInfo();
2969 drawInfo->text=const_cast<char *>(text_.c_str());
2971 GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),&exceptionInfo);
2976 void Magick::Image::frame(const Geometry &geometry_)
2984 info.x=static_cast<ssize_t>(geometry_.width());
2985 info.y=static_cast<ssize_t>(geometry_.height());
2986 info.width=columns() + (static_cast<size_t>(info.x) << 1);
2987 info.height=rows() + (static_cast<size_t>(info.y) << 1);
2988 info.outer_bevel=geometry_.xOff();
2989 info.inner_bevel=geometry_.yOff();
2992 newImage=FrameImage(constImage(),&info,image()->compose,&exceptionInfo);
2993 replaceImage(newImage);
2997 void Magick::Image::frame(const size_t width_,const size_t height_,
2998 const ssize_t outerBevel_,const ssize_t innerBevel_)
3006 info.x=static_cast<ssize_t>(width_);
3007 info.y=static_cast<ssize_t>(height_);
3008 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3009 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3010 info.outer_bevel=static_cast<ssize_t>(outerBevel_);
3011 info.inner_bevel=static_cast<ssize_t>(innerBevel_);
3014 newImage=FrameImage(constImage(),&info,image()->compose,&exceptionInfo);
3015 replaceImage(newImage);
3019 void Magick::Image::fx(const std::string expression_)
3025 newImage=FxImage(constImage(),expression_.c_str(),&exceptionInfo);
3026 replaceImage(newImage);
3030 void Magick::Image::fx(const std::string expression_,
3031 const Magick::ChannelType channel_)
3037 SetPPChannelMask(channel_);
3038 newImage=FxImage(constImage(),expression_.c_str(),&exceptionInfo);
3039 RestorePPChannelMask;
3040 replaceImage(newImage);
3044 void Magick::Image::gamma(const double gamma_)
3048 GammaImage(image(),gamma_,&exceptionInfo);
3052 void Magick::Image::gamma(const double gammaRed_,const double gammaGreen_,
3053 const double gammaBlue_)
3056 gamma[MaxTextExtent + 1];
3058 FormatLocaleString(gamma,MaxTextExtent,"%3.6f/%3.6f/%3.6f/",gammaRed_,
3059 gammaGreen_,gammaBlue_);
3063 GammaImage(image(),atof(gamma),&exceptionInfo);
3067 void Magick::Image::gaussianBlur(const double width_,const double sigma_)
3073 newImage=GaussianBlurImage(constImage(),width_,sigma_,&exceptionInfo);
3074 replaceImage(newImage);
3078 void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
3079 const double width_,const double sigma_)
3085 SetPPChannelMask(channel_);
3086 newImage=GaussianBlurImage(constImage(),width_,sigma_,&exceptionInfo);
3087 RestorePPChannelMask;
3088 replaceImage(newImage);
3092 const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
3093 const ssize_t y_,const size_t columns_,const size_t rows_) const
3099 p=(*GetVirtualPixels)(constImage(),x_, y_,columns_, rows_,&exceptionInfo);
3104 const void *Magick::Image::getConstMetacontent(void) const
3109 result=GetVirtualMetacontent(constImage());
3112 throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
3117 void *Magick::Image::getMetacontent(void )
3122 result=GetAuthenticMetacontent(image());
3125 throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
3130 Magick::Quantum *Magick::Image::getPixels(const ssize_t x_,const ssize_t y_,
3131 const size_t columns_,const size_t rows_)
3138 result=(*GetAuthenticPixels)(image(),x_, y_,columns_,rows_,&exceptionInfo);
3144 void Magick::Image::haldClut(const Image &clutImage_)
3148 (void) HaldClutImage(image(),clutImage_.constImage(),&exceptionInfo);
3152 void Magick::Image::implode(const double factor_)
3158 newImage=ImplodeImage(constImage(),factor_,image()->interpolate,
3160 replaceImage(newImage);
3164 void Magick::Image::inverseFourierTransform(const Image &phase_)
3166 inverseFourierTransform(phase_,true);
3169 void Magick::Image::inverseFourierTransform(const Image &phase_,
3170 const bool magnitude_)
3176 newImage=InverseFourierTransformImage(constImage(),phase_.constImage(),
3177 magnitude_ == true ? MagickTrue : MagickFalse,&exceptionInfo);
3178 replaceImage(newImage);
3182 void Magick::Image::level(const double blackPoint_,const double whitePoint_,
3183 const double gamma_)
3187 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,&exceptionInfo);
3191 void Magick::Image::levelChannel(const ChannelType channel_,
3192 const double blackPoint_,const double whitePoint_,const double gamma_)
3196 SetPPChannelMask(channel_);
3197 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,&exceptionInfo);
3198 RestorePPChannelMask;
3202 void Magick::Image::levelColors(const Color &blackColor_,
3203 const Color &whiteColor_,const bool invert_)
3212 GetPixelInfo(image(),&black);
3213 pixel=static_cast<PixelInfo>(blackColor_);
3214 black.red=pixel.red;
3215 black.green=pixel.green;
3216 black.blue=pixel.blue;
3217 black.alpha=pixel.alpha;
3219 GetPixelInfo(image(),&white);
3220 pixel=static_cast<PixelInfo>(whiteColor_);
3221 white.red=pixel.red;
3222 white.green=pixel.green;
3223 white.blue=pixel.blue;
3224 white.alpha=pixel.alpha;
3227 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3228 MagickTrue : MagickFalse,&exceptionInfo);
3232 void Magick::Image::levelColorsChannel(const ChannelType channel_,
3233 const Color &blackColor_,const Color &whiteColor_,const bool invert_)
3242 GetPixelInfo(image(),&black);
3243 pixel=static_cast<PixelInfo>(blackColor_);
3244 black.red=pixel.red;
3245 black.green=pixel.green;
3246 black.blue=pixel.blue;
3247 black.alpha=pixel.alpha;
3249 GetPixelInfo(image(),&white);
3250 pixel=static_cast<PixelInfo>(whiteColor_);
3251 white.red=pixel.red;
3252 white.green=pixel.green;
3253 white.blue=pixel.blue;
3254 white.alpha=pixel.alpha;
3257 SetPPChannelMask(channel_);
3258 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3259 MagickTrue : MagickFalse,&exceptionInfo);
3260 RestorePPChannelMask;
3264 void Magick::Image::linearStretch(const double blackPoint_,
3265 const double whitePoint_)
3269 LinearStretchImage(image(),blackPoint_,whitePoint_,&exceptionInfo);
3273 void Magick::Image::liquidRescale(const Geometry &geometry_)
3286 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3290 newImage=LiquidRescaleImage(image(),width,height,x,y,&exceptionInfo);
3291 replaceImage(newImage);
3295 void Magick::Image::magnify(void)
3301 newImage=MagnifyImage(constImage(),&exceptionInfo);
3302 replaceImage(newImage);
3306 void Magick::Image::map(const Image &mapImage_,const bool dither_)
3310 options()->quantizeDither(dither_);
3311 RemapImage(options()->quantizeInfo(),image(),mapImage_.constImage(),
3316 void Magick::Image::medianFilter(const double radius_)
3322 newImage=StatisticImage(image(),MedianStatistic,(size_t) radius_,
3323 (size_t) radius_,&exceptionInfo);
3324 replaceImage(newImage);
3328 void Magick::Image::minify(void)
3334 newImage=MinifyImage(constImage(),&exceptionInfo);
3335 replaceImage(newImage);
3339 void Magick::Image::modulate(const double brightness_,const double saturation_,
3343 modulate[MaxTextExtent + 1];
3345 FormatLocaleString(modulate,MaxTextExtent,"%3.6f,%3.6f,%3.6f",brightness_,
3350 ModulateImage(image(),modulate,&exceptionInfo);
3354 void Magick::Image::morphology(const MorphologyMethod method_,
3355 const std::string kernel_,const ssize_t iterations_)
3363 kernel=AcquireKernelInfo(kernel_.c_str());
3364 if (kernel == (KernelInfo *)NULL)
3365 throwExceptionExplicit(OptionError,"Unable to parse kernel.");
3368 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3370 replaceImage(newImage);
3371 kernel=DestroyKernelInfo(kernel);
3375 void Magick::Image::morphology(const MorphologyMethod method_,
3376 const KernelInfoType kernel_,const std::string arguments_,
3377 const ssize_t iterations_)
3385 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3386 if (option == (const char *)NULL)
3387 throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
3389 kernel=std::string(option);
3390 if (!arguments_.empty())
3391 kernel+=":"+arguments_;
3393 morphology(method_,kernel,iterations_);
3396 void Magick::Image::morphologyChannel(const ChannelType channel_,
3397 const MorphologyMethod method_,const std::string kernel_,
3398 const ssize_t iterations_)
3406 kernel=AcquireKernelInfo(kernel_.c_str());
3407 if (kernel == (KernelInfo *)NULL)
3408 throwExceptionExplicit(OptionError,"Unable to parse kernel.");
3411 SetPPChannelMask(channel_);
3412 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3414 RestorePPChannelMask;
3415 replaceImage(newImage);
3416 kernel=DestroyKernelInfo(kernel);
3420 void Magick::Image::morphologyChannel(const ChannelType channel_,
3421 const MorphologyMethod method_,const KernelInfoType kernel_,
3422 const std::string arguments_,const ssize_t iterations_)
3430 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3431 if (option == (const char *)NULL)
3432 throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
3434 kernel=std::string(option);
3435 if (!arguments_.empty())
3436 kernel+=":"+arguments_;
3438 morphologyChannel(channel_,method_,kernel,iterations_);
3441 void Magick::Image::motionBlur(const double radius_,const double sigma_,
3442 const double angle_)
3448 newImage=MotionBlurImage(constImage(),radius_,sigma_,angle_,&exceptionInfo);
3449 replaceImage(newImage);
3453 void Magick::Image::negate(const bool grayscale_)
3457 NegateImage(image(),(MagickBooleanType) grayscale_,&exceptionInfo);
3461 void Magick::Image::negateChannel(const ChannelType channel_,
3462 const bool grayscale_)
3466 SetPPChannelMask(channel_);
3467 NegateImage(image(),(MagickBooleanType) grayscale_,&exceptionInfo);
3468 RestorePPChannelMask;
3472 void Magick::Image::normalize(void)
3476 NormalizeImage(image(),&exceptionInfo);
3480 void Magick::Image::oilPaint(const double radius_,const double sigma_)
3486 newImage=OilPaintImage(constImage(),radius_,sigma_,&exceptionInfo);
3487 replaceImage(newImage);
3491 void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_)
3501 if (!opaqueColor_.isValid())
3502 throwExceptionExplicit(OptionError,"Opaque color argument is invalid");
3504 if (!penColor_.isValid())
3505 throwExceptionExplicit(OptionError,"Pen color argument is invalid");
3508 opaqueColor=opaqueColor_;
3512 (void) QueryColorCompliance(opaqueColor.c_str(),AllCompliance,&opaque,
3514 (void) QueryColorCompliance(penColor.c_str(),AllCompliance,&pen,
3516 OpaquePaintImage(image(),&opaque,&pen,MagickFalse,&exceptionInfo);
3520 void Magick::Image::orderedDither(std::string thresholdMap_)
3524 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),&exceptionInfo);
3528 void Magick::Image::orderedDitherChannel(const ChannelType channel_,
3529 std::string thresholdMap_)
3533 SetPPChannelMask(channel_);
3534 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),&exceptionInfo);
3535 RestorePPChannelMask;
3539 void Magick::Image::perceptible(const double epsilon_)
3543 PerceptibleImage(image(),epsilon_,&exceptionInfo);
3547 void Magick::Image::perceptibleChannel(const ChannelType channel_,
3548 const double epsilon_)
3552 SetPPChannelMask(channel_);
3553 PerceptibleImage(image(),epsilon_,&exceptionInfo);
3554 RestorePPChannelMask;
3558 void Magick::Image::ping(const std::string &imageSpec_)
3564 options()->fileName(imageSpec_);
3565 newImage=PingImage(imageInfo(),&exceptionInfo);
3566 replaceImage(newImage);
3570 void Magick::Image::ping(const Blob& blob_)
3576 newImage=PingBlob(imageInfo(),blob_.data(),blob_.length(),&exceptionInfo);
3577 replaceImage(newImage);
3581 void Magick::Image::pixelColor(const ssize_t x_,const ssize_t y_,
3582 const Color &color_)
3590 // Test arguments to ensure they are within the image.
3591 if (y_ > (ssize_t) rows() || x_ > (ssize_t) columns())
3592 throwExceptionExplicit(OptionError,"Access outside of image boundary");
3596 // Set image to DirectClass
3597 classType(DirectClass );
3600 Pixels pixels(*this);
3602 pixel=pixels.get(x_, y_, 1, 1 );
3604 MagickCore::SetPixelInfoPixel(constImage(),&packet,pixel);
3605 // Tell ImageMagick that pixels have been updated
3609 Magick::Color Magick::Image::pixelColor(const ssize_t x_,
3610 const ssize_t y_) const
3615 pixel=getConstPixels(x_,y_,1,1);
3621 MagickCore::GetPixelInfoPixel(constImage(),pixel,&packet);
3622 return(Color(packet));
3625 return(Color()); // invalid
3628 void Magick::Image::polaroid(const std::string &caption_,const double angle_,
3629 const PixelInterpolateMethod method_)
3635 newImage=PolaroidImage(constImage(),options()->drawInfo(),caption_.c_str(),
3636 angle_,method_,&exceptionInfo);
3637 replaceImage(newImage);
3641 void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
3645 PosterizeImage(image(),levels_,method_,&exceptionInfo);
3649 void Magick::Image::posterizeChannel(const ChannelType channel_,
3650 const size_t levels_,const DitherMethod method_)
3654 SetPPChannelMask(channel_);
3655 PosterizeImage(image(),levels_,method_,&exceptionInfo);
3656 RestorePPChannelMask;
3660 void Magick::Image::process(std::string name_,const ssize_t argc,
3666 (void) InvokeDynamicImageFilter(name_.c_str(),&image(),argc,argv,
3671 void Magick::Image::profile(const std::string name_,
3672 const Magick::Blob &profile_)
3676 (void) ProfileImage(image(),name_.c_str(),(unsigned char *)profile_.data(),
3677 profile_.length(),&exceptionInfo);
3681 Magick::Blob Magick::Image::profile(const std::string name_) const
3686 profile=GetImageProfile(constImage(),name_.c_str());
3688 if (profile == (StringInfo *) NULL)
3690 return(Blob((void*) GetStringInfoDatum(profile),GetStringInfoLength(
3694 void Magick::Image::quantize(const bool measureError_)
3699 options()->quantizeInfo()->measure_error=MagickTrue;
3701 options()->quantizeInfo()->measure_error=MagickFalse;
3704 QuantizeImage(options()->quantizeInfo(),image(),&exceptionInfo);
3708 void Magick::Image::quantumOperator(const ChannelType channel_,
3709 const MagickEvaluateOperator operator_,double rvalue_)
3712 SetPPChannelMask(channel_);
3713 EvaluateImage(image(),operator_,rvalue_,&exceptionInfo);
3714 RestorePPChannelMask;
3718 void Magick::Image::quantumOperator(const ssize_t x_,const ssize_t y_,
3719 const size_t columns_,const size_t rows_,const ChannelType channel_,
3720 const MagickEvaluateOperator operator_,const double rvalue_)
3728 geometry.width = columns_;
3729 geometry.height = rows_;
3734 cropImage=CropImage(image(),&geometry,&exceptionInfo);
3735 SetPPChannelMask(channel_);
3736 EvaluateImage(cropImage,operator_,rvalue_,&exceptionInfo);
3737 RestorePPChannelMask;
3738 (void) CompositeImage(image(),cropImage,image()->alpha_trait ==
3739 BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
3740 geometry.x,geometry.y,&exceptionInfo );
3741 cropImage=DestroyImageList(cropImage);
3745 void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
3748 raiseInfo=geometry_;
3752 RaiseImage(image(),&raiseInfo,raisedFlag_ == true ? MagickTrue : MagickFalse,
3757 void Magick::Image::randomThreshold(const Geometry &thresholds_)
3760 (void) RandomThresholdImage(image(),static_cast<std::string>(
3761 thresholds_).c_str(),&exceptionInfo);
3765 void Magick::Image::randomThresholdChannel(const ChannelType channel_,
3766 const Geometry &thresholds_)
3770 SetPPChannelMask(channel_);
3771 (void) RandomThresholdImage(image(),static_cast<std::string>(
3772 thresholds_).c_str(),&exceptionInfo);
3773 RestorePPChannelMask;
3777 void Magick::Image::read(const Blob &blob_)
3783 newImage=BlobToImage(imageInfo(),static_cast<const void *>(blob_.data()),
3784 blob_.length(),&exceptionInfo);
3785 replaceImage(newImage);
3789 void Magick::Image::read(const Blob &blob_,const Geometry &size_)
3795 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3796 const size_t depth_)
3803 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3804 const size_t depth_,const std::string &magick_)
3809 // Set explicit image format
3810 fileName(magick_ + ':');
3814 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3815 const std::string &magick_)
3819 // Set explicit image format
3820 fileName(magick_ + ':');
3824 void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_)
3830 void Magick::Image::read(const size_t width_,const size_t height_,
3831 const std::string &map_,const StorageType type_,const void *pixels_)
3837 newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
3839 replaceImage(newImage);
3843 void Magick::Image::read(const std::string &imageSpec_)
3849 options()->fileName(imageSpec_);
3850 newImage=ReadImage(imageInfo(),&exceptionInfo);
3852 // Ensure that multiple image frames were not read.
3853 if (newImage && newImage->next)
3858 // Destroy any extra image frames
3859 next=newImage->next;
3862 DestroyImageList(next);
3864 replaceImage(newImage);
3868 void Magick::Image::readPixels(const Magick::QuantumType quantum_,
3869 const unsigned char *source_)
3874 quantum_info=AcquireQuantumInfo(imageInfo(),image());
3876 ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
3877 quantum_,source_,&exceptionInfo);
3878 quantum_info=DestroyQuantumInfo(quantum_info);
3882 void Magick::Image::reduceNoise(void)
3887 void Magick::Image::reduceNoise(const double order_)
3893 newImage=StatisticImage(constImage(),NonpeakStatistic,(size_t) order_,
3894 (size_t) order_,&exceptionInfo);
3895 replaceImage(newImage);
3899 void Magick::Image::resample(const Geometry &geometry_)
3912 // Calculate new size. This code should be supported using binary arguments
3913 // in the ImageMagick library.
3914 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3918 newImage=ResampleImage(constImage(),width,height,image()->filter,
3920 replaceImage(newImage);
3924 void Magick::Image::resize(const Geometry &geometry_)
3937 // Calculate new size. This code should be supported using binary arguments
3938 // in the ImageMagick library.
3939 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3943 newImage=ResizeImage(constImage(),width,height,image()->filter,
3945 replaceImage(newImage);
3949 void Magick::Image::roll(const Geometry &roll_)
3958 if (roll_.xNegative())
3960 if (roll_.yNegative())
3964 newImage=RollImage(constImage(),xOff,yOff,&exceptionInfo);
3965 replaceImage(newImage);
3969 void Magick::Image::roll(const size_t columns_,const size_t rows_)
3975 newImage=RollImage(constImage(),static_cast<ssize_t>(columns_),
3976 static_cast<ssize_t>(rows_),&exceptionInfo);
3977 replaceImage(newImage);
3981 void Magick::Image::rotate(const double degrees_)
3987 newImage=RotateImage(constImage(),degrees_,&exceptionInfo);
3988 replaceImage(newImage);
3992 void Magick::Image::rotationalBlur(const double angle_)
3998 newImage=RotationalBlurImage(constImage(),angle_,&exceptionInfo);
3999 replaceImage(newImage);
4003 void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
4004 const double angle_)
4010 SetPPChannelMask(channel_);
4011 newImage=RotationalBlurImage(constImage(),angle_,&exceptionInfo);
4012 RestorePPChannelMask;
4013 replaceImage(newImage);
4017 void Magick::Image::sample(const Geometry &geometry_)
4030 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4034 newImage=SampleImage(constImage(),width,height,&exceptionInfo);
4035 replaceImage(newImage);
4039 void Magick::Image::scale(const Geometry &geometry_)
4052 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4056 newImage=ScaleImage(constImage(),width,height,&exceptionInfo);
4057 replaceImage(newImage);
4061 void Magick::Image::segment(const double clusterThreshold_,
4062 const double smoothingThreshold_)
4066 SegmentImage(image(),options()->quantizeColorSpace(),
4067 (MagickBooleanType) options()->verbose(),clusterThreshold_,
4068 smoothingThreshold_,&exceptionInfo);
4069 SyncImage(image(),&exceptionInfo);
4073 void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
4074 const double threshold_)
4080 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4082 replaceImage(newImage);
4086 void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
4087 const double radius_,const double sigma_,const double threshold_)
4093 SetPPChannelMask(channel_);
4094 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4096 RestorePPChannelMask;
4097 replaceImage(newImage);
4101 Magick::Image Magick::Image::separate(const ChannelType channel_)
4107 image=SeparateImage(constImage(),channel_,&exceptionInfo);
4109 if (image == (MagickCore::Image *) NULL)
4110 return(Magick::Image());
4112 return(Magick::Image(image));
4115 void Magick::Image::sepiaTone(const double threshold_)
4121 newImage=SepiaToneImage(constImage(),threshold_,&exceptionInfo);
4122 replaceImage(newImage);
4126 Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
4127 const size_t columns_,const size_t rows_)
4134 result=(*QueueAuthenticPixels)(image(),x_,y_,columns_,rows_,&exceptionInfo);
4139 void Magick::Image::shade(const double azimuth_,const double elevation_,
4140 const bool colorShading_)
4146 newImage=ShadeImage(constImage(),colorShading_ == true ?
4147 MagickTrue : MagickFalse,azimuth_,elevation_,&exceptionInfo);
4148 replaceImage(newImage);
4152 void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
4153 const ssize_t x_,const ssize_t y_)
4159 newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
4161 replaceImage(newImage);
4165 void Magick::Image::sharpen(const double radius_,const double sigma_)
4171 newImage=SharpenImage(constImage(),radius_,sigma_,&exceptionInfo);
4172 replaceImage(newImage);
4176 void Magick::Image::sharpenChannel(const ChannelType channel_,
4177 const double radius_,const double sigma_)
4183 SetPPChannelMask(channel_);
4184 newImage=SharpenImage(constImage(),radius_,sigma_,&exceptionInfo);
4185 RestorePPChannelMask;
4186 replaceImage(newImage);
4190 void Magick::Image::shave(const Geometry &geometry_)
4196 shaveInfo=geometry_;
4199 newImage=ShaveImage(constImage(),&shaveInfo,&exceptionInfo);
4200 replaceImage(newImage);
4204 void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
4210 newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,&exceptionInfo);
4211 replaceImage(newImage);
4215 void Magick::Image::sigmoidalContrast(const size_t sharpen_,
4216 const double contrast,const double midpoint)
4220 (void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
4221 midpoint,&exceptionInfo);
4225 std::string Magick::Image::signature(const bool force_) const
4230 Lock(&_imgRef->_mutexLock);
4232 // Re-calculate image signature if necessary
4234 if (force_ || !GetImageProperty(constImage(),"Signature",&exceptionInfo) ||
4235 constImage()->taint)
4236 SignatureImage(const_cast<MagickCore::Image *>(constImage()),
4239 property=GetImageProperty(constImage(),"Signature",&exceptionInfo);
4242 return(std::string(property));
4245 void Magick::Image::sketch(const double radius_,const double sigma_,
4246 const double angle_)
4252 newImage=SketchImage(constImage(),radius_,sigma_,angle_,&exceptionInfo);
4253 replaceImage(newImage);
4257 void Magick::Image::solarize(const double factor_)
4261 SolarizeImage(image(),factor_,&exceptionInfo);
4265 void Magick::Image::sparseColor(const ChannelType channel_,
4266 const SparseColorMethod method_,const size_t numberArguments_,
4267 const double *arguments_)
4273 SetPPChannelMask(channel_);
4274 newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
4276 RestorePPChannelMask;
4277 replaceImage(newImage);
4281 void Magick::Image::splice(const Geometry &geometry_)
4287 spliceInfo=geometry_;
4290 newImage=SpliceImage(constImage(),&spliceInfo,&exceptionInfo);
4291 replaceImage(newImage);
4295 void Magick::Image::spread(const size_t amount_)
4301 newImage=SpreadImage(constImage(),amount_,image()->interpolate,
4303 replaceImage(newImage);
4307 void Magick::Image::statistics(ImageStatistics *statistics)
4315 SetPPChannelMask(RedChannel);
4316 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4317 statistics->red.minimum=minimum;
4318 statistics->red.maximum=maximum;
4319 (void) GetImageMean(constImage(),&statistics->red.mean,
4320 &statistics->red.standard_deviation,&exceptionInfo);
4321 (void) GetImageKurtosis(constImage(),&statistics->red.kurtosis,
4322 &statistics->red.skewness,&exceptionInfo);
4324 (void) SetImageChannelMask(image(),GreenChannel);
4325 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4326 statistics->green.minimum=minimum;
4327 statistics->green.maximum=maximum;
4328 (void) GetImageMean(constImage(),&statistics->green.mean,
4329 &statistics->green.standard_deviation,&exceptionInfo);
4330 (void) GetImageKurtosis(constImage(),&statistics->green.kurtosis,
4331 &statistics->green.skewness,&exceptionInfo);
4333 (void) SetImageChannelMask(image(),GreenChannel);
4334 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4335 statistics->blue.minimum=minimum;
4336 statistics->blue.maximum=maximum;
4337 (void) GetImageMean(constImage(),&statistics->blue.mean,
4338 &statistics->blue.standard_deviation,&exceptionInfo);
4339 (void) GetImageKurtosis(constImage(),&statistics->blue.kurtosis,
4340 &statistics->blue.skewness,&exceptionInfo);
4342 (void) SetImageChannelMask(image(),AlphaChannel);
4343 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4344 statistics->alpha.minimum=minimum;
4345 statistics->alpha.maximum=maximum;
4346 (void) GetImageMean(constImage(),&statistics->alpha.mean,
4347 &statistics->alpha.standard_deviation,&exceptionInfo);
4348 (void) GetImageKurtosis(constImage(),&statistics->alpha.kurtosis,
4349 &statistics->alpha.skewness,&exceptionInfo);
4350 RestorePPChannelMask;
4354 void Magick::Image::stegano(const Image &watermark_)
4360 newImage=SteganoImage(constImage(),watermark_.constImage(),&exceptionInfo);
4361 replaceImage(newImage);
4365 void Magick::Image::stereo(const Image &rightImage_)
4371 newImage=StereoImage(constImage(),rightImage_.constImage(),&exceptionInfo);
4372 replaceImage(newImage);
4376 void Magick::Image::strip(void)
4380 StripImage(image(),&exceptionInfo);
4384 Magick::Image Magick::Image::subImageSearch(const Image &reference_,
4385 const MetricType metric_,Geometry *offset_,double *similarityMetric_,
4386 const double similarityThreshold)
4395 newImage=SimilarityImage(image(),reference_.constImage(),metric_,
4396 similarityThreshold,&offset,similarityMetric_,&exceptionInfo);
4398 if (offset_ != (Geometry *) NULL)
4400 if (newImage == (MagickCore::Image *) NULL)
4401 return(Magick::Image());
4403 return(Magick::Image(newImage));
4406 void Magick::Image::swirl(const double degrees_)
4412 newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
4414 replaceImage(newImage);
4418 void Magick::Image::syncPixels(void)
4421 (*SyncAuthenticPixels)(image(),&exceptionInfo);
4425 void Magick::Image::texture(const Image &texture_)
4429 TextureImage(image(),texture_.constImage(),&exceptionInfo);
4433 void Magick::Image::threshold(const double threshold_)
4437 BilevelImage(image(),threshold_,&exceptionInfo);
4441 void Magick::Image::thumbnail(const Geometry &geometry_)
4454 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4458 newImage=ThumbnailImage(constImage(),width,height,&exceptionInfo);
4459 replaceImage(newImage);
4463 void Magick::Image::tint(const std::string opacity_)
4472 color=static_cast<PixelInfo>(constOptions()->fillColor());
4473 newImage=TintImage(constImage(),opacity_.c_str(),&color,&exceptionInfo);
4474 replaceImage(newImage);
4478 void Magick::Image::transform(const Geometry &imageGeometry_)
4482 TransformImage(&(image()),0,std::string(imageGeometry_).c_str(),
4487 void Magick::Image::transform(const Geometry &imageGeometry_,
4488 const Geometry &cropGeometry_)
4492 TransformImage(&(image()),std::string(cropGeometry_).c_str(),std::string(
4493 imageGeometry_).c_str(), &exceptionInfo);
4497 void Magick::Image::transformOrigin(const double x_,const double y_)
4500 options()->transformOrigin(x_,y_);
4503 void Magick::Image::transformReset(void)
4506 options()->transformReset();
4509 void Magick::Image::transformScale(const double sx_,const double sy_)
4512 options()->transformScale(sx_,sy_);
4515 void Magick::Image::transparent(const Color &color_)
4523 if (!color_.isValid())
4524 throwExceptionExplicit(OptionError,"Color argument is invalid");
4528 (void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
4531 TransparentPaintImage(image(),&target,TransparentAlpha,MagickFalse,
4536 void Magick::Image::transparentChroma(const Color &colorLow_,
4537 const Color &colorHigh_)
4547 if (!colorLow_.isValid() || !colorHigh_.isValid())
4548 throwExceptionExplicit(OptionError,"Color argument is invalid");
4551 colorHigh=colorHigh_;
4554 (void) QueryColorCompliance(colorLow.c_str(),AllCompliance,&targetLow,
4556 (void) QueryColorCompliance(colorHigh.c_str(),AllCompliance,&targetHigh,
4559 TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
4560 MagickFalse,&exceptionInfo);
4564 void Magick::Image::transpose(void)
4570 newImage=TransposeImage(constImage(),&exceptionInfo);
4571 replaceImage(newImage);
4575 void Magick::Image::transverse(void)
4581 newImage=TransverseImage(constImage(),&exceptionInfo);
4582 replaceImage(newImage);
4586 void Magick::Image::trim(void)
4592 newImage=TrimImage(constImage(),&exceptionInfo);
4593 replaceImage(newImage);
4597 Magick::Image Magick::Image::uniqueColors(void)
4603 image=UniqueImageColors(constImage(),&exceptionInfo);
4605 if (image == (MagickCore::Image *) NULL)
4606 return(Magick::Image());
4608 return(Magick::Image(image));
4611 void Magick::Image::unsharpmask(const double radius_,const double sigma_,
4612 const double amount_,const double threshold_)
4618 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4620 replaceImage(newImage);
4624 void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
4625 const double radius_,const double sigma_,const double amount_,
4626 const double threshold_)
4632 SetPPChannelMask(channel_);
4633 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4635 RestorePPChannelMask;
4636 replaceImage(newImage);
4640 void Magick::Image::vignette(const double radius_,const double sigma_,
4641 const ssize_t x_,const ssize_t y_)
4647 newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,&exceptionInfo);
4648 replaceImage(newImage);
4652 void Magick::Image::wave(const double amplitude_,const double wavelength_)
4658 newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
4660 replaceImage(newImage);
4664 void Magick::Image::whiteThreshold(const std::string &threshold_)
4668 WhiteThresholdImage(image(),threshold_.c_str(),&exceptionInfo);
4672 void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
4673 const std::string &threshold_)
4677 SetPPChannelMask(channel_);
4678 WhiteThresholdImage(image(),threshold_.c_str(),&exceptionInfo);
4679 RestorePPChannelMask;
4683 void Magick::Image::write(Blob *blob_)
4686 length=2048; // Efficient size for small images
4693 data=ImagesToBlob(constImageInfo(),image(),&length,&exceptionInfo);
4695 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4698 void Magick::Image::write(Blob *blob_,const std::string &magick_)
4701 length=2048; // Efficient size for small images
4709 data=ImagesToBlob(constImageInfo(),image(),&length,&exceptionInfo);
4711 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4714 void Magick::Image::write(Blob *blob_,const std::string &magick_,
4715 const size_t depth_)
4718 length=2048; // Efficient size for small images
4727 data=ImagesToBlob(constImageInfo(),image(),&length,&exceptionInfo);
4729 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4732 void Magick::Image::write(const ssize_t x_,const ssize_t y_,
4733 const size_t columns_,const size_t rows_,const std::string &map_,
4734 const StorageType type_,void *pixels_)
4737 ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
4742 void Magick::Image::write(const std::string &imageSpec_)
4745 fileName(imageSpec_);
4747 WriteImage(constImageInfo(),image(),&exceptionInfo);
4751 void Magick::Image::writePixels(const Magick::QuantumType quantum_,
4752 unsigned char *destination_)
4757 quantum_info=AcquireQuantumInfo(imageInfo(),image());
4759 ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4760 quantum_,destination_, &exceptionInfo);
4761 quantum_info=DestroyQuantumInfo(quantum_info);
4765 void Magick::Image::zoom(const Geometry &geometry_)
4778 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4782 newImage=ResizeImage(constImage(),width,height,image()->filter,&exceptionInfo);
4783 replaceImage(newImage);
4787 Magick::Image::Image(MagickCore::Image *image_)
4788 : _imgRef(new ImageRef(image_))
4792 MagickCore::Image *&Magick::Image::image(void)
4794 return(_imgRef->image());
4797 const MagickCore::Image *Magick::Image::constImage(void) const
4799 return(_imgRef->image());
4802 MagickCore::ImageInfo *Magick::Image::imageInfo(void)
4804 return(_imgRef->options()->imageInfo());
4807 const MagickCore::ImageInfo *Magick::Image::constImageInfo(void) const
4809 return(_imgRef->options()->imageInfo());
4812 Magick::Options *Magick::Image::options(void)
4814 return(_imgRef->options());
4817 const Magick::Options *Magick::Image::constOptions(void) const
4819 return(_imgRef->options());
4822 MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)
4824 return(_imgRef->options()->quantizeInfo());
4827 const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
4829 return(_imgRef->options()->quantizeInfo());
4832 void Magick::Image::modifyImage(void)
4835 Lock(&_imgRef->_mutexLock);
4836 if (_imgRef->_refCount == 1)
4838 // De-register image and return
4845 replaceImage(CloneImage(image(),0,0,MagickTrue,&exceptionInfo));
4849 ssize_t Magick::Image::registerId(void)
4851 Lock(&_imgRef->_mutexLock);
4852 if ( _imgRef->id() < 0)
4858 _imgRef->id(_imgRef->id()+1);
4859 sprintf(id,"%.20g\n",(double) _imgRef->id());
4860 SetImageRegistry(ImageRegistryType,id,image(),&exceptionInfo);
4863 return(_imgRef->id());
4866 MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
4872 image = replacement_;
4876 image=AcquireImage(constImageInfo(),&exceptionInfo);
4881 Lock(&_imgRef->_mutexLock);
4883 if (_imgRef->_refCount == 1)
4885 // We own the image, just replace it, and de-register
4887 _imgRef->image(image);
4891 // We don't own the image, dereference and replace with copy
4892 --_imgRef->_refCount;
4893 _imgRef=new ImageRef(image,constOptions());
4897 return(_imgRef->_image);
4900 void Magick::Image::unregisterId(void)