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::blackPointCompensation(const bool flag_)
446 image()->black_point_compensation=(MagickBooleanType) flag_;
449 bool Magick::Image::blackPointCompensation(void) const
451 return(static_cast<bool>(constImage()->black_point_compensation));
454 void Magick::Image::borderColor(const Color &borderColor_)
458 if (borderColor_.isValid())
459 image()->border_color=borderColor_;
461 image()->border_color=Color();
463 options()->borderColor(borderColor_);
466 Magick::Color Magick::Image::borderColor(void) const
468 return(constOptions()->borderColor());
471 Magick::Geometry Magick::Image::boundingBox(void) const
477 bbox=GetImageBoundingBox(constImage(),&exceptionInfo);
479 return(Geometry(bbox));
482 void Magick::Image::boxColor(const Color &boxColor_)
485 options()->boxColor(boxColor_);
488 Magick::Color Magick::Image::boxColor(void) const
490 return(constOptions()->boxColor());
493 void Magick::Image::channelDepth(const size_t depth_)
497 SetImageDepth(image(),depth_,&exceptionInfo);
501 size_t Magick::Image::channelDepth()
507 channel_depth=GetImageDepth(constImage(),&exceptionInfo);
509 return(channel_depth);
512 size_t Magick::Image::channels() const
514 return(constImage()->number_channels);
517 void Magick::Image::classType(const ClassType class_)
519 if (classType() == PseudoClass && class_ == DirectClass)
521 // Use SyncImage to synchronize the DirectClass pixels with the
522 // color map and then set to DirectClass type.
525 SyncImage(image(),&exceptionInfo);
527 image()->colormap=(PixelInfo *)RelinquishMagickMemory(image()->colormap);
528 image()->storage_class=static_cast<MagickCore::ClassType>(DirectClass);
532 if (classType() == DirectClass && class_ == PseudoClass)
534 // Quantize to create PseudoClass color map
536 quantizeColors(MaxColormapSize);
538 image()->storage_class=static_cast<MagickCore::ClassType>(PseudoClass);
542 Magick::ClassType Magick::Image::classType(void) const
544 return static_cast<Magick::ClassType>(constImage()->storage_class);
547 void Magick::Image::clipMask(const Magick::Image &clipMask_)
552 if (clipMask_.isValid())
553 SetImageMask(image(),clipMask_.constImage(),&exceptionInfo);
555 SetImageMask(image(),0,&exceptionInfo);
559 Magick::Image Magick::Image::clipMask(void) const
565 image=GetImageMask(constImage(),&exceptionInfo);
567 if (image == (MagickCore::Image *) NULL)
568 return(Magick::Image());
570 return(Magick::Image(image));
573 void Magick::Image::colorFuzz(const double fuzz_)
577 options()->colorFuzz(fuzz_);
580 double Magick::Image::colorFuzz(void) const
582 return(constOptions()->colorFuzz());
585 void Magick::Image::colorMapSize(const size_t entries_)
587 if (entries_ >MaxColormapSize)
588 throwExceptionExplicit(OptionError,
589 "Colormap entries must not exceed MaxColormapSize");
593 AcquireImageColormap(image(),entries_,&exceptionInfo);
597 size_t Magick::Image::colorMapSize(void) const
599 if (!constImage()->colormap)
600 throwExceptionExplicit(OptionError,"Image does not contain a colormap");
602 return(constImage()->colors);
605 void Magick::Image::colorSpace(const ColorspaceType colorSpace_)
607 if (image()->colorspace == colorSpace_)
612 TransformImageColorspace(image(),colorSpace_,&exceptionInfo);
616 Magick::ColorspaceType Magick::Image::colorSpace(void) const
618 return (constImage()->colorspace);
621 void Magick::Image::colorSpaceType(const ColorspaceType colorSpace_)
625 SetImageColorspace(image(),colorSpace_,&exceptionInfo);
627 options()->colorspaceType(colorSpace_);
630 Magick::ColorspaceType Magick::Image::colorSpaceType(void) const
632 return(constOptions()->colorspaceType());
635 size_t Magick::Image::columns(void) const
637 return(constImage()->columns);
640 void Magick::Image::comment(const std::string &comment_)
644 SetImageProperty(image(),"Comment",NULL,&exceptionInfo);
645 if (comment_.length() > 0)
646 SetImageProperty(image(),"Comment",comment_.c_str(),&exceptionInfo);
650 std::string Magick::Image::comment(void) const
656 value=GetImageProperty(constImage(),"Comment",&exceptionInfo);
660 return(std::string(value));
662 return(std::string()); // Intentionally no exception
665 void Magick::Image::compose(const CompositeOperator compose_)
667 image()->compose=compose_;
670 Magick::CompositeOperator Magick::Image::compose(void) const
672 return(constImage()->compose);
675 void Magick::Image::compressType(const CompressionType compressType_)
678 image()->compression=compressType_;
679 options()->compressType(compressType_);
682 Magick::CompressionType Magick::Image::compressType(void) const
684 return(constImage()->compression);
687 void Magick::Image::debug(const bool flag_)
690 options()->debug(flag_);
693 bool Magick::Image::debug(void) const
695 return(constOptions()->debug());
698 void Magick::Image::density(const Geometry &density_)
701 options()->density(density_);
702 if (density_.isValid())
704 image()->resolution.x=density_.width();
705 if (density_.height() != 0)
706 image()->resolution.y=density_.height();
708 image()->resolution.y=density_.width();
713 image()->resolution.x=0;
714 image()->resolution.y=0;
718 Magick::Geometry Magick::Image::density(void) const
726 if (constImage()->resolution.x > 0.0)
727 x_resolution=static_cast<ssize_t>(constImage()->resolution.x + 0.5);
729 if (constImage()->resolution.y > 0.0)
730 y_resolution=static_cast<ssize_t>(constImage()->resolution.y + 0.5);
732 return(Geometry(x_resolution,y_resolution));
735 return(constOptions()->density());
738 void Magick::Image::depth(const size_t depth_)
743 if (depth > MAGICKCORE_QUANTUM_DEPTH)
744 depth=MAGICKCORE_QUANTUM_DEPTH;
747 image()->depth=depth;
748 options()->depth(depth);
751 size_t Magick::Image::depth(void) const
753 return(constImage()->depth);
756 std::string Magick::Image::directory(void) const
758 if (constImage()->directory)
759 return(std::string(constImage()->directory));
761 throwExceptionExplicit(CorruptImageWarning,
762 "Image does not contain a directory");
764 return(std::string());
767 void Magick::Image::endian(const Magick::EndianType endian_)
770 options()->endian(endian_);
771 image()->endian=endian_;
774 Magick::EndianType Magick::Image::endian(void) const
776 return(constImage()->endian);
779 void Magick::Image::exifProfile(const Magick::Blob &exifProfile_)
783 if (exifProfile_.data() != 0)
788 exif_profile=AcquireStringInfo(exifProfile_.length());
789 SetStringInfoDatum(exif_profile,(unsigned char *) exifProfile_.data());
791 (void) SetImageProfile(image(),"exif",exif_profile,&exceptionInfo);
792 exif_profile=DestroyStringInfo(exif_profile);
797 Magick::Blob Magick::Image::exifProfile(void) const
802 exif_profile=GetImageProfile(constImage(),"exif");
803 if (exif_profile == (StringInfo *) NULL)
805 return(Blob(GetStringInfoDatum(exif_profile),
806 GetStringInfoLength(exif_profile)));
809 void Magick::Image::fileName(const std::string &fileName_)
813 fileName_.copy(image()->filename,sizeof(image()->filename)-1);
814 image()->filename[fileName_.length()]=0; // Null terminate
816 options()->fileName(fileName_);
819 std::string Magick::Image::fileName(void) const
821 return(constOptions()->fileName());
824 MagickCore::MagickSizeType Magick::Image::fileSize(void) const
826 return(GetBlobSize(constImage()));
829 void Magick::Image::fillColor(const Magick::Color &fillColor_)
832 options()->fillColor(fillColor_);
835 Magick::Color Magick::Image::fillColor(void) const
837 return(constOptions()->fillColor());
840 void Magick::Image::fillRule(const Magick::FillRule &fillRule_)
843 options()->fillRule(fillRule_);
846 Magick::FillRule Magick::Image::fillRule(void) const
848 return constOptions()->fillRule();
851 void Magick::Image::fillPattern(const Image &fillPattern_)
854 if (fillPattern_.isValid())
855 options()->fillPattern(fillPattern_.constImage());
857 options()->fillPattern(static_cast<MagickCore::Image*>(NULL));
860 Magick::Image Magick::Image::fillPattern(void) const
862 // FIXME: This is inordinately innefficient
863 const MagickCore::Image
869 tmpTexture=constOptions()->fillPattern();
877 image=CloneImage(tmpTexture,0,0,MagickTrue,&exceptionInfo);
878 texture.replaceImage(image);
884 void Magick::Image::filterType(const Magick::FilterTypes filterType_)
887 image()->filter=filterType_;
890 Magick::FilterTypes Magick::Image::filterType(void) const
892 return(constImage()->filter);
895 void Magick::Image::font(const std::string &font_)
898 options()->font(font_);
901 std::string Magick::Image::font(void) const
903 return(constOptions()->font());
906 void Magick::Image::fontPointsize(const double pointSize_)
909 options()->fontPointsize(pointSize_);
912 double Magick::Image::fontPointsize(void) const
914 return(constOptions()->fontPointsize());
917 std::string Magick::Image::format(void) const
923 magick_info=GetMagickInfo(constImage()->magick,&exceptionInfo);
926 if ((magick_info != 0) && (*magick_info->description != '\0'))
927 return(std::string(magick_info->description));
929 throwExceptionExplicit(CorruptImageWarning,"Unrecognized image magick type");
930 return(std::string());
933 std::string Magick::Image::formatExpression(const std::string expression)
942 text=InterpretImageProperties(imageInfo(),image(),expression.c_str(),
944 if (text != (char *) NULL)
946 result=std::string(text);
947 text=DestroyString(text);
953 double Magick::Image::gamma(void) const
955 return(constImage()->gamma);
958 Magick::Geometry Magick::Image::geometry(void) const
960 if (constImage()->geometry)
961 return Geometry(constImage()->geometry);
963 throwExceptionExplicit(OptionWarning,"Image does not contain a geometry");
968 void Magick::Image::gifDisposeMethod(
969 const MagickCore::DisposeType disposeMethod_)
972 image()->dispose=disposeMethod_;
975 MagickCore::DisposeType Magick::Image::gifDisposeMethod(void) const
977 return(constImage()->dispose);
980 void Magick::Image::iccColorProfile(const Magick::Blob &colorProfile_)
982 profile("icm",colorProfile_);
985 Magick::Blob Magick::Image::iccColorProfile(void) const
990 color_profile=GetImageProfile(constImage(),"icc");
991 if (color_profile == (StringInfo *) NULL)
993 return(Blob(GetStringInfoDatum(color_profile),GetStringInfoLength(
997 void Magick::Image::interlaceType(const Magick::InterlaceType interlace_)
1000 image()->interlace=interlace_;
1001 options()->interlaceType(interlace_);
1004 Magick::InterlaceType Magick::Image::interlaceType(void) const
1006 return(constImage()->interlace);
1009 void Magick::Image::interpolate(const PixelInterpolateMethod interpolate_)
1012 image()->interpolate=interpolate_;
1015 Magick::PixelInterpolateMethod Magick::Image::interpolate(void) const
1017 return constImage()->interpolate;
1020 void Magick::Image::iptcProfile(const Magick::Blob &iptcProfile_)
1023 if (iptcProfile_.data() != 0)
1028 iptc_profile=AcquireStringInfo(iptcProfile_.length());
1029 SetStringInfoDatum(iptc_profile,(unsigned char *) iptcProfile_.data());
1031 (void) SetImageProfile(image(),"iptc",iptc_profile,&exceptionInfo);
1032 iptc_profile=DestroyStringInfo(iptc_profile);
1037 Magick::Blob Magick::Image::iptcProfile(void) const
1042 iptc_profile=GetImageProfile(constImage(),"iptc");
1043 if (iptc_profile == (StringInfo *) NULL)
1045 return(Blob(GetStringInfoDatum(iptc_profile),GetStringInfoLength(
1049 void Magick::Image::isValid(const bool isValid_)
1054 _imgRef=new ImageRef;
1056 else if (!isValid())
1058 // Construct with single-pixel black image to make
1059 // image valid. This is an obvious hack.
1060 size(Geometry(1,1));
1065 bool Magick::Image::isValid(void) const
1067 return rows() && columns();
1070 void Magick::Image::label(const std::string &label_)
1074 SetImageProperty(image(),"Label",NULL,&exceptionInfo);
1075 if (label_.length() > 0)
1076 SetImageProperty(image(),"Label",label_.c_str(),&exceptionInfo);
1080 std::string Magick::Image::label(void) const
1086 value=GetImageProperty(constImage(),"Label",&exceptionInfo);
1090 return(std::string(value));
1092 return(std::string());
1095 void Magick::Image::magick(const std::string &magick_)
1099 magick_.copy(image()->magick,sizeof(image()->magick)-1);
1100 image()->magick[magick_.length()]=0;
1102 options()->magick(magick_);
1105 std::string Magick::Image::magick(void) const
1107 if (*(constImage()->magick) != '\0')
1108 return(std::string(constImage()->magick));
1110 return(constOptions()->magick());
1113 double Magick::Image::meanErrorPerPixel(void) const
1115 return(constImage()->error.mean_error_per_pixel);
1118 void Magick::Image::modulusDepth(const size_t depth_)
1122 SetImageDepth(image(),depth_,&exceptionInfo);
1124 options()->depth(depth_);
1127 size_t Magick::Image::modulusDepth(void) const
1133 depth=GetImageDepth(constImage(),&exceptionInfo);
1138 void Magick::Image::monochrome(const bool monochromeFlag_)
1141 options()->monochrome(monochromeFlag_);
1144 bool Magick::Image::monochrome(void) const
1146 return(constOptions()->monochrome());
1149 Magick::Geometry Magick::Image::montageGeometry(void) const
1151 if (constImage()->montage)
1152 return Magick::Geometry(constImage()->montage);
1154 throwExceptionExplicit(CorruptImageWarning,
1155 "Image does not contain a montage");
1157 return(Magick::Geometry());
1160 double Magick::Image::normalizedMaxError(void) const
1162 return(constImage()->error.normalized_maximum_error);
1165 double Magick::Image::normalizedMeanError(void) const
1167 return(constImage()->error.normalized_mean_error);
1170 void Magick::Image::orientation(const Magick::OrientationType orientation_)
1173 image()->orientation=orientation_;
1176 Magick::OrientationType Magick::Image::orientation(void) const
1178 return(constImage()->orientation);
1181 void Magick::Image::page(const Magick::Geometry &pageSize_)
1184 options()->page(pageSize_);
1185 image()->page=pageSize_;
1188 Magick::Geometry Magick::Image::page(void) const
1190 return(Geometry(constImage()->page.width,constImage()->page.height,
1191 AbsoluteValue(constImage()->page.x),AbsoluteValue(constImage()->page.y),
1192 constImage()->page.x < 0 ? true : false,
1193 constImage()->page.y < 0 ? true : false));
1196 void Magick::Image::quality(const size_t quality_)
1199 image()->quality=quality_;
1200 options()->quality(quality_);
1203 size_t Magick::Image::quality(void) const
1205 return(constImage()->quality);
1208 void Magick::Image::quantizeColors(const size_t colors_)
1211 options()->quantizeColors(colors_);
1214 size_t Magick::Image::quantizeColors(void) const
1216 return(constOptions()->quantizeColors());
1219 void Magick::Image::quantizeColorSpace(
1220 const Magick::ColorspaceType colorSpace_)
1223 options()->quantizeColorSpace(colorSpace_);
1226 Magick::ColorspaceType Magick::Image::quantizeColorSpace(void) const
1228 return(constOptions()->quantizeColorSpace());
1231 void Magick::Image::quantizeDither(const bool ditherFlag_)
1234 options()->quantizeDither(ditherFlag_);
1237 bool Magick::Image::quantizeDither(void) const
1239 return(constOptions()->quantizeDither());
1242 void Magick::Image::quantizeDitherMethod(const DitherMethod ditherMethod_)
1245 options()->quantizeDitherMethod(ditherMethod_);
1248 MagickCore::DitherMethod Magick::Image::quantizeDitherMethod(void) const
1250 return(constOptions()->quantizeDitherMethod());
1253 void Magick::Image::quantizeTreeDepth(const size_t treeDepth_)
1256 options()->quantizeTreeDepth(treeDepth_);
1259 size_t Magick::Image::quantizeTreeDepth() const
1261 return(constOptions()->quantizeTreeDepth());
1264 void Magick::Image::renderingIntent(
1265 const Magick::RenderingIntent renderingIntent_)
1268 image()->rendering_intent=renderingIntent_;
1271 Magick::RenderingIntent Magick::Image::renderingIntent(void) const
1273 return(static_cast<Magick::RenderingIntent>(constImage()->rendering_intent));
1276 void Magick::Image::resolutionUnits(
1277 const Magick::ResolutionType resolutionUnits_)
1280 image()->units=resolutionUnits_;
1281 options()->resolutionUnits(resolutionUnits_);
1284 Magick::ResolutionType Magick::Image::resolutionUnits(void) const
1286 return(constOptions()->resolutionUnits());
1289 size_t Magick::Image::rows(void) const
1291 return(constImage()->rows);
1294 void Magick::Image::scene(const size_t scene_)
1297 image()->scene=scene_;
1300 size_t Magick::Image::scene(void) const
1302 return(constImage()->scene);
1305 void Magick::Image::size(const Geometry &geometry_)
1308 options()->size(geometry_);
1309 image()->rows=geometry_.height();
1310 image()->columns=geometry_.width();
1313 Magick::Geometry Magick::Image::size(void) const
1315 return(Magick::Geometry(constImage()->columns,constImage()->rows));
1318 void Magick::Image::strokeAntiAlias(const bool flag_)
1321 options()->strokeAntiAlias(flag_);
1324 bool Magick::Image::strokeAntiAlias(void) const
1326 return(constOptions()->strokeAntiAlias());
1329 void Magick::Image::strokeColor(const Magick::Color &strokeColor_)
1332 options()->strokeColor(strokeColor_);
1335 Magick::Color Magick::Image::strokeColor(void) const
1337 return(constOptions()->strokeColor());
1340 void Magick::Image::strokeDashArray(const double *strokeDashArray_)
1343 options()->strokeDashArray(strokeDashArray_);
1346 const double* Magick::Image::strokeDashArray(void) const
1348 return(constOptions()->strokeDashArray());
1351 void Magick::Image::strokeDashOffset(const double strokeDashOffset_)
1354 options()->strokeDashOffset(strokeDashOffset_);
1357 double Magick::Image::strokeDashOffset(void) const
1359 return(constOptions()->strokeDashOffset());
1362 void Magick::Image::strokeLineCap(const Magick::LineCap lineCap_)
1365 options()->strokeLineCap(lineCap_);
1368 Magick::LineCap Magick::Image::strokeLineCap(void) const
1370 return(constOptions()->strokeLineCap());
1373 void Magick::Image::strokeLineJoin(const Magick::LineJoin lineJoin_)
1376 options()->strokeLineJoin(lineJoin_);
1379 Magick::LineJoin Magick::Image::strokeLineJoin(void) const
1381 return(constOptions()->strokeLineJoin());
1384 void Magick::Image::strokeMiterLimit(const size_t strokeMiterLimit_)
1387 options()->strokeMiterLimit(strokeMiterLimit_);
1390 size_t Magick::Image::strokeMiterLimit(void) const
1392 return(constOptions()->strokeMiterLimit());
1395 void Magick::Image::strokePattern(const Image &strokePattern_)
1398 if(strokePattern_.isValid())
1399 options()->strokePattern(strokePattern_.constImage());
1401 options()->strokePattern(static_cast<MagickCore::Image*>(NULL));
1404 Magick::Image Magick::Image::strokePattern(void) const
1406 // FIXME: This is inordinately innefficient
1407 const MagickCore::Image
1413 tmpTexture=constOptions()->strokePattern();
1421 image=CloneImage(tmpTexture,0,0,MagickTrue,&exceptionInfo);
1422 texture.replaceImage(image);
1428 void Magick::Image::strokeWidth(const double strokeWidth_)
1431 options()->strokeWidth(strokeWidth_);
1434 double Magick::Image::strokeWidth(void) const
1436 return(constOptions()->strokeWidth());
1439 void Magick::Image::subImage(const size_t subImage_)
1442 options()->subImage(subImage_);
1445 size_t Magick::Image::subImage(void) const
1447 return(constOptions()->subImage());
1450 void Magick::Image::subRange(const size_t subRange_)
1453 options()->subRange(subRange_);
1456 size_t Magick::Image::subRange(void) const
1458 return(constOptions()->subRange());
1461 void Magick::Image::textDirection(DirectionType direction_)
1464 options()->textDirection(direction_);
1467 Magick::DirectionType Magick::Image::textDirection(void) const
1469 return(constOptions()->textDirection());
1472 void Magick::Image::textEncoding(const std::string &encoding_)
1475 options()->textEncoding(encoding_);
1478 std::string Magick::Image::textEncoding(void) const
1480 return(constOptions()->textEncoding());
1483 void Magick::Image::textGravity(GravityType gravity_)
1486 options()->textGravity(gravity_);
1489 Magick::GravityType Magick::Image::textGravity(void) const
1491 return(constOptions()->textGravity());
1494 void Magick::Image::textInterlineSpacing(double spacing_)
1497 options()->textInterlineSpacing(spacing_);
1500 double Magick::Image::textInterlineSpacing(void) const
1502 return(constOptions()->textInterlineSpacing());
1505 void Magick::Image::textInterwordSpacing(double spacing_)
1508 options()->textInterwordSpacing(spacing_);
1511 double Magick::Image::textInterwordSpacing(void) const
1513 return(constOptions()->textInterwordSpacing());
1516 void Magick::Image::textKerning(double kerning_)
1519 options()->textKerning(kerning_);
1522 double Magick::Image::textKerning(void) const
1524 return(constOptions()->textKerning());
1527 size_t Magick::Image::totalColors(void) const
1533 colors=GetNumberColors(constImage(),0,&exceptionInfo);
1538 void Magick::Image::transformRotation(const double angle_)
1541 options()->transformRotation(angle_);
1544 void Magick::Image::transformSkewX(const double skewx_)
1547 options()->transformSkewX(skewx_);
1550 void Magick::Image::transformSkewY(const double skewy_)
1553 options()->transformSkewY(skewy_);
1556 Magick::ImageType Magick::Image::type(void) const
1558 if (constOptions()->type() != UndefinedType)
1559 return(constOptions()->type());
1560 else if (constImage()->type != UndefinedType)
1561 return(constImage()->type);
1563 return(determineType());
1566 void Magick::Image::type(const Magick::ImageType type_)
1569 options()->type(type_);
1571 SetImageType(image(),type_,&exceptionInfo);
1575 void Magick::Image::verbose(const bool verboseFlag_)
1578 options()->verbose(verboseFlag_);
1581 bool Magick::Image::verbose(void) const
1583 return(constOptions()->verbose());
1586 void Magick::Image::view(const std::string &view_)
1589 options()->view(view_);
1592 std::string Magick::Image::view(void) const
1594 return(constOptions()->view());
1597 void Magick::Image::virtualPixelMethod(
1598 const VirtualPixelMethod virtualPixelMethod_)
1602 SetImageVirtualPixelMethod(image(),virtualPixelMethod_,&exceptionInfo);
1606 Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod(void) const
1608 return(GetImageVirtualPixelMethod(constImage()));
1611 void Magick::Image::x11Display(const std::string &display_)
1614 options()->x11Display(display_);
1617 std::string Magick::Image::x11Display(void) const
1619 return(constOptions()->x11Display());
1622 double Magick::Image::xResolution(void) const
1624 return(constImage()->resolution.x);
1627 double Magick::Image::yResolution(void) const
1629 return(constImage()->resolution.y);
1632 void Magick::Image::adaptiveBlur(const double radius_,const double sigma_)
1638 newImage=AdaptiveBlurImage(constImage(),radius_,sigma_,&exceptionInfo);
1639 replaceImage(newImage);
1643 void Magick::Image::adaptiveResize(const Geometry &geometry_)
1656 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
1660 newImage=AdaptiveResizeImage(constImage(),width,height,&exceptionInfo);
1661 replaceImage(newImage);
1665 void Magick::Image::adaptiveSharpen(const double radius_,const double sigma_)
1671 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,&exceptionInfo);
1672 replaceImage(newImage);
1676 void Magick::Image::adaptiveSharpenChannel(const ChannelType channel_,
1677 const double radius_,const double sigma_ )
1683 SetPPChannelMask(channel_);
1684 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,&exceptionInfo);
1685 RestorePPChannelMask;
1686 replaceImage(newImage);
1690 void Magick::Image::adaptiveThreshold(const size_t width_,const size_t height_,
1691 const ssize_t offset_)
1698 newImage=AdaptiveThresholdImage(constImage(),width_,height_,offset_,
1700 replaceImage(newImage);
1704 void Magick::Image::addNoise(const NoiseType noiseType_)
1710 newImage=AddNoiseImage(constImage(),noiseType_,1.0,&exceptionInfo);
1711 replaceImage(newImage);
1715 void Magick::Image::addNoiseChannel(const ChannelType channel_,
1716 const NoiseType noiseType_)
1722 SetPPChannelMask(channel_);
1723 newImage=AddNoiseImage(constImage(),noiseType_,1.0,&exceptionInfo);
1724 RestorePPChannelMask;
1725 replaceImage(newImage);
1729 void Magick::Image::affineTransform(const DrawableAffine &affine_)
1737 _affine.sx=affine_.sx();
1738 _affine.sy=affine_.sy();
1739 _affine.rx=affine_.rx();
1740 _affine.ry=affine_.ry();
1741 _affine.tx=affine_.tx();
1742 _affine.ty=affine_.ty();
1745 newImage=AffineTransformImage(constImage(),&_affine,&exceptionInfo);
1746 replaceImage(newImage);
1750 void Magick::Image::alpha(const unsigned int alpha_)
1754 SetImageAlpha(image(),alpha_,&exceptionInfo);
1758 void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
1762 SetImageAlphaChannel(image(),alphaOption_,&exceptionInfo);
1766 void Magick::Image::alphaFloodfill(const Color &target_,
1767 const unsigned int alpha_,const ssize_t x_,const ssize_t y_,
1768 const Magick::PaintMethod method_)
1774 GetPixelInfo(constImage(),&target);
1775 target.red=static_cast<PixelInfo>(target_).red;
1776 target.green=static_cast<PixelInfo>(target_).green;
1777 target.blue=static_cast<PixelInfo>(target_).blue;
1778 target.alpha=alpha_;
1780 SetPPChannelMask(AlphaChannel);
1781 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
1782 method_ == FloodfillMethod ? MagickFalse : MagickTrue,&exceptionInfo);
1783 RestorePPChannelMask;
1787 void Magick::Image::annotate(const std::string &text_,
1788 const Geometry &location_)
1790 annotate(text_,location_,NorthWestGravity,0.0);
1793 void Magick::Image::annotate(const std::string &text_,
1794 const Geometry &boundingArea_,const GravityType gravity_)
1796 annotate(text_,boundingArea_,gravity_,0.0);
1799 void Magick::Image::annotate(const std::string &text_,
1800 const Geometry &boundingArea_,const GravityType gravity_,
1801 const double degrees_)
1807 boundingArea[MaxTextExtent];
1814 drawInfo=options()->drawInfo();
1815 drawInfo->text=const_cast<char *>(text_.c_str());
1816 drawInfo->geometry=0;
1818 if (boundingArea_.isValid())
1820 if (boundingArea_.width() == 0 || boundingArea_.height() == 0)
1822 FormatLocaleString(boundingArea,MaxTextExtent,"%+.20g%+.20g",
1823 (double) boundingArea_.xOff(),(double) boundingArea_.yOff());
1827 (void) CopyMagickString(boundingArea,string(boundingArea_).c_str(),
1830 drawInfo->geometry=boundingArea;
1833 drawInfo->gravity=gravity_;
1835 oaffine=drawInfo->affine;
1836 if (degrees_ != 0.0)
1849 current=drawInfo->affine;
1850 affine.sx=cos(DegreesToRadians(fmod(degrees_,360.0)));
1851 affine.rx=sin(DegreesToRadians(fmod(degrees_,360.0)));
1852 affine.ry=(-sin(DegreesToRadians(fmod(degrees_,360.0))));
1853 affine.sy=cos(DegreesToRadians(fmod(degrees_,360.0)));
1855 drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
1856 drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
1857 drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
1858 drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
1859 drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty
1864 AnnotateImage(image(),drawInfo,&exceptionInfo);
1866 // Restore original values
1867 drawInfo->affine=oaffine;
1869 drawInfo->geometry=0;
1874 void Magick::Image::annotate(const std::string &text_,
1875 const GravityType gravity_)
1882 drawInfo=options()->drawInfo();
1883 drawInfo->text=const_cast<char *>(text_.c_str());
1884 drawInfo->gravity=gravity_;
1887 AnnotateImage(image(),drawInfo,&exceptionInfo);
1889 drawInfo->gravity=NorthWestGravity;
1895 void Magick::Image::artifact(const std::string &name_,const std::string &value_)
1898 (void) SetImageArtifact(image(),name_.c_str(),value_.c_str());
1901 std::string Magick::Image::artifact(const std::string &name_)
1906 value=GetImageArtifact(constImage(),name_.c_str());
1908 return(std::string(value));
1909 return(std::string());
1912 void Magick::Image::attribute(const std::string name_,const std::string value_)
1916 SetImageProperty(image(),name_.c_str(),value_.c_str(),&exceptionInfo);
1920 std::string Magick::Image::attribute(const std::string name_)
1926 value=GetImageProperty(constImage(),name_.c_str(),&exceptionInfo);
1930 return(std::string(value));
1932 return(std::string()); // Intentionally no exception
1935 void Magick::Image::autoGamma(void)
1939 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
1940 (void) AutoGammaImage(image(),&exceptionInfo);
1944 void Magick::Image::autoGammaChannel(const ChannelType channel_)
1948 SetPPChannelMask(channel_);
1949 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
1950 (void) AutoGammaImage(image(),&exceptionInfo);
1951 RestorePPChannelMask;
1955 void Magick::Image::autoLevel(void)
1959 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
1960 (void) AutoLevelImage(image(),&exceptionInfo);
1964 void Magick::Image::autoLevelChannel(const ChannelType channel_)
1968 SetPPChannelMask(channel_);
1969 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
1970 (void) AutoLevelImage(image(),&exceptionInfo);
1971 RestorePPChannelMask;
1975 void Magick::Image::autoOrient(void)
1980 if (image()->orientation == UndefinedOrientation ||
1981 image()->orientation == TopLeftOrientation)
1985 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
1986 newImage=AutoOrientImage(constImage(),image()->orientation,&exceptionInfo);
1987 replaceImage(newImage);
1991 void Magick::Image::blackThreshold(const std::string &threshold_)
1995 BlackThresholdImage(image(),threshold_.c_str(),&exceptionInfo);
1999 void Magick::Image::blackThresholdChannel(const ChannelType channel_,
2000 const std::string &threshold_)
2004 SetPPChannelMask(channel_);
2005 BlackThresholdImage(image(),threshold_.c_str(),&exceptionInfo);
2006 RestorePPChannelMask;
2010 void Magick::Image::blueShift(const double factor_)
2016 newImage=BlueShiftImage(constImage(),factor_,&exceptionInfo);
2017 replaceImage(newImage);
2021 void Magick::Image::blur(const double radius_,const double sigma_)
2027 newImage=BlurImage(constImage(),radius_,sigma_,&exceptionInfo);
2028 replaceImage(newImage);
2032 void Magick::Image::blurChannel(const ChannelType channel_,
2033 const double radius_,const double sigma_)
2039 SetPPChannelMask(channel_);
2040 newImage=BlurImage(constImage(),radius_,sigma_,&exceptionInfo);
2041 RestorePPChannelMask;
2042 replaceImage(newImage);
2046 void Magick::Image::border(const Geometry &geometry_)
2052 borderInfo=geometry_;
2055 newImage=BorderImage(constImage(),&borderInfo,image()->compose,
2057 replaceImage(newImage);
2061 void Magick::Image::brightnessContrast(const double brightness_,
2062 const double contrast_)
2066 BrightnessContrastImage(image(),brightness_,contrast_,&exceptionInfo);
2070 void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
2071 const double brightness_,const double contrast_)
2075 SetPPChannelMask(channel_);
2076 BrightnessContrastImage(image(),brightness_,contrast_,&exceptionInfo);
2077 RestorePPChannelMask;
2081 void Magick::Image::cannyEdge(const double radius_,const double sigma_,
2082 const double lowerPercent_,const double upperPercent_)
2089 newImage=CannyEdgeImage(constImage(),radius_,sigma_,lowerPercent_,
2090 upperPercent_,&exceptionInfo);
2091 replaceImage(newImage);
2095 void Magick::Image::channel(const ChannelType channel_)
2101 newImage=SeparateImage(image(),channel_,&exceptionInfo);
2102 replaceImage(newImage);
2106 void Magick::Image::charcoal(const double radius_,const double sigma_)
2112 newImage=CharcoalImage(image(),radius_,sigma_,&exceptionInfo);
2113 replaceImage(newImage);
2117 void Magick::Image::chop(const Geometry &geometry_)
2126 newImage=ChopImage(image(),&chopInfo,&exceptionInfo);
2127 replaceImage(newImage);
2131 void Magick::Image::chromaBluePrimary(const double x_,const double y_)
2134 image()->chromaticity.blue_primary.x=x_;
2135 image()->chromaticity.blue_primary.y=y_;
2138 void Magick::Image::chromaBluePrimary(double *x_,double *y_) const
2140 *x_=constImage()->chromaticity.blue_primary.x;
2141 *y_=constImage()->chromaticity.blue_primary.y;
2144 void Magick::Image::chromaGreenPrimary(const double x_,const double y_)
2147 image()->chromaticity.green_primary.x=x_;
2148 image()->chromaticity.green_primary.y=y_;
2151 void Magick::Image::chromaGreenPrimary(double *x_,double *y_) const
2153 *x_=constImage()->chromaticity.green_primary.x;
2154 *y_=constImage()->chromaticity.green_primary.y;
2157 void Magick::Image::chromaRedPrimary(const double x_,const double y_)
2160 image()->chromaticity.red_primary.x=x_;
2161 image()->chromaticity.red_primary.y=y_;
2164 void Magick::Image::chromaRedPrimary(double *x_,double *y_) const
2166 *x_=constImage()->chromaticity.red_primary.x;
2167 *y_=constImage()->chromaticity.red_primary.y;
2170 void Magick::Image::chromaWhitePoint(const double x_,const double y_)
2173 image()->chromaticity.white_point.x=x_;
2174 image()->chromaticity.white_point.y=y_;
2177 void Magick::Image::chromaWhitePoint(double *x_,double *y_) const
2179 *x_=constImage()->chromaticity.white_point.x;
2180 *y_=constImage()->chromaticity.white_point.y;
2183 void Magick::Image::cdl(const std::string &cdl_)
2187 (void) ColorDecisionListImage(image(),cdl_.c_str(),&exceptionInfo);
2191 void Magick::Image::clamp(void)
2195 ClampImage(image(),&exceptionInfo);
2199 void Magick::Image::clampChannel(const ChannelType channel_)
2203 SetPPChannelMask(channel_);
2204 ClampImage(image(),&exceptionInfo);
2205 RestorePPChannelMask;
2209 void Magick::Image::clip(void)
2213 ClipImage(image(),&exceptionInfo);
2217 void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
2221 ClipImagePath(image(),pathname_.c_str(),(MagickBooleanType) inside_,
2226 void Magick::Image::clut(const Image &clutImage_,
2227 const PixelInterpolateMethod method)
2231 ClutImage(image(),clutImage_.constImage(),method,&exceptionInfo);
2235 void Magick::Image::clutChannel(const ChannelType channel_,
2236 const Image &clutImage_,const PixelInterpolateMethod method)
2240 SetPPChannelMask(channel_);
2241 ClutImage(image(),clutImage_.constImage(),method,&exceptionInfo);
2242 RestorePPChannelMask;
2246 void Magick::Image::colorize(const unsigned int alpha_,const Color &penColor_)
2248 colorize(alpha_,alpha_,alpha_,penColor_);
2251 void Magick::Image::colorize(const unsigned int alphaRed_,
2252 const unsigned int alphaGreen_,const unsigned int alphaBlue_,
2253 const Color &penColor_)
2256 blend[MaxTextExtent];
2265 if (!penColor_.isValid())
2266 throwExceptionExplicit(OptionError,"Pen color argument is invalid");
2268 FormatLocaleString(blend,MaxTextExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
2271 GetPixelInfo(image(),&target);
2272 pixel=static_cast<PixelInfo>(penColor_);
2273 target.red=pixel.red;
2274 target.green=pixel.green;
2275 target.blue=pixel.blue;
2276 target.alpha=pixel.alpha;
2278 newImage=ColorizeImage(image(),blend,&target,&exceptionInfo);
2279 replaceImage(newImage);
2283 void Magick::Image::colorMap(const size_t index_,const Color &color_)
2290 if (index_ > (MaxColormapSize-1))
2291 throwExceptionExplicit(OptionError,
2292 "Colormap index must be less than MaxColormapSize");
2294 if (!color_.isValid())
2295 throwExceptionExplicit(OptionError,"Color argument is invalid");
2299 // Ensure that colormap size is large enough
2300 if (colorMapSize() < (index_+1))
2301 colorMapSize(index_+1);
2303 // Set color at index in colormap
2304 (imageptr->colormap)[index_]=color_;
2307 Magick::Color Magick::Image::colorMap(const size_t index_) const
2309 if (!constImage()->colormap)
2311 throwExceptionExplicit(OptionError,"Image does not contain a colormap");
2315 if (index_ > constImage()->colors-1)
2316 throwExceptionExplicit(OptionError,"Index out of range");
2318 return(Magick::Color((constImage()->colormap)[index_]));
2321 void Magick::Image::colorMatrix(const size_t order_,
2322 const double *color_matrix_)
2328 kernel_info=AcquireKernelInfo((const char *) NULL);
2329 kernel_info->width=order_;
2330 kernel_info->height=order_;
2331 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2332 order_*sizeof(*kernel_info->values));
2333 if (kernel_info->values != (MagickRealType *) NULL)
2338 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2339 kernel_info->values[i]=color_matrix_[i];
2340 newImage=ColorMatrixImage(image(),kernel_info,&exceptionInfo);
2341 replaceImage(newImage);
2343 kernel_info=DestroyKernelInfo(kernel_info);
2347 bool Magick::Image::compare(const Image &reference_)
2358 status=static_cast<bool>(IsImagesEqual(image(),ref.image(),&exceptionInfo));
2363 double Magick::Image::compare(const Image &reference_,const MetricType metric_)
2369 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2375 double Magick::Image::compareChannel(const ChannelType channel_,
2376 const Image &reference_,const MetricType metric_)
2382 SetPPChannelMask(channel_);
2383 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2385 RestorePPChannelMask;
2390 Magick::Image Magick::Image::compare(const Image &reference_,
2391 const MetricType metric_,double *distortion)
2397 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2400 if (newImage == (MagickCore::Image *) NULL)
2401 return(Magick::Image());
2403 return(Magick::Image(newImage));
2406 Magick::Image Magick::Image::compareChannel(const ChannelType channel_,
2407 const Image &reference_,const MetricType metric_,double *distortion)
2413 SetPPChannelMask(channel_);
2414 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2416 RestorePPChannelMask;
2418 if (newImage == (MagickCore::Image *) NULL)
2419 return(Magick::Image());
2421 return(Magick::Image(newImage));
2424 void Magick::Image::composite(const Image &compositeImage_,
2425 const Geometry &offset_,const CompositeOperator compose_)
2435 ParseMetaGeometry(static_cast<std::string>(offset_).c_str(),&x,&y,&width,
2440 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickFalse,
2441 x,y,&exceptionInfo);
2445 void Magick::Image::composite(const Image &compositeImage_,
2446 const GravityType gravity_,const CompositeOperator compose_)
2452 SetGeometry(compositeImage_.constImage(),&geometry);
2453 GravityAdjustGeometry(columns(),rows(),gravity_,&geometry);
2456 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickFalse,
2457 geometry.x,geometry.y,&exceptionInfo);
2461 void Magick::Image::composite(const Image &compositeImage_,
2462 const ssize_t xOffset_,const ssize_t yOffset_,
2463 const CompositeOperator compose_)
2465 // Image supplied as compositeImage is composited with current image and
2466 // results in updating current image.
2469 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickFalse,
2470 xOffset_,yOffset_,&exceptionInfo);
2474 void Magick::Image::contrast(const size_t sharpen_)
2478 ContrastImage(image(),(MagickBooleanType) sharpen_,&exceptionInfo);
2482 void Magick::Image::contrastStretch(const double blackPoint_,
2483 const double whitePoint_)
2487 ContrastStretchImage(image(),blackPoint_,whitePoint_,&exceptionInfo);
2491 void Magick::Image::contrastStretchChannel(const ChannelType channel_,
2492 const double blackPoint_,const double whitePoint_)
2496 SetPPChannelMask(channel_);
2497 ContrastStretchImage(image(),blackPoint_,whitePoint_,&exceptionInfo);
2498 RestorePPChannelMask;
2502 void Magick::Image::convolve(const size_t order_,const double *kernel_)
2508 kernel_info=AcquireKernelInfo((const char *) NULL);
2509 kernel_info->width=order_;
2510 kernel_info->height=order_;
2511 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2512 order_*sizeof(*kernel_info->values));
2513 if (kernel_info->values != (MagickRealType *) NULL)
2518 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2519 kernel_info->values[i]=kernel_[i];
2520 newImage=ConvolveImage(image(),kernel_info,&exceptionInfo);
2521 replaceImage(newImage);
2523 kernel_info=DestroyKernelInfo(kernel_info);
2527 void Magick::Image::crop(const Geometry &geometry_)
2536 newImage=CropImage(constImage(),&cropInfo,&exceptionInfo);
2537 replaceImage(newImage);
2541 void Magick::Image::cycleColormap(const ssize_t amount_)
2545 CycleColormapImage(image(),amount_,&exceptionInfo);
2549 void Magick::Image::decipher(const std::string &passphrase_)
2553 DecipherImage(image(),passphrase_.c_str(),&exceptionInfo);
2557 void Magick::Image::defineSet(const std::string &magick_,
2558 const std::string &key_,bool flag_)
2564 definition=magick_ + ":" + key_;
2566 (void) SetImageOption(imageInfo(),definition.c_str(),"");
2568 DeleteImageOption(imageInfo(),definition.c_str());
2571 bool Magick::Image::defineSet(const std::string &magick_,
2572 const std::string &key_ ) const
2580 key=magick_ + ":" + key_;
2581 option=GetImageOption(constImageInfo(),key.c_str());
2587 void Magick::Image::defineValue(const std::string &magick_,
2588 const std::string &key_,const std::string &value_)
2595 format=magick_ + ":" + key_;
2597 (void) SetImageOption(imageInfo(),format.c_str(),option.c_str());
2600 std::string Magick::Image::defineValue(const std::string &magick_,
2601 const std::string &key_) const
2609 definition=magick_ + ":" + key_;
2610 option=GetImageOption(constImageInfo(),definition.c_str());
2612 return(std::string(option));
2613 return(std::string());
2616 void Magick::Image::deskew(const double threshold_)
2622 newImage=DeskewImage(constImage(),threshold_,&exceptionInfo);
2623 replaceImage(newImage);
2627 void Magick::Image::despeckle(void)
2633 newImage=DespeckleImage(constImage(),&exceptionInfo);
2634 replaceImage(newImage);
2638 Magick::ImageType Magick::Image::determineType(void) const
2644 image_type=GetImageType(constImage(),&exceptionInfo);
2649 void Magick::Image::display(void)
2652 DisplayImages(imageInfo(),image(),&exceptionInfo);
2656 void Magick::Image::distort(const DistortImageMethod method_,
2657 const size_t numberArguments_,const double *arguments_,const bool bestfit_)
2663 newImage=DistortImage(constImage(), method_,numberArguments_,arguments_,
2664 bestfit_ == true ? MagickTrue : MagickFalse,&exceptionInfo);
2665 replaceImage(newImage);
2669 void Magick::Image::draw(const Magick::Drawable &drawable_)
2676 wand=DrawAllocateWand(options()->drawInfo(),image());
2680 drawable_.operator()(wand);
2684 ClonePPDrawException(wand);
2685 wand=DestroyDrawingWand(wand);
2686 ThrowPPDrawException;
2690 void Magick::Image::draw(const std::list<Magick::Drawable> &drawable_)
2697 wand=DrawAllocateWand(options()->drawInfo(),image());
2701 for (std::list<Magick::Drawable>::const_iterator p = drawable_.begin();
2702 p != drawable_.end(); p++ )
2704 p->operator()(wand);
2705 if (DrawGetExceptionType(wand) != UndefinedException)
2709 if (DrawGetExceptionType(wand) == UndefinedException)
2712 ClonePPDrawException(wand);
2713 wand=DestroyDrawingWand(wand);
2714 ThrowPPDrawException;
2718 void Magick::Image::edge(const double radius_)
2724 newImage=EdgeImage(constImage(),radius_,&exceptionInfo);
2725 replaceImage(newImage);
2729 void Magick::Image::emboss(const double radius_,const double sigma_)
2735 newImage=EmbossImage(constImage(),radius_,sigma_,&exceptionInfo);
2736 replaceImage(newImage);
2740 void Magick::Image::encipher(const std::string &passphrase_)
2744 EncipherImage(image(),passphrase_.c_str(),&exceptionInfo);
2748 void Magick::Image::enhance(void)
2754 newImage=EnhanceImage(constImage(),&exceptionInfo);
2755 replaceImage(newImage);
2759 void Magick::Image::equalize(void)
2763 EqualizeImage(image(),&exceptionInfo);
2767 void Magick::Image::erase(void)
2771 SetImageBackgroundColor(image(),&exceptionInfo);
2775 void Magick::Image::extent(const Geometry &geometry_ )
2781 extentInfo=geometry_;
2784 extentInfo.x=geometry_.xOff();
2785 extentInfo.y=geometry_.yOff();
2787 newImage=ExtentImage(image(),&extentInfo,&exceptionInfo);
2788 replaceImage(newImage);
2792 void Magick::Image::extent(const Geometry &geometry_,
2793 const Color &backgroundColor_)
2795 backgroundColor(backgroundColor_);
2799 void Magick::Image::extent(const Geometry &geometry_,
2800 const Color &backgroundColor_,const GravityType gravity_)
2802 backgroundColor(backgroundColor_);
2803 extent(geometry_,gravity_);
2806 void Magick::Image::extent(const Geometry &geometry_,
2807 const GravityType gravity_)
2812 SetGeometry(image(),&geometry);
2813 geometry.width=geometry_.width();
2814 geometry.height=geometry_.height();
2815 GravityAdjustGeometry(image()->columns,image()->rows,gravity_,&geometry);
2819 void Magick::Image::flip(void)
2825 newImage=FlipImage(constImage(),&exceptionInfo);
2826 replaceImage(newImage);
2830 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2831 const unsigned int alpha_,const PaintMethod method_)
2838 GetPixelInfo(image(),&target);
2839 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2840 target.red=pixel.red;
2841 target.green=pixel.green;
2842 target.blue=pixel.blue;
2843 target.alpha=alpha_;
2846 FloodfillPaintImage(image(),options()->drawInfo(),&target,
2847 static_cast<ssize_t>(x_), static_cast<ssize_t>(y_),
2848 method_ == FloodfillMethod ? MagickFalse : MagickTrue,&exceptionInfo);
2852 void Magick::Image::floodFillColor(const Geometry &point_,
2853 const Magick::Color &fillColor_)
2855 floodFillTexture(point_,Image(Geometry(1,1),fillColor_));
2858 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2859 const Magick::Color &fillColor_)
2861 floodFillTexture(x_,y_,Image(Geometry(1,1),fillColor_));
2864 void Magick::Image::floodFillColor(const Geometry &point_,
2865 const Magick::Color &fillColor_,const Magick::Color &borderColor_)
2867 floodFillTexture(point_,Image(Geometry(1,1),fillColor_),borderColor_);
2870 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2871 const Magick::Color &fillColor_,const Magick::Color &borderColor_)
2873 floodFillTexture(x_,y_,Image(Geometry(1,1),fillColor_),borderColor_);
2876 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2877 const Magick::Image &texture_)
2879 floodFillTexture(point_.xOff(),point_.yOff(),texture_);
2882 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2883 const Magick::Image &texture_)
2893 // Set drawing fill pattern
2894 fillPattern=(MagickCore::Image *)NULL;
2895 if (options()->fillPattern() != (MagickCore::Image *)NULL)
2898 fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
2902 options()->fillPattern(texture_.constImage());
2905 Pixels pixels(*this);
2907 p=pixels.get(x_,y_,1,1);
2914 GetPixelInfo(constImage(),&target);
2915 target.red=GetPixelRed(constImage(),p);
2916 target.green=GetPixelGreen(constImage(),p);
2917 target.blue=GetPixelBlue(constImage(),p);
2919 FloodfillPaintImage(image(),options()->drawInfo(),&target,
2920 static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),MagickFalse,
2922 options()->fillPattern(fillPattern);
2926 options()->fillPattern(fillPattern);
2929 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2930 const Magick::Image &texture_,const Magick::Color &borderColor_)
2932 floodFillTexture(point_.xOff(),point_.yOff(),texture_,borderColor_);
2935 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2936 const Magick::Image &texture_,const Magick::Color &borderColor_)
2946 // Set drawing fill pattern
2947 fillPattern=(MagickCore::Image *)NULL;
2948 if (options()->fillPattern() != (MagickCore::Image *)NULL)
2951 fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
2955 options()->fillPattern(texture_.constImage());
2957 GetPixelInfo(constImage(),&target);
2958 target.red=static_cast<PixelInfo>(borderColor_).red;
2959 target.green=static_cast<PixelInfo>(borderColor_).green;
2960 target.blue=static_cast<PixelInfo>(borderColor_).blue;
2962 FloodfillPaintImage(image(),options()->drawInfo(),&target,
2963 static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),MagickTrue,
2965 options()->fillPattern(fillPattern);
2969 void Magick::Image::flop(void)
2975 newImage=FlopImage(constImage(),&exceptionInfo);
2976 replaceImage(newImage);
2980 void Magick::Image::fontTypeMetrics(const std::string &text_,
2981 TypeMetric *metrics)
2986 drawInfo=options()->drawInfo();
2987 drawInfo->text=const_cast<char *>(text_.c_str());
2989 GetTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),&exceptionInfo);
2994 void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
2995 TypeMetric *metrics)
3000 drawInfo=options()->drawInfo();
3001 drawInfo->text=const_cast<char *>(text_.c_str());
3003 GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),&exceptionInfo);
3008 void Magick::Image::frame(const Geometry &geometry_)
3016 info.x=static_cast<ssize_t>(geometry_.width());
3017 info.y=static_cast<ssize_t>(geometry_.height());
3018 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3019 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3020 info.outer_bevel=geometry_.xOff();
3021 info.inner_bevel=geometry_.yOff();
3024 newImage=FrameImage(constImage(),&info,image()->compose,&exceptionInfo);
3025 replaceImage(newImage);
3029 void Magick::Image::frame(const size_t width_,const size_t height_,
3030 const ssize_t outerBevel_,const ssize_t innerBevel_)
3038 info.x=static_cast<ssize_t>(width_);
3039 info.y=static_cast<ssize_t>(height_);
3040 info.width=columns() + (static_cast<size_t>(info.x) << 1);
3041 info.height=rows() + (static_cast<size_t>(info.y) << 1);
3042 info.outer_bevel=static_cast<ssize_t>(outerBevel_);
3043 info.inner_bevel=static_cast<ssize_t>(innerBevel_);
3046 newImage=FrameImage(constImage(),&info,image()->compose,&exceptionInfo);
3047 replaceImage(newImage);
3051 void Magick::Image::fx(const std::string expression_)
3057 newImage=FxImage(constImage(),expression_.c_str(),&exceptionInfo);
3058 replaceImage(newImage);
3062 void Magick::Image::fx(const std::string expression_,
3063 const Magick::ChannelType channel_)
3069 SetPPChannelMask(channel_);
3070 newImage=FxImage(constImage(),expression_.c_str(),&exceptionInfo);
3071 RestorePPChannelMask;
3072 replaceImage(newImage);
3076 void Magick::Image::gamma(const double gamma_)
3080 GammaImage(image(),gamma_,&exceptionInfo);
3084 void Magick::Image::gamma(const double gammaRed_,const double gammaGreen_,
3085 const double gammaBlue_)
3088 gamma[MaxTextExtent + 1];
3090 FormatLocaleString(gamma,MaxTextExtent,"%3.6f/%3.6f/%3.6f/",gammaRed_,
3091 gammaGreen_,gammaBlue_);
3095 GammaImage(image(),atof(gamma),&exceptionInfo);
3099 void Magick::Image::gaussianBlur(const double width_,const double sigma_)
3105 newImage=GaussianBlurImage(constImage(),width_,sigma_,&exceptionInfo);
3106 replaceImage(newImage);
3110 void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
3111 const double width_,const double sigma_)
3117 SetPPChannelMask(channel_);
3118 newImage=GaussianBlurImage(constImage(),width_,sigma_,&exceptionInfo);
3119 RestorePPChannelMask;
3120 replaceImage(newImage);
3124 const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
3125 const ssize_t y_,const size_t columns_,const size_t rows_) const
3131 p=(*GetVirtualPixels)(constImage(),x_, y_,columns_, rows_,&exceptionInfo);
3136 const void *Magick::Image::getConstMetacontent(void) const
3141 result=GetVirtualMetacontent(constImage());
3144 throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
3149 void *Magick::Image::getMetacontent(void )
3154 result=GetAuthenticMetacontent(image());
3157 throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
3162 Magick::Quantum *Magick::Image::getPixels(const ssize_t x_,const ssize_t y_,
3163 const size_t columns_,const size_t rows_)
3170 result=(*GetAuthenticPixels)(image(),x_, y_,columns_,rows_,&exceptionInfo);
3176 void Magick::Image::haldClut(const Image &clutImage_)
3180 (void) HaldClutImage(image(),clutImage_.constImage(),&exceptionInfo);
3184 void Magick::Image::houghLine(const size_t width_,const size_t height_,
3185 const size_t threshold_)
3191 newImage=HoughLineImage(constImage(),width_,height_,threshold_,
3193 replaceImage(newImage);
3197 void Magick::Image::implode(const double factor_)
3203 newImage=ImplodeImage(constImage(),factor_,image()->interpolate,
3205 replaceImage(newImage);
3209 void Magick::Image::inverseFourierTransform(const Image &phase_)
3211 inverseFourierTransform(phase_,true);
3214 void Magick::Image::inverseFourierTransform(const Image &phase_,
3215 const bool magnitude_)
3221 newImage=InverseFourierTransformImage(constImage(),phase_.constImage(),
3222 magnitude_ == true ? MagickTrue : MagickFalse,&exceptionInfo);
3223 replaceImage(newImage);
3227 void Magick::Image::level(const double blackPoint_,const double whitePoint_,
3228 const double gamma_)
3232 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,&exceptionInfo);
3236 void Magick::Image::levelChannel(const ChannelType channel_,
3237 const double blackPoint_,const double whitePoint_,const double gamma_)
3241 SetPPChannelMask(channel_);
3242 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,&exceptionInfo);
3243 RestorePPChannelMask;
3247 void Magick::Image::levelColors(const Color &blackColor_,
3248 const Color &whiteColor_,const bool invert_)
3257 GetPixelInfo(image(),&black);
3258 pixel=static_cast<PixelInfo>(blackColor_);
3259 black.red=pixel.red;
3260 black.green=pixel.green;
3261 black.blue=pixel.blue;
3262 black.alpha=pixel.alpha;
3264 GetPixelInfo(image(),&white);
3265 pixel=static_cast<PixelInfo>(whiteColor_);
3266 white.red=pixel.red;
3267 white.green=pixel.green;
3268 white.blue=pixel.blue;
3269 white.alpha=pixel.alpha;
3272 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3273 MagickTrue : MagickFalse,&exceptionInfo);
3277 void Magick::Image::levelColorsChannel(const ChannelType channel_,
3278 const Color &blackColor_,const Color &whiteColor_,const bool invert_)
3287 GetPixelInfo(image(),&black);
3288 pixel=static_cast<PixelInfo>(blackColor_);
3289 black.red=pixel.red;
3290 black.green=pixel.green;
3291 black.blue=pixel.blue;
3292 black.alpha=pixel.alpha;
3294 GetPixelInfo(image(),&white);
3295 pixel=static_cast<PixelInfo>(whiteColor_);
3296 white.red=pixel.red;
3297 white.green=pixel.green;
3298 white.blue=pixel.blue;
3299 white.alpha=pixel.alpha;
3302 SetPPChannelMask(channel_);
3303 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3304 MagickTrue : MagickFalse,&exceptionInfo);
3305 RestorePPChannelMask;
3309 void Magick::Image::linearStretch(const double blackPoint_,
3310 const double whitePoint_)
3314 LinearStretchImage(image(),blackPoint_,whitePoint_,&exceptionInfo);
3318 void Magick::Image::liquidRescale(const Geometry &geometry_)
3331 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3335 newImage=LiquidRescaleImage(image(),width,height,x,y,&exceptionInfo);
3336 replaceImage(newImage);
3340 void Magick::Image::magnify(void)
3346 newImage=MagnifyImage(constImage(),&exceptionInfo);
3347 replaceImage(newImage);
3351 void Magick::Image::map(const Image &mapImage_,const bool dither_)
3355 options()->quantizeDither(dither_);
3356 RemapImage(options()->quantizeInfo(),image(),mapImage_.constImage(),
3361 void Magick::Image::medianFilter(const double radius_)
3367 newImage=StatisticImage(image(),MedianStatistic,(size_t) radius_,
3368 (size_t) radius_,&exceptionInfo);
3369 replaceImage(newImage);
3373 void Magick::Image::minify(void)
3379 newImage=MinifyImage(constImage(),&exceptionInfo);
3380 replaceImage(newImage);
3384 void Magick::Image::modulate(const double brightness_,const double saturation_,
3388 modulate[MaxTextExtent + 1];
3390 FormatLocaleString(modulate,MaxTextExtent,"%3.6f,%3.6f,%3.6f",brightness_,
3395 ModulateImage(image(),modulate,&exceptionInfo);
3399 Magick::ChannelMoments Magick::Image::moments(void)
3404 MagickCore::ChannelMoments*
3408 channel_moments=GetImageMoments(constImage(),&exceptionInfo);
3409 if (channel_moments != (MagickCore::ChannelMoments *) NULL)
3411 channelMoments=ChannelMoments(channel_moments);
3412 channel_moments=(MagickCore::ChannelMoments *) RelinquishMagickMemory(
3416 return(channelMoments);
3419 void Magick::Image::morphology(const MorphologyMethod method_,
3420 const std::string kernel_,const ssize_t iterations_)
3428 kernel=AcquireKernelInfo(kernel_.c_str());
3429 if (kernel == (KernelInfo *)NULL)
3430 throwExceptionExplicit(OptionError,"Unable to parse kernel.");
3433 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3435 replaceImage(newImage);
3436 kernel=DestroyKernelInfo(kernel);
3440 void Magick::Image::morphology(const MorphologyMethod method_,
3441 const KernelInfoType kernel_,const std::string arguments_,
3442 const ssize_t iterations_)
3450 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3451 if (option == (const char *)NULL)
3452 throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
3454 kernel=std::string(option);
3455 if (!arguments_.empty())
3456 kernel+=":"+arguments_;
3458 morphology(method_,kernel,iterations_);
3461 void Magick::Image::morphologyChannel(const ChannelType channel_,
3462 const MorphologyMethod method_,const std::string kernel_,
3463 const ssize_t iterations_)
3471 kernel=AcquireKernelInfo(kernel_.c_str());
3472 if (kernel == (KernelInfo *)NULL)
3473 throwExceptionExplicit(OptionError,"Unable to parse kernel.");
3476 SetPPChannelMask(channel_);
3477 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3479 RestorePPChannelMask;
3480 replaceImage(newImage);
3481 kernel=DestroyKernelInfo(kernel);
3485 void Magick::Image::morphologyChannel(const ChannelType channel_,
3486 const MorphologyMethod method_,const KernelInfoType kernel_,
3487 const std::string arguments_,const ssize_t iterations_)
3495 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3496 if (option == (const char *)NULL)
3497 throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
3499 kernel=std::string(option);
3500 if (!arguments_.empty())
3501 kernel+=":"+arguments_;
3503 morphologyChannel(channel_,method_,kernel,iterations_);
3506 void Magick::Image::motionBlur(const double radius_,const double sigma_,
3507 const double angle_)
3513 newImage=MotionBlurImage(constImage(),radius_,sigma_,angle_,&exceptionInfo);
3514 replaceImage(newImage);
3518 void Magick::Image::negate(const bool grayscale_)
3522 NegateImage(image(),(MagickBooleanType) grayscale_,&exceptionInfo);
3526 void Magick::Image::negateChannel(const ChannelType channel_,
3527 const bool grayscale_)
3531 SetPPChannelMask(channel_);
3532 NegateImage(image(),(MagickBooleanType) grayscale_,&exceptionInfo);
3533 RestorePPChannelMask;
3537 void Magick::Image::normalize(void)
3541 NormalizeImage(image(),&exceptionInfo);
3545 void Magick::Image::oilPaint(const double radius_,const double sigma_)
3551 newImage=OilPaintImage(constImage(),radius_,sigma_,&exceptionInfo);
3552 replaceImage(newImage);
3556 void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_)
3566 if (!opaqueColor_.isValid())
3567 throwExceptionExplicit(OptionError,"Opaque color argument is invalid");
3569 if (!penColor_.isValid())
3570 throwExceptionExplicit(OptionError,"Pen color argument is invalid");
3573 opaqueColor=opaqueColor_;
3577 (void) QueryColorCompliance(opaqueColor.c_str(),AllCompliance,&opaque,
3579 (void) QueryColorCompliance(penColor.c_str(),AllCompliance,&pen,
3581 OpaquePaintImage(image(),&opaque,&pen,MagickFalse,&exceptionInfo);
3585 void Magick::Image::orderedDither(std::string thresholdMap_)
3589 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),&exceptionInfo);
3593 void Magick::Image::orderedDitherChannel(const ChannelType channel_,
3594 std::string thresholdMap_)
3598 SetPPChannelMask(channel_);
3599 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),&exceptionInfo);
3600 RestorePPChannelMask;
3604 void Magick::Image::perceptible(const double epsilon_)
3608 PerceptibleImage(image(),epsilon_,&exceptionInfo);
3612 void Magick::Image::perceptibleChannel(const ChannelType channel_,
3613 const double epsilon_)
3617 SetPPChannelMask(channel_);
3618 PerceptibleImage(image(),epsilon_,&exceptionInfo);
3619 RestorePPChannelMask;
3623 void Magick::Image::ping(const std::string &imageSpec_)
3629 options()->fileName(imageSpec_);
3630 newImage=PingImage(imageInfo(),&exceptionInfo);
3631 replaceImage(newImage);
3635 void Magick::Image::ping(const Blob& blob_)
3641 newImage=PingBlob(imageInfo(),blob_.data(),blob_.length(),&exceptionInfo);
3642 replaceImage(newImage);
3646 void Magick::Image::pixelColor(const ssize_t x_,const ssize_t y_,
3647 const Color &color_)
3655 // Test arguments to ensure they are within the image.
3656 if (y_ > (ssize_t) rows() || x_ > (ssize_t) columns())
3657 throwExceptionExplicit(OptionError,"Access outside of image boundary");
3661 // Set image to DirectClass
3662 classType(DirectClass );
3665 Pixels pixels(*this);
3667 pixel=pixels.get(x_, y_, 1, 1 );
3669 MagickCore::SetPixelInfoPixel(constImage(),&packet,pixel);
3670 // Tell ImageMagick that pixels have been updated
3674 Magick::Color Magick::Image::pixelColor(const ssize_t x_,
3675 const ssize_t y_) const
3680 pixel=getConstPixels(x_,y_,1,1);
3686 MagickCore::GetPixelInfoPixel(constImage(),pixel,&packet);
3687 return(Color(packet));
3690 return(Color()); // invalid
3693 void Magick::Image::polaroid(const std::string &caption_,const double angle_,
3694 const PixelInterpolateMethod method_)
3700 newImage=PolaroidImage(constImage(),options()->drawInfo(),caption_.c_str(),
3701 angle_,method_,&exceptionInfo);
3702 replaceImage(newImage);
3706 void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
3710 PosterizeImage(image(),levels_,method_,&exceptionInfo);
3714 void Magick::Image::posterizeChannel(const ChannelType channel_,
3715 const size_t levels_,const DitherMethod method_)
3719 SetPPChannelMask(channel_);
3720 PosterizeImage(image(),levels_,method_,&exceptionInfo);
3721 RestorePPChannelMask;
3725 void Magick::Image::process(std::string name_,const ssize_t argc,
3731 (void) InvokeDynamicImageFilter(name_.c_str(),&image(),argc,argv,
3736 void Magick::Image::profile(const std::string name_,
3737 const Magick::Blob &profile_)
3741 (void) ProfileImage(image(),name_.c_str(),(unsigned char *)profile_.data(),
3742 profile_.length(),&exceptionInfo);
3746 Magick::Blob Magick::Image::profile(const std::string name_) const
3751 profile=GetImageProfile(constImage(),name_.c_str());
3753 if (profile == (StringInfo *) NULL)
3755 return(Blob((void*) GetStringInfoDatum(profile),GetStringInfoLength(
3759 void Magick::Image::quantize(const bool measureError_)
3764 options()->quantizeInfo()->measure_error=MagickTrue;
3766 options()->quantizeInfo()->measure_error=MagickFalse;
3769 QuantizeImage(options()->quantizeInfo(),image(),&exceptionInfo);
3773 void Magick::Image::quantumOperator(const ChannelType channel_,
3774 const MagickEvaluateOperator operator_,double rvalue_)
3777 SetPPChannelMask(channel_);
3778 EvaluateImage(image(),operator_,rvalue_,&exceptionInfo);
3779 RestorePPChannelMask;
3783 void Magick::Image::quantumOperator(const ssize_t x_,const ssize_t y_,
3784 const size_t columns_,const size_t rows_,const ChannelType channel_,
3785 const MagickEvaluateOperator operator_,const double rvalue_)
3793 geometry.width = columns_;
3794 geometry.height = rows_;
3799 cropImage=CropImage(image(),&geometry,&exceptionInfo);
3800 SetPPChannelMask(channel_);
3801 EvaluateImage(cropImage,operator_,rvalue_,&exceptionInfo);
3802 RestorePPChannelMask;
3803 (void) CompositeImage(image(),cropImage,image()->alpha_trait ==
3804 BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
3805 geometry.x,geometry.y,&exceptionInfo );
3806 cropImage=DestroyImageList(cropImage);
3810 void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
3813 raiseInfo=geometry_;
3817 RaiseImage(image(),&raiseInfo,raisedFlag_ == true ? MagickTrue : MagickFalse,
3822 void Magick::Image::randomThreshold(const Geometry &thresholds_)
3825 (void) RandomThresholdImage(image(),static_cast<std::string>(
3826 thresholds_).c_str(),&exceptionInfo);
3830 void Magick::Image::randomThresholdChannel(const ChannelType channel_,
3831 const Geometry &thresholds_)
3835 SetPPChannelMask(channel_);
3836 (void) RandomThresholdImage(image(),static_cast<std::string>(
3837 thresholds_).c_str(),&exceptionInfo);
3838 RestorePPChannelMask;
3842 void Magick::Image::read(const Blob &blob_)
3848 newImage=BlobToImage(imageInfo(),static_cast<const void *>(blob_.data()),
3849 blob_.length(),&exceptionInfo);
3850 replaceImage(newImage);
3854 void Magick::Image::read(const Blob &blob_,const Geometry &size_)
3860 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3861 const size_t depth_)
3868 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3869 const size_t depth_,const std::string &magick_)
3874 // Set explicit image format
3875 fileName(magick_ + ':');
3879 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3880 const std::string &magick_)
3884 // Set explicit image format
3885 fileName(magick_ + ':');
3889 void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_)
3895 void Magick::Image::read(const size_t width_,const size_t height_,
3896 const std::string &map_,const StorageType type_,const void *pixels_)
3902 newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
3904 replaceImage(newImage);
3908 void Magick::Image::read(const std::string &imageSpec_)
3914 options()->fileName(imageSpec_);
3915 newImage=ReadImage(imageInfo(),&exceptionInfo);
3917 // Ensure that multiple image frames were not read.
3918 if (newImage && newImage->next)
3923 // Destroy any extra image frames
3924 next=newImage->next;
3927 DestroyImageList(next);
3929 replaceImage(newImage);
3933 void Magick::Image::readPixels(const Magick::QuantumType quantum_,
3934 const unsigned char *source_)
3939 quantum_info=AcquireQuantumInfo(imageInfo(),image());
3941 ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
3942 quantum_,source_,&exceptionInfo);
3943 quantum_info=DestroyQuantumInfo(quantum_info);
3947 void Magick::Image::reduceNoise(void)
3952 void Magick::Image::reduceNoise(const double order_)
3958 newImage=StatisticImage(constImage(),NonpeakStatistic,(size_t) order_,
3959 (size_t) order_,&exceptionInfo);
3960 replaceImage(newImage);
3964 void Magick::Image::resample(const Geometry &geometry_)
3977 // Calculate new size. This code should be supported using binary arguments
3978 // in the ImageMagick library.
3979 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3983 newImage=ResampleImage(constImage(),width,height,image()->filter,
3985 replaceImage(newImage);
3989 void Magick::Image::resize(const Geometry &geometry_)
4002 // Calculate new size. This code should be supported using binary arguments
4003 // in the ImageMagick library.
4004 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4008 newImage=ResizeImage(constImage(),width,height,image()->filter,
4010 replaceImage(newImage);
4014 void Magick::Image::roll(const Geometry &roll_)
4023 if (roll_.xNegative())
4025 if (roll_.yNegative())
4029 newImage=RollImage(constImage(),xOff,yOff,&exceptionInfo);
4030 replaceImage(newImage);
4034 void Magick::Image::roll(const size_t columns_,const size_t rows_)
4040 newImage=RollImage(constImage(),static_cast<ssize_t>(columns_),
4041 static_cast<ssize_t>(rows_),&exceptionInfo);
4042 replaceImage(newImage);
4046 void Magick::Image::rotate(const double degrees_)
4052 newImage=RotateImage(constImage(),degrees_,&exceptionInfo);
4053 replaceImage(newImage);
4057 void Magick::Image::rotationalBlur(const double angle_)
4063 newImage=RotationalBlurImage(constImage(),angle_,&exceptionInfo);
4064 replaceImage(newImage);
4068 void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
4069 const double angle_)
4075 SetPPChannelMask(channel_);
4076 newImage=RotationalBlurImage(constImage(),angle_,&exceptionInfo);
4077 RestorePPChannelMask;
4078 replaceImage(newImage);
4082 void Magick::Image::sample(const Geometry &geometry_)
4095 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4099 newImage=SampleImage(constImage(),width,height,&exceptionInfo);
4100 replaceImage(newImage);
4104 void Magick::Image::scale(const Geometry &geometry_)
4117 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4121 newImage=ScaleImage(constImage(),width,height,&exceptionInfo);
4122 replaceImage(newImage);
4126 void Magick::Image::segment(const double clusterThreshold_,
4127 const double smoothingThreshold_)
4131 SegmentImage(image(),options()->quantizeColorSpace(),
4132 (MagickBooleanType) options()->verbose(),clusterThreshold_,
4133 smoothingThreshold_,&exceptionInfo);
4134 SyncImage(image(),&exceptionInfo);
4138 void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
4139 const double threshold_)
4145 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4147 replaceImage(newImage);
4151 void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
4152 const double radius_,const double sigma_,const double threshold_)
4158 SetPPChannelMask(channel_);
4159 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4161 RestorePPChannelMask;
4162 replaceImage(newImage);
4166 Magick::Image Magick::Image::separate(const ChannelType channel_)
4172 image=SeparateImage(constImage(),channel_,&exceptionInfo);
4174 if (image == (MagickCore::Image *) NULL)
4175 return(Magick::Image());
4177 return(Magick::Image(image));
4180 void Magick::Image::sepiaTone(const double threshold_)
4186 newImage=SepiaToneImage(constImage(),threshold_,&exceptionInfo);
4187 replaceImage(newImage);
4191 Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
4192 const size_t columns_,const size_t rows_)
4199 result=(*QueueAuthenticPixels)(image(),x_,y_,columns_,rows_,&exceptionInfo);
4204 void Magick::Image::shade(const double azimuth_,const double elevation_,
4205 const bool colorShading_)
4211 newImage=ShadeImage(constImage(),colorShading_ == true ?
4212 MagickTrue : MagickFalse,azimuth_,elevation_,&exceptionInfo);
4213 replaceImage(newImage);
4217 void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
4218 const ssize_t x_,const ssize_t y_)
4224 newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
4226 replaceImage(newImage);
4230 void Magick::Image::sharpen(const double radius_,const double sigma_)
4236 newImage=SharpenImage(constImage(),radius_,sigma_,&exceptionInfo);
4237 replaceImage(newImage);
4241 void Magick::Image::sharpenChannel(const ChannelType channel_,
4242 const double radius_,const double sigma_)
4248 SetPPChannelMask(channel_);
4249 newImage=SharpenImage(constImage(),radius_,sigma_,&exceptionInfo);
4250 RestorePPChannelMask;
4251 replaceImage(newImage);
4255 void Magick::Image::shave(const Geometry &geometry_)
4261 shaveInfo=geometry_;
4264 newImage=ShaveImage(constImage(),&shaveInfo,&exceptionInfo);
4265 replaceImage(newImage);
4269 void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
4275 newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,&exceptionInfo);
4276 replaceImage(newImage);
4280 void Magick::Image::sigmoidalContrast(const size_t sharpen_,
4281 const double contrast,const double midpoint)
4285 (void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
4286 midpoint,&exceptionInfo);
4290 std::string Magick::Image::signature(const bool force_) const
4295 Lock(&_imgRef->_mutexLock);
4297 // Re-calculate image signature if necessary
4299 if (force_ || !GetImageProperty(constImage(),"Signature",&exceptionInfo) ||
4300 constImage()->taint)
4301 SignatureImage(const_cast<MagickCore::Image *>(constImage()),
4304 property=GetImageProperty(constImage(),"Signature",&exceptionInfo);
4307 return(std::string(property));
4310 void Magick::Image::sketch(const double radius_,const double sigma_,
4311 const double angle_)
4317 newImage=SketchImage(constImage(),radius_,sigma_,angle_,&exceptionInfo);
4318 replaceImage(newImage);
4322 void Magick::Image::solarize(const double factor_)
4326 SolarizeImage(image(),factor_,&exceptionInfo);
4330 void Magick::Image::sparseColor(const ChannelType channel_,
4331 const SparseColorMethod method_,const size_t numberArguments_,
4332 const double *arguments_)
4338 SetPPChannelMask(channel_);
4339 newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
4341 RestorePPChannelMask;
4342 replaceImage(newImage);
4346 void Magick::Image::splice(const Geometry &geometry_)
4352 spliceInfo=geometry_;
4355 newImage=SpliceImage(constImage(),&spliceInfo,&exceptionInfo);
4356 replaceImage(newImage);
4360 void Magick::Image::spread(const size_t amount_)
4366 newImage=SpreadImage(constImage(),amount_,image()->interpolate,
4368 replaceImage(newImage);
4372 void Magick::Image::statistics(ImageStatistics *statistics)
4380 SetPPChannelMask(RedChannel);
4381 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4382 statistics->red.minimum=minimum;
4383 statistics->red.maximum=maximum;
4384 (void) GetImageMean(constImage(),&statistics->red.mean,
4385 &statistics->red.standard_deviation,&exceptionInfo);
4386 (void) GetImageKurtosis(constImage(),&statistics->red.kurtosis,
4387 &statistics->red.skewness,&exceptionInfo);
4389 (void) SetImageChannelMask(image(),GreenChannel);
4390 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4391 statistics->green.minimum=minimum;
4392 statistics->green.maximum=maximum;
4393 (void) GetImageMean(constImage(),&statistics->green.mean,
4394 &statistics->green.standard_deviation,&exceptionInfo);
4395 (void) GetImageKurtosis(constImage(),&statistics->green.kurtosis,
4396 &statistics->green.skewness,&exceptionInfo);
4398 (void) SetImageChannelMask(image(),GreenChannel);
4399 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4400 statistics->blue.minimum=minimum;
4401 statistics->blue.maximum=maximum;
4402 (void) GetImageMean(constImage(),&statistics->blue.mean,
4403 &statistics->blue.standard_deviation,&exceptionInfo);
4404 (void) GetImageKurtosis(constImage(),&statistics->blue.kurtosis,
4405 &statistics->blue.skewness,&exceptionInfo);
4407 (void) SetImageChannelMask(image(),AlphaChannel);
4408 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4409 statistics->alpha.minimum=minimum;
4410 statistics->alpha.maximum=maximum;
4411 (void) GetImageMean(constImage(),&statistics->alpha.mean,
4412 &statistics->alpha.standard_deviation,&exceptionInfo);
4413 (void) GetImageKurtosis(constImage(),&statistics->alpha.kurtosis,
4414 &statistics->alpha.skewness,&exceptionInfo);
4415 RestorePPChannelMask;
4419 void Magick::Image::stegano(const Image &watermark_)
4425 newImage=SteganoImage(constImage(),watermark_.constImage(),&exceptionInfo);
4426 replaceImage(newImage);
4430 void Magick::Image::stereo(const Image &rightImage_)
4436 newImage=StereoImage(constImage(),rightImage_.constImage(),&exceptionInfo);
4437 replaceImage(newImage);
4441 void Magick::Image::strip(void)
4445 StripImage(image(),&exceptionInfo);
4449 Magick::Image Magick::Image::subImageSearch(const Image &reference_,
4450 const MetricType metric_,Geometry *offset_,double *similarityMetric_,
4451 const double similarityThreshold)
4460 newImage=SimilarityImage(image(),reference_.constImage(),metric_,
4461 similarityThreshold,&offset,similarityMetric_,&exceptionInfo);
4463 if (offset_ != (Geometry *) NULL)
4465 if (newImage == (MagickCore::Image *) NULL)
4466 return(Magick::Image());
4468 return(Magick::Image(newImage));
4471 void Magick::Image::swirl(const double degrees_)
4477 newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
4479 replaceImage(newImage);
4483 void Magick::Image::syncPixels(void)
4486 (*SyncAuthenticPixels)(image(),&exceptionInfo);
4490 void Magick::Image::texture(const Image &texture_)
4494 TextureImage(image(),texture_.constImage(),&exceptionInfo);
4498 void Magick::Image::threshold(const double threshold_)
4502 BilevelImage(image(),threshold_,&exceptionInfo);
4506 void Magick::Image::thumbnail(const Geometry &geometry_)
4519 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4523 newImage=ThumbnailImage(constImage(),width,height,&exceptionInfo);
4524 replaceImage(newImage);
4528 void Magick::Image::tint(const std::string opacity_)
4537 color=static_cast<PixelInfo>(constOptions()->fillColor());
4538 newImage=TintImage(constImage(),opacity_.c_str(),&color,&exceptionInfo);
4539 replaceImage(newImage);
4543 void Magick::Image::transform(const Geometry &imageGeometry_)
4547 TransformImage(&(image()),0,std::string(imageGeometry_).c_str(),
4552 void Magick::Image::transform(const Geometry &imageGeometry_,
4553 const Geometry &cropGeometry_)
4557 TransformImage(&(image()),std::string(cropGeometry_).c_str(),std::string(
4558 imageGeometry_).c_str(), &exceptionInfo);
4562 void Magick::Image::transformOrigin(const double x_,const double y_)
4565 options()->transformOrigin(x_,y_);
4568 void Magick::Image::transformReset(void)
4571 options()->transformReset();
4574 void Magick::Image::transformScale(const double sx_,const double sy_)
4577 options()->transformScale(sx_,sy_);
4580 void Magick::Image::transparent(const Color &color_)
4588 if (!color_.isValid())
4589 throwExceptionExplicit(OptionError,"Color argument is invalid");
4593 (void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
4596 TransparentPaintImage(image(),&target,TransparentAlpha,MagickFalse,
4601 void Magick::Image::transparentChroma(const Color &colorLow_,
4602 const Color &colorHigh_)
4612 if (!colorLow_.isValid() || !colorHigh_.isValid())
4613 throwExceptionExplicit(OptionError,"Color argument is invalid");
4616 colorHigh=colorHigh_;
4619 (void) QueryColorCompliance(colorLow.c_str(),AllCompliance,&targetLow,
4621 (void) QueryColorCompliance(colorHigh.c_str(),AllCompliance,&targetHigh,
4624 TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
4625 MagickFalse,&exceptionInfo);
4629 void Magick::Image::transpose(void)
4635 newImage=TransposeImage(constImage(),&exceptionInfo);
4636 replaceImage(newImage);
4640 void Magick::Image::transverse(void)
4646 newImage=TransverseImage(constImage(),&exceptionInfo);
4647 replaceImage(newImage);
4651 void Magick::Image::trim(void)
4657 newImage=TrimImage(constImage(),&exceptionInfo);
4658 replaceImage(newImage);
4662 Magick::Image Magick::Image::uniqueColors(void)
4668 image=UniqueImageColors(constImage(),&exceptionInfo);
4670 if (image == (MagickCore::Image *) NULL)
4671 return(Magick::Image());
4673 return(Magick::Image(image));
4676 void Magick::Image::unsharpmask(const double radius_,const double sigma_,
4677 const double amount_,const double threshold_)
4683 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4685 replaceImage(newImage);
4689 void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
4690 const double radius_,const double sigma_,const double amount_,
4691 const double threshold_)
4697 SetPPChannelMask(channel_);
4698 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4700 RestorePPChannelMask;
4701 replaceImage(newImage);
4705 void Magick::Image::vignette(const double radius_,const double sigma_,
4706 const ssize_t x_,const ssize_t y_)
4712 newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,&exceptionInfo);
4713 replaceImage(newImage);
4717 void Magick::Image::wave(const double amplitude_,const double wavelength_)
4723 newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
4725 replaceImage(newImage);
4729 void Magick::Image::whiteThreshold(const std::string &threshold_)
4733 WhiteThresholdImage(image(),threshold_.c_str(),&exceptionInfo);
4737 void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
4738 const std::string &threshold_)
4742 SetPPChannelMask(channel_);
4743 WhiteThresholdImage(image(),threshold_.c_str(),&exceptionInfo);
4744 RestorePPChannelMask;
4748 void Magick::Image::write(Blob *blob_)
4758 data=ImagesToBlob(constImageInfo(),image(),&length,&exceptionInfo);
4760 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4764 void Magick::Image::write(Blob *blob_,const std::string &magick_)
4775 data=ImagesToBlob(constImageInfo(),image(),&length,&exceptionInfo);
4777 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4781 void Magick::Image::write(Blob *blob_,const std::string &magick_,
4782 const size_t depth_)
4794 data=ImagesToBlob(constImageInfo(),image(),&length,&exceptionInfo);
4796 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4800 void Magick::Image::write(const ssize_t x_,const ssize_t y_,
4801 const size_t columns_,const size_t rows_,const std::string &map_,
4802 const StorageType type_,void *pixels_)
4805 ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
4810 void Magick::Image::write(const std::string &imageSpec_)
4813 fileName(imageSpec_);
4815 WriteImage(constImageInfo(),image(),&exceptionInfo);
4819 void Magick::Image::writePixels(const Magick::QuantumType quantum_,
4820 unsigned char *destination_)
4825 quantum_info=AcquireQuantumInfo(imageInfo(),image());
4827 ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4828 quantum_,destination_, &exceptionInfo);
4829 quantum_info=DestroyQuantumInfo(quantum_info);
4833 void Magick::Image::zoom(const Geometry &geometry_)
4846 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4850 newImage=ResizeImage(constImage(),width,height,image()->filter,&exceptionInfo);
4851 replaceImage(newImage);
4855 Magick::Image::Image(MagickCore::Image *image_)
4856 : _imgRef(new ImageRef(image_))
4860 MagickCore::Image *&Magick::Image::image(void)
4862 return(_imgRef->image());
4865 const MagickCore::Image *Magick::Image::constImage(void) const
4867 return(_imgRef->image());
4870 MagickCore::ImageInfo *Magick::Image::imageInfo(void)
4872 return(_imgRef->options()->imageInfo());
4875 const MagickCore::ImageInfo *Magick::Image::constImageInfo(void) const
4877 return(_imgRef->options()->imageInfo());
4880 Magick::Options *Magick::Image::options(void)
4882 return(_imgRef->options());
4885 const Magick::Options *Magick::Image::constOptions(void) const
4887 return(_imgRef->options());
4890 MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)
4892 return(_imgRef->options()->quantizeInfo());
4895 const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
4897 return(_imgRef->options()->quantizeInfo());
4900 void Magick::Image::modifyImage(void)
4903 Lock(&_imgRef->_mutexLock);
4904 if (_imgRef->_refCount == 1)
4906 // De-register image and return
4913 replaceImage(CloneImage(image(),0,0,MagickTrue,&exceptionInfo));
4917 ssize_t Magick::Image::registerId(void)
4919 Lock(&_imgRef->_mutexLock);
4920 if ( _imgRef->id() < 0)
4926 _imgRef->id(_imgRef->id()+1);
4927 sprintf(id,"%.20g\n",(double) _imgRef->id());
4928 SetImageRegistry(ImageRegistryType,id,image(),&exceptionInfo);
4931 return(_imgRef->id());
4934 MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
4940 image = replacement_;
4944 image=AcquireImage(constImageInfo(),&exceptionInfo);
4949 Lock(&_imgRef->_mutexLock);
4951 if (_imgRef->_refCount == 1)
4953 // We own the image, just replace it, and de-register
4955 _imgRef->image(image);
4959 // We don't own the image, dereference and replace with copy
4960 --_imgRef->_refCount;
4961 _imgRef=new ImageRef(image,constOptions());
4965 return(_imgRef->_image);
4968 void Magick::Image::unregisterId(void)