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 (void) 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 (void) 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::ImageMoments Magick::Image::moments(void)
3401 return(ImageMoments(constImage()));
3404 void Magick::Image::morphology(const MorphologyMethod method_,
3405 const std::string kernel_,const ssize_t iterations_)
3413 kernel=AcquireKernelInfo(kernel_.c_str());
3414 if (kernel == (KernelInfo *)NULL)
3415 throwExceptionExplicit(OptionError,"Unable to parse kernel.");
3418 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3420 replaceImage(newImage);
3421 kernel=DestroyKernelInfo(kernel);
3425 void Magick::Image::morphology(const MorphologyMethod method_,
3426 const KernelInfoType kernel_,const std::string arguments_,
3427 const ssize_t iterations_)
3435 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3436 if (option == (const char *)NULL)
3437 throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
3439 kernel=std::string(option);
3440 if (!arguments_.empty())
3441 kernel+=":"+arguments_;
3443 morphology(method_,kernel,iterations_);
3446 void Magick::Image::morphologyChannel(const ChannelType channel_,
3447 const MorphologyMethod method_,const std::string kernel_,
3448 const ssize_t iterations_)
3456 kernel=AcquireKernelInfo(kernel_.c_str());
3457 if (kernel == (KernelInfo *)NULL)
3458 throwExceptionExplicit(OptionError,"Unable to parse kernel.");
3461 SetPPChannelMask(channel_);
3462 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3464 RestorePPChannelMask;
3465 replaceImage(newImage);
3466 kernel=DestroyKernelInfo(kernel);
3470 void Magick::Image::morphologyChannel(const ChannelType channel_,
3471 const MorphologyMethod method_,const KernelInfoType kernel_,
3472 const std::string arguments_,const ssize_t iterations_)
3480 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3481 if (option == (const char *)NULL)
3482 throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
3484 kernel=std::string(option);
3485 if (!arguments_.empty())
3486 kernel+=":"+arguments_;
3488 morphologyChannel(channel_,method_,kernel,iterations_);
3491 void Magick::Image::motionBlur(const double radius_,const double sigma_,
3492 const double angle_)
3498 newImage=MotionBlurImage(constImage(),radius_,sigma_,angle_,&exceptionInfo);
3499 replaceImage(newImage);
3503 void Magick::Image::negate(const bool grayscale_)
3507 NegateImage(image(),(MagickBooleanType) grayscale_,&exceptionInfo);
3511 void Magick::Image::negateChannel(const ChannelType channel_,
3512 const bool grayscale_)
3516 SetPPChannelMask(channel_);
3517 NegateImage(image(),(MagickBooleanType) grayscale_,&exceptionInfo);
3518 RestorePPChannelMask;
3522 void Magick::Image::normalize(void)
3526 NormalizeImage(image(),&exceptionInfo);
3530 void Magick::Image::oilPaint(const double radius_,const double sigma_)
3536 newImage=OilPaintImage(constImage(),radius_,sigma_,&exceptionInfo);
3537 replaceImage(newImage);
3541 void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_)
3551 if (!opaqueColor_.isValid())
3552 throwExceptionExplicit(OptionError,"Opaque color argument is invalid");
3554 if (!penColor_.isValid())
3555 throwExceptionExplicit(OptionError,"Pen color argument is invalid");
3558 opaqueColor=opaqueColor_;
3562 (void) QueryColorCompliance(opaqueColor.c_str(),AllCompliance,&opaque,
3564 (void) QueryColorCompliance(penColor.c_str(),AllCompliance,&pen,
3566 OpaquePaintImage(image(),&opaque,&pen,MagickFalse,&exceptionInfo);
3570 void Magick::Image::orderedDither(std::string thresholdMap_)
3574 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),&exceptionInfo);
3578 void Magick::Image::orderedDitherChannel(const ChannelType channel_,
3579 std::string thresholdMap_)
3583 SetPPChannelMask(channel_);
3584 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),&exceptionInfo);
3585 RestorePPChannelMask;
3589 void Magick::Image::perceptible(const double epsilon_)
3593 PerceptibleImage(image(),epsilon_,&exceptionInfo);
3597 void Magick::Image::perceptibleChannel(const ChannelType channel_,
3598 const double epsilon_)
3602 SetPPChannelMask(channel_);
3603 PerceptibleImage(image(),epsilon_,&exceptionInfo);
3604 RestorePPChannelMask;
3608 void Magick::Image::ping(const std::string &imageSpec_)
3614 options()->fileName(imageSpec_);
3615 newImage=PingImage(imageInfo(),&exceptionInfo);
3616 replaceImage(newImage);
3620 void Magick::Image::ping(const Blob& blob_)
3626 newImage=PingBlob(imageInfo(),blob_.data(),blob_.length(),&exceptionInfo);
3627 replaceImage(newImage);
3631 void Magick::Image::pixelColor(const ssize_t x_,const ssize_t y_,
3632 const Color &color_)
3640 // Test arguments to ensure they are within the image.
3641 if (y_ > (ssize_t) rows() || x_ > (ssize_t) columns())
3642 throwExceptionExplicit(OptionError,"Access outside of image boundary");
3646 // Set image to DirectClass
3647 classType(DirectClass );
3650 Pixels pixels(*this);
3652 pixel=pixels.get(x_, y_, 1, 1 );
3654 MagickCore::SetPixelInfoPixel(constImage(),&packet,pixel);
3655 // Tell ImageMagick that pixels have been updated
3659 Magick::Color Magick::Image::pixelColor(const ssize_t x_,
3660 const ssize_t y_) const
3665 pixel=getConstPixels(x_,y_,1,1);
3671 MagickCore::GetPixelInfoPixel(constImage(),pixel,&packet);
3672 return(Color(packet));
3675 return(Color()); // invalid
3678 void Magick::Image::polaroid(const std::string &caption_,const double angle_,
3679 const PixelInterpolateMethod method_)
3685 newImage=PolaroidImage(constImage(),options()->drawInfo(),caption_.c_str(),
3686 angle_,method_,&exceptionInfo);
3687 replaceImage(newImage);
3691 void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
3695 PosterizeImage(image(),levels_,method_,&exceptionInfo);
3699 void Magick::Image::posterizeChannel(const ChannelType channel_,
3700 const size_t levels_,const DitherMethod method_)
3704 SetPPChannelMask(channel_);
3705 PosterizeImage(image(),levels_,method_,&exceptionInfo);
3706 RestorePPChannelMask;
3710 void Magick::Image::process(std::string name_,const ssize_t argc,
3716 (void) InvokeDynamicImageFilter(name_.c_str(),&image(),argc,argv,
3721 void Magick::Image::profile(const std::string name_,
3722 const Magick::Blob &profile_)
3726 (void) ProfileImage(image(),name_.c_str(),(unsigned char *)profile_.data(),
3727 profile_.length(),&exceptionInfo);
3731 Magick::Blob Magick::Image::profile(const std::string name_) const
3736 profile=GetImageProfile(constImage(),name_.c_str());
3738 if (profile == (StringInfo *) NULL)
3740 return(Blob((void*) GetStringInfoDatum(profile),GetStringInfoLength(
3744 void Magick::Image::quantize(const bool measureError_)
3749 options()->quantizeInfo()->measure_error=MagickTrue;
3751 options()->quantizeInfo()->measure_error=MagickFalse;
3754 QuantizeImage(options()->quantizeInfo(),image(),&exceptionInfo);
3758 void Magick::Image::quantumOperator(const ChannelType channel_,
3759 const MagickEvaluateOperator operator_,double rvalue_)
3762 SetPPChannelMask(channel_);
3763 EvaluateImage(image(),operator_,rvalue_,&exceptionInfo);
3764 RestorePPChannelMask;
3768 void Magick::Image::quantumOperator(const ssize_t x_,const ssize_t y_,
3769 const size_t columns_,const size_t rows_,const ChannelType channel_,
3770 const MagickEvaluateOperator operator_,const double rvalue_)
3778 geometry.width = columns_;
3779 geometry.height = rows_;
3784 cropImage=CropImage(image(),&geometry,&exceptionInfo);
3785 SetPPChannelMask(channel_);
3786 EvaluateImage(cropImage,operator_,rvalue_,&exceptionInfo);
3787 RestorePPChannelMask;
3788 (void) CompositeImage(image(),cropImage,image()->alpha_trait ==
3789 BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
3790 geometry.x,geometry.y,&exceptionInfo );
3791 cropImage=DestroyImageList(cropImage);
3795 void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
3798 raiseInfo=geometry_;
3802 RaiseImage(image(),&raiseInfo,raisedFlag_ == true ? MagickTrue : MagickFalse,
3807 void Magick::Image::randomThreshold(const Geometry &thresholds_)
3810 (void) RandomThresholdImage(image(),static_cast<std::string>(
3811 thresholds_).c_str(),&exceptionInfo);
3815 void Magick::Image::randomThresholdChannel(const ChannelType channel_,
3816 const Geometry &thresholds_)
3820 SetPPChannelMask(channel_);
3821 (void) RandomThresholdImage(image(),static_cast<std::string>(
3822 thresholds_).c_str(),&exceptionInfo);
3823 RestorePPChannelMask;
3827 void Magick::Image::read(const Blob &blob_)
3833 newImage=BlobToImage(imageInfo(),static_cast<const void *>(blob_.data()),
3834 blob_.length(),&exceptionInfo);
3835 replaceImage(newImage);
3839 void Magick::Image::read(const Blob &blob_,const Geometry &size_)
3845 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3846 const size_t depth_)
3853 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3854 const size_t depth_,const std::string &magick_)
3859 // Set explicit image format
3860 fileName(magick_ + ':');
3864 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3865 const std::string &magick_)
3869 // Set explicit image format
3870 fileName(magick_ + ':');
3874 void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_)
3880 void Magick::Image::read(const size_t width_,const size_t height_,
3881 const std::string &map_,const StorageType type_,const void *pixels_)
3887 newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
3889 replaceImage(newImage);
3893 void Magick::Image::read(const std::string &imageSpec_)
3899 options()->fileName(imageSpec_);
3900 newImage=ReadImage(imageInfo(),&exceptionInfo);
3902 // Ensure that multiple image frames were not read.
3903 if (newImage && newImage->next)
3908 // Destroy any extra image frames
3909 next=newImage->next;
3912 DestroyImageList(next);
3914 replaceImage(newImage);
3918 void Magick::Image::readPixels(const Magick::QuantumType quantum_,
3919 const unsigned char *source_)
3924 quantum_info=AcquireQuantumInfo(imageInfo(),image());
3926 ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
3927 quantum_,source_,&exceptionInfo);
3928 quantum_info=DestroyQuantumInfo(quantum_info);
3932 void Magick::Image::reduceNoise(void)
3937 void Magick::Image::reduceNoise(const double order_)
3943 newImage=StatisticImage(constImage(),NonpeakStatistic,(size_t) order_,
3944 (size_t) order_,&exceptionInfo);
3945 replaceImage(newImage);
3949 void Magick::Image::resample(const Geometry &geometry_)
3962 // Calculate new size. This code should be supported using binary arguments
3963 // in the ImageMagick library.
3964 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3968 newImage=ResampleImage(constImage(),width,height,image()->filter,
3970 replaceImage(newImage);
3974 void Magick::Image::resize(const Geometry &geometry_)
3987 // Calculate new size. This code should be supported using binary arguments
3988 // in the ImageMagick library.
3989 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3993 newImage=ResizeImage(constImage(),width,height,image()->filter,
3995 replaceImage(newImage);
3999 void Magick::Image::roll(const Geometry &roll_)
4008 if (roll_.xNegative())
4010 if (roll_.yNegative())
4014 newImage=RollImage(constImage(),xOff,yOff,&exceptionInfo);
4015 replaceImage(newImage);
4019 void Magick::Image::roll(const size_t columns_,const size_t rows_)
4025 newImage=RollImage(constImage(),static_cast<ssize_t>(columns_),
4026 static_cast<ssize_t>(rows_),&exceptionInfo);
4027 replaceImage(newImage);
4031 void Magick::Image::rotate(const double degrees_)
4037 newImage=RotateImage(constImage(),degrees_,&exceptionInfo);
4038 replaceImage(newImage);
4042 void Magick::Image::rotationalBlur(const double angle_)
4048 newImage=RotationalBlurImage(constImage(),angle_,&exceptionInfo);
4049 replaceImage(newImage);
4053 void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
4054 const double angle_)
4060 SetPPChannelMask(channel_);
4061 newImage=RotationalBlurImage(constImage(),angle_,&exceptionInfo);
4062 RestorePPChannelMask;
4063 replaceImage(newImage);
4067 void Magick::Image::sample(const Geometry &geometry_)
4080 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4084 newImage=SampleImage(constImage(),width,height,&exceptionInfo);
4085 replaceImage(newImage);
4089 void Magick::Image::scale(const Geometry &geometry_)
4102 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4106 newImage=ScaleImage(constImage(),width,height,&exceptionInfo);
4107 replaceImage(newImage);
4111 void Magick::Image::segment(const double clusterThreshold_,
4112 const double smoothingThreshold_)
4116 SegmentImage(image(),options()->quantizeColorSpace(),
4117 (MagickBooleanType) options()->verbose(),clusterThreshold_,
4118 smoothingThreshold_,&exceptionInfo);
4119 SyncImage(image(),&exceptionInfo);
4123 void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
4124 const double threshold_)
4130 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4132 replaceImage(newImage);
4136 void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
4137 const double radius_,const double sigma_,const double threshold_)
4143 SetPPChannelMask(channel_);
4144 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4146 RestorePPChannelMask;
4147 replaceImage(newImage);
4151 Magick::Image Magick::Image::separate(const ChannelType channel_)
4157 image=SeparateImage(constImage(),channel_,&exceptionInfo);
4159 if (image == (MagickCore::Image *) NULL)
4160 return(Magick::Image());
4162 return(Magick::Image(image));
4165 void Magick::Image::sepiaTone(const double threshold_)
4171 newImage=SepiaToneImage(constImage(),threshold_,&exceptionInfo);
4172 replaceImage(newImage);
4176 Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
4177 const size_t columns_,const size_t rows_)
4184 result=(*QueueAuthenticPixels)(image(),x_,y_,columns_,rows_,&exceptionInfo);
4189 void Magick::Image::shade(const double azimuth_,const double elevation_,
4190 const bool colorShading_)
4196 newImage=ShadeImage(constImage(),colorShading_ == true ?
4197 MagickTrue : MagickFalse,azimuth_,elevation_,&exceptionInfo);
4198 replaceImage(newImage);
4202 void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
4203 const ssize_t x_,const ssize_t y_)
4209 newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
4211 replaceImage(newImage);
4215 void Magick::Image::sharpen(const double radius_,const double sigma_)
4221 newImage=SharpenImage(constImage(),radius_,sigma_,&exceptionInfo);
4222 replaceImage(newImage);
4226 void Magick::Image::sharpenChannel(const ChannelType channel_,
4227 const double radius_,const double sigma_)
4233 SetPPChannelMask(channel_);
4234 newImage=SharpenImage(constImage(),radius_,sigma_,&exceptionInfo);
4235 RestorePPChannelMask;
4236 replaceImage(newImage);
4240 void Magick::Image::shave(const Geometry &geometry_)
4246 shaveInfo=geometry_;
4249 newImage=ShaveImage(constImage(),&shaveInfo,&exceptionInfo);
4250 replaceImage(newImage);
4254 void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
4260 newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,&exceptionInfo);
4261 replaceImage(newImage);
4265 void Magick::Image::sigmoidalContrast(const size_t sharpen_,
4266 const double contrast,const double midpoint)
4270 (void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
4271 midpoint,&exceptionInfo);
4275 std::string Magick::Image::signature(const bool force_) const
4280 Lock(&_imgRef->_mutexLock);
4282 // Re-calculate image signature if necessary
4284 if (force_ || !GetImageProperty(constImage(),"Signature",&exceptionInfo) ||
4285 constImage()->taint)
4286 SignatureImage(const_cast<MagickCore::Image *>(constImage()),
4289 property=GetImageProperty(constImage(),"Signature",&exceptionInfo);
4292 return(std::string(property));
4295 void Magick::Image::sketch(const double radius_,const double sigma_,
4296 const double angle_)
4302 newImage=SketchImage(constImage(),radius_,sigma_,angle_,&exceptionInfo);
4303 replaceImage(newImage);
4307 void Magick::Image::solarize(const double factor_)
4311 SolarizeImage(image(),factor_,&exceptionInfo);
4315 void Magick::Image::sparseColor(const ChannelType channel_,
4316 const SparseColorMethod method_,const size_t numberArguments_,
4317 const double *arguments_)
4323 SetPPChannelMask(channel_);
4324 newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
4326 RestorePPChannelMask;
4327 replaceImage(newImage);
4331 void Magick::Image::splice(const Geometry &geometry_)
4337 spliceInfo=geometry_;
4340 newImage=SpliceImage(constImage(),&spliceInfo,&exceptionInfo);
4341 replaceImage(newImage);
4345 void Magick::Image::spread(const size_t amount_)
4351 newImage=SpreadImage(constImage(),amount_,image()->interpolate,
4353 replaceImage(newImage);
4357 void Magick::Image::statistics(ImageStatistics *statistics)
4365 SetPPChannelMask(RedChannel);
4366 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4367 statistics->red.minimum=minimum;
4368 statistics->red.maximum=maximum;
4369 (void) GetImageMean(constImage(),&statistics->red.mean,
4370 &statistics->red.standard_deviation,&exceptionInfo);
4371 (void) GetImageKurtosis(constImage(),&statistics->red.kurtosis,
4372 &statistics->red.skewness,&exceptionInfo);
4374 (void) SetImageChannelMask(image(),GreenChannel);
4375 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4376 statistics->green.minimum=minimum;
4377 statistics->green.maximum=maximum;
4378 (void) GetImageMean(constImage(),&statistics->green.mean,
4379 &statistics->green.standard_deviation,&exceptionInfo);
4380 (void) GetImageKurtosis(constImage(),&statistics->green.kurtosis,
4381 &statistics->green.skewness,&exceptionInfo);
4383 (void) SetImageChannelMask(image(),GreenChannel);
4384 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4385 statistics->blue.minimum=minimum;
4386 statistics->blue.maximum=maximum;
4387 (void) GetImageMean(constImage(),&statistics->blue.mean,
4388 &statistics->blue.standard_deviation,&exceptionInfo);
4389 (void) GetImageKurtosis(constImage(),&statistics->blue.kurtosis,
4390 &statistics->blue.skewness,&exceptionInfo);
4392 (void) SetImageChannelMask(image(),AlphaChannel);
4393 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4394 statistics->alpha.minimum=minimum;
4395 statistics->alpha.maximum=maximum;
4396 (void) GetImageMean(constImage(),&statistics->alpha.mean,
4397 &statistics->alpha.standard_deviation,&exceptionInfo);
4398 (void) GetImageKurtosis(constImage(),&statistics->alpha.kurtosis,
4399 &statistics->alpha.skewness,&exceptionInfo);
4400 RestorePPChannelMask;
4404 void Magick::Image::stegano(const Image &watermark_)
4410 newImage=SteganoImage(constImage(),watermark_.constImage(),&exceptionInfo);
4411 replaceImage(newImage);
4415 void Magick::Image::stereo(const Image &rightImage_)
4421 newImage=StereoImage(constImage(),rightImage_.constImage(),&exceptionInfo);
4422 replaceImage(newImage);
4426 void Magick::Image::strip(void)
4430 StripImage(image(),&exceptionInfo);
4434 Magick::Image Magick::Image::subImageSearch(const Image &reference_,
4435 const MetricType metric_,Geometry *offset_,double *similarityMetric_,
4436 const double similarityThreshold)
4445 newImage=SimilarityImage(image(),reference_.constImage(),metric_,
4446 similarityThreshold,&offset,similarityMetric_,&exceptionInfo);
4448 if (offset_ != (Geometry *) NULL)
4450 if (newImage == (MagickCore::Image *) NULL)
4451 return(Magick::Image());
4453 return(Magick::Image(newImage));
4456 void Magick::Image::swirl(const double degrees_)
4462 newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
4464 replaceImage(newImage);
4468 void Magick::Image::syncPixels(void)
4471 (void) (*SyncAuthenticPixels)(image(),&exceptionInfo);
4475 void Magick::Image::texture(const Image &texture_)
4479 TextureImage(image(),texture_.constImage(),&exceptionInfo);
4483 void Magick::Image::threshold(const double threshold_)
4487 BilevelImage(image(),threshold_,&exceptionInfo);
4491 void Magick::Image::thumbnail(const Geometry &geometry_)
4504 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4508 newImage=ThumbnailImage(constImage(),width,height,&exceptionInfo);
4509 replaceImage(newImage);
4513 void Magick::Image::tint(const std::string opacity_)
4522 color=static_cast<PixelInfo>(constOptions()->fillColor());
4523 newImage=TintImage(constImage(),opacity_.c_str(),&color,&exceptionInfo);
4524 replaceImage(newImage);
4528 void Magick::Image::transform(const Geometry &imageGeometry_)
4532 TransformImage(&(image()),0,std::string(imageGeometry_).c_str(),
4537 void Magick::Image::transform(const Geometry &imageGeometry_,
4538 const Geometry &cropGeometry_)
4542 TransformImage(&(image()),std::string(cropGeometry_).c_str(),std::string(
4543 imageGeometry_).c_str(), &exceptionInfo);
4547 void Magick::Image::transformOrigin(const double x_,const double y_)
4550 options()->transformOrigin(x_,y_);
4553 void Magick::Image::transformReset(void)
4556 options()->transformReset();
4559 void Magick::Image::transformScale(const double sx_,const double sy_)
4562 options()->transformScale(sx_,sy_);
4565 void Magick::Image::transparent(const Color &color_)
4573 if (!color_.isValid())
4574 throwExceptionExplicit(OptionError,"Color argument is invalid");
4578 (void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
4581 TransparentPaintImage(image(),&target,TransparentAlpha,MagickFalse,
4586 void Magick::Image::transparentChroma(const Color &colorLow_,
4587 const Color &colorHigh_)
4597 if (!colorLow_.isValid() || !colorHigh_.isValid())
4598 throwExceptionExplicit(OptionError,"Color argument is invalid");
4601 colorHigh=colorHigh_;
4604 (void) QueryColorCompliance(colorLow.c_str(),AllCompliance,&targetLow,
4606 (void) QueryColorCompliance(colorHigh.c_str(),AllCompliance,&targetHigh,
4609 TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
4610 MagickFalse,&exceptionInfo);
4614 void Magick::Image::transpose(void)
4620 newImage=TransposeImage(constImage(),&exceptionInfo);
4621 replaceImage(newImage);
4625 void Magick::Image::transverse(void)
4631 newImage=TransverseImage(constImage(),&exceptionInfo);
4632 replaceImage(newImage);
4636 void Magick::Image::trim(void)
4642 newImage=TrimImage(constImage(),&exceptionInfo);
4643 replaceImage(newImage);
4647 Magick::Image Magick::Image::uniqueColors(void)
4653 image=UniqueImageColors(constImage(),&exceptionInfo);
4655 if (image == (MagickCore::Image *) NULL)
4656 return(Magick::Image());
4658 return(Magick::Image(image));
4661 void Magick::Image::unsharpmask(const double radius_,const double sigma_,
4662 const double amount_,const double threshold_)
4668 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4670 replaceImage(newImage);
4674 void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
4675 const double radius_,const double sigma_,const double amount_,
4676 const double threshold_)
4682 SetPPChannelMask(channel_);
4683 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4685 RestorePPChannelMask;
4686 replaceImage(newImage);
4690 void Magick::Image::vignette(const double radius_,const double sigma_,
4691 const ssize_t x_,const ssize_t y_)
4697 newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,&exceptionInfo);
4698 replaceImage(newImage);
4702 void Magick::Image::wave(const double amplitude_,const double wavelength_)
4708 newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
4710 replaceImage(newImage);
4714 void Magick::Image::whiteThreshold(const std::string &threshold_)
4718 WhiteThresholdImage(image(),threshold_.c_str(),&exceptionInfo);
4722 void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
4723 const std::string &threshold_)
4727 SetPPChannelMask(channel_);
4728 WhiteThresholdImage(image(),threshold_.c_str(),&exceptionInfo);
4729 RestorePPChannelMask;
4733 void Magick::Image::write(Blob *blob_)
4743 data=ImagesToBlob(constImageInfo(),image(),&length,&exceptionInfo);
4745 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4749 void Magick::Image::write(Blob *blob_,const std::string &magick_)
4760 data=ImagesToBlob(constImageInfo(),image(),&length,&exceptionInfo);
4762 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4766 void Magick::Image::write(Blob *blob_,const std::string &magick_,
4767 const size_t depth_)
4779 data=ImagesToBlob(constImageInfo(),image(),&length,&exceptionInfo);
4781 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4785 void Magick::Image::write(const ssize_t x_,const ssize_t y_,
4786 const size_t columns_,const size_t rows_,const std::string &map_,
4787 const StorageType type_,void *pixels_)
4790 ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
4795 void Magick::Image::write(const std::string &imageSpec_)
4798 fileName(imageSpec_);
4800 WriteImage(constImageInfo(),image(),&exceptionInfo);
4804 void Magick::Image::writePixels(const Magick::QuantumType quantum_,
4805 unsigned char *destination_)
4810 quantum_info=AcquireQuantumInfo(imageInfo(),image());
4812 ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4813 quantum_,destination_, &exceptionInfo);
4814 quantum_info=DestroyQuantumInfo(quantum_info);
4818 void Magick::Image::zoom(const Geometry &geometry_)
4831 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4835 newImage=ResizeImage(constImage(),width,height,image()->filter,&exceptionInfo);
4836 replaceImage(newImage);
4840 Magick::Image::Image(MagickCore::Image *image_)
4841 : _imgRef(new ImageRef(image_))
4845 MagickCore::Image *&Magick::Image::image(void)
4847 return(_imgRef->image());
4850 const MagickCore::Image *Magick::Image::constImage(void) const
4852 return(_imgRef->image());
4855 MagickCore::ImageInfo *Magick::Image::imageInfo(void)
4857 return(_imgRef->options()->imageInfo());
4860 const MagickCore::ImageInfo *Magick::Image::constImageInfo(void) const
4862 return(_imgRef->options()->imageInfo());
4865 Magick::Options *Magick::Image::options(void)
4867 return(_imgRef->options());
4870 const Magick::Options *Magick::Image::constOptions(void) const
4872 return(_imgRef->options());
4875 MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)
4877 return(_imgRef->options()->quantizeInfo());
4880 const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
4882 return(_imgRef->options()->quantizeInfo());
4885 void Magick::Image::modifyImage(void)
4888 Lock(&_imgRef->_mutexLock);
4889 if (_imgRef->_refCount == 1)
4891 // De-register image and return
4898 replaceImage(CloneImage(image(),0,0,MagickTrue,&exceptionInfo));
4902 ssize_t Magick::Image::registerId(void)
4904 Lock(&_imgRef->_mutexLock);
4905 if ( _imgRef->id() < 0)
4911 _imgRef->id(_imgRef->id()+1);
4912 sprintf(id,"%.20g\n",(double) _imgRef->id());
4913 SetImageRegistry(ImageRegistryType,id,image(),&exceptionInfo);
4916 return(_imgRef->id());
4919 MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
4925 image = replacement_;
4929 image=AcquireImage(constImageInfo(),&exceptionInfo);
4934 Lock(&_imgRef->_mutexLock);
4936 if (_imgRef->_refCount == 1)
4938 // We own the image, just replace it, and de-register
4940 _imgRef->image(image);
4944 // We don't own the image, dereference and replace with copy
4945 --_imgRef->_refCount;
4946 _imgRef=new ImageRef(image,constOptions());
4950 return(_imgRef->_image);
4953 void Magick::Image::unregisterId(void)