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
1562 image_type=constOptions()->type();
1563 if (image_type == UndefinedType)
1564 image_type=GetImageType(constImage(),&exceptionInfo);
1569 void Magick::Image::type(const Magick::ImageType type_)
1572 options()->type(type_);
1574 SetImageType(image(),type_,&exceptionInfo);
1578 void Magick::Image::verbose(const bool verboseFlag_)
1581 options()->verbose(verboseFlag_);
1584 bool Magick::Image::verbose(void) const
1586 return(constOptions()->verbose());
1589 void Magick::Image::view(const std::string &view_)
1592 options()->view(view_);
1595 std::string Magick::Image::view(void) const
1597 return(constOptions()->view());
1600 void Magick::Image::virtualPixelMethod(
1601 const VirtualPixelMethod virtualPixelMethod_)
1605 SetImageVirtualPixelMethod(image(),virtualPixelMethod_,&exceptionInfo);
1609 Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod(void) const
1611 return(GetImageVirtualPixelMethod(constImage()));
1614 void Magick::Image::x11Display(const std::string &display_)
1617 options()->x11Display(display_);
1620 std::string Magick::Image::x11Display(void) const
1622 return(constOptions()->x11Display());
1625 double Magick::Image::xResolution(void) const
1627 return(constImage()->resolution.x);
1630 double Magick::Image::yResolution(void) const
1632 return(constImage()->resolution.y);
1635 void Magick::Image::adaptiveBlur(const double radius_,const double sigma_)
1641 newImage=AdaptiveBlurImage(constImage(),radius_,sigma_,&exceptionInfo);
1642 replaceImage(newImage);
1646 void Magick::Image::adaptiveResize(const Geometry &geometry_)
1659 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
1663 newImage=AdaptiveResizeImage(constImage(),width,height,&exceptionInfo);
1664 replaceImage(newImage);
1668 void Magick::Image::adaptiveSharpen(const double radius_,const double sigma_)
1674 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,&exceptionInfo);
1675 replaceImage(newImage);
1679 void Magick::Image::adaptiveSharpenChannel(const ChannelType channel_,
1680 const double radius_,const double sigma_ )
1686 SetPPChannelMask(channel_);
1687 newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,&exceptionInfo);
1688 RestorePPChannelMask;
1689 replaceImage(newImage);
1693 void Magick::Image::adaptiveThreshold(const size_t width_,const size_t height_,
1694 const ssize_t offset_)
1701 newImage=AdaptiveThresholdImage(constImage(),width_,height_,offset_,
1703 replaceImage(newImage);
1707 void Magick::Image::addNoise(const NoiseType noiseType_)
1713 newImage=AddNoiseImage(constImage(),noiseType_,1.0,&exceptionInfo);
1714 replaceImage(newImage);
1718 void Magick::Image::addNoiseChannel(const ChannelType channel_,
1719 const NoiseType noiseType_)
1725 SetPPChannelMask(channel_);
1726 newImage=AddNoiseImage(constImage(),noiseType_,1.0,&exceptionInfo);
1727 RestorePPChannelMask;
1728 replaceImage(newImage);
1732 void Magick::Image::affineTransform(const DrawableAffine &affine_)
1740 _affine.sx=affine_.sx();
1741 _affine.sy=affine_.sy();
1742 _affine.rx=affine_.rx();
1743 _affine.ry=affine_.ry();
1744 _affine.tx=affine_.tx();
1745 _affine.ty=affine_.ty();
1748 newImage=AffineTransformImage(constImage(),&_affine,&exceptionInfo);
1749 replaceImage(newImage);
1753 void Magick::Image::alpha(const unsigned int alpha_)
1757 SetImageAlpha(image(),alpha_,&exceptionInfo);
1761 void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
1765 SetImageAlphaChannel(image(),alphaOption_,&exceptionInfo);
1769 void Magick::Image::alphaFloodfill(const Color &target_,
1770 const unsigned int alpha_,const ssize_t x_,const ssize_t y_,
1771 const Magick::PaintMethod method_)
1777 GetPixelInfo(constImage(),&target);
1778 target.red=static_cast<PixelInfo>(target_).red;
1779 target.green=static_cast<PixelInfo>(target_).green;
1780 target.blue=static_cast<PixelInfo>(target_).blue;
1781 target.alpha=alpha_;
1783 SetPPChannelMask(AlphaChannel);
1784 FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
1785 method_ == FloodfillMethod ? MagickFalse : MagickTrue,&exceptionInfo);
1786 RestorePPChannelMask;
1790 void Magick::Image::annotate(const std::string &text_,
1791 const Geometry &location_)
1793 annotate(text_,location_,NorthWestGravity,0.0);
1796 void Magick::Image::annotate(const std::string &text_,
1797 const Geometry &boundingArea_,const GravityType gravity_)
1799 annotate(text_,boundingArea_,gravity_,0.0);
1802 void Magick::Image::annotate(const std::string &text_,
1803 const Geometry &boundingArea_,const GravityType gravity_,
1804 const double degrees_)
1810 boundingArea[MaxTextExtent];
1817 drawInfo=options()->drawInfo();
1818 drawInfo->text=const_cast<char *>(text_.c_str());
1819 drawInfo->geometry=0;
1821 if (boundingArea_.isValid())
1823 if (boundingArea_.width() == 0 || boundingArea_.height() == 0)
1825 FormatLocaleString(boundingArea,MaxTextExtent,"%+.20g%+.20g",
1826 (double) boundingArea_.xOff(),(double) boundingArea_.yOff());
1830 (void) CopyMagickString(boundingArea,string(boundingArea_).c_str(),
1833 drawInfo->geometry=boundingArea;
1836 drawInfo->gravity=gravity_;
1838 oaffine=drawInfo->affine;
1839 if (degrees_ != 0.0)
1852 current=drawInfo->affine;
1853 affine.sx=cos(DegreesToRadians(fmod(degrees_,360.0)));
1854 affine.rx=sin(DegreesToRadians(fmod(degrees_,360.0)));
1855 affine.ry=(-sin(DegreesToRadians(fmod(degrees_,360.0))));
1856 affine.sy=cos(DegreesToRadians(fmod(degrees_,360.0)));
1858 drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
1859 drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
1860 drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
1861 drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
1862 drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty
1867 AnnotateImage(image(),drawInfo,&exceptionInfo);
1869 // Restore original values
1870 drawInfo->affine=oaffine;
1872 drawInfo->geometry=0;
1877 void Magick::Image::annotate(const std::string &text_,
1878 const GravityType gravity_)
1885 drawInfo=options()->drawInfo();
1886 drawInfo->text=const_cast<char *>(text_.c_str());
1887 drawInfo->gravity=gravity_;
1890 AnnotateImage(image(),drawInfo,&exceptionInfo);
1892 drawInfo->gravity=NorthWestGravity;
1898 void Magick::Image::artifact(const std::string &name_,const std::string &value_)
1901 (void) SetImageArtifact(image(),name_.c_str(),value_.c_str());
1904 std::string Magick::Image::artifact(const std::string &name_)
1909 value=GetImageArtifact(constImage(),name_.c_str());
1911 return(std::string(value));
1912 return(std::string());
1915 void Magick::Image::attribute(const std::string name_,const std::string value_)
1919 SetImageProperty(image(),name_.c_str(),value_.c_str(),&exceptionInfo);
1923 std::string Magick::Image::attribute(const std::string name_)
1929 value=GetImageProperty(constImage(),name_.c_str(),&exceptionInfo);
1933 return(std::string(value));
1935 return(std::string()); // Intentionally no exception
1938 void Magick::Image::autoGamma(void)
1942 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
1943 (void) AutoGammaImage(image(),&exceptionInfo);
1947 void Magick::Image::autoGammaChannel(const ChannelType channel_)
1951 SetPPChannelMask(channel_);
1952 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
1953 (void) AutoGammaImage(image(),&exceptionInfo);
1954 RestorePPChannelMask;
1958 void Magick::Image::autoLevel(void)
1962 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
1963 (void) AutoLevelImage(image(),&exceptionInfo);
1967 void Magick::Image::autoLevelChannel(const ChannelType channel_)
1971 SetPPChannelMask(channel_);
1972 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
1973 (void) AutoLevelImage(image(),&exceptionInfo);
1974 RestorePPChannelMask;
1978 void Magick::Image::autoOrient(void)
1983 if (image()->orientation == UndefinedOrientation ||
1984 image()->orientation == TopLeftOrientation)
1988 (void) SyncImageSettings(imageInfo(),image(),&exceptionInfo);
1989 newImage=AutoOrientImage(constImage(),image()->orientation,&exceptionInfo);
1990 replaceImage(newImage);
1994 void Magick::Image::blackThreshold(const std::string &threshold_)
1998 BlackThresholdImage(image(),threshold_.c_str(),&exceptionInfo);
2002 void Magick::Image::blackThresholdChannel(const ChannelType channel_,
2003 const std::string &threshold_)
2007 SetPPChannelMask(channel_);
2008 BlackThresholdImage(image(),threshold_.c_str(),&exceptionInfo);
2009 RestorePPChannelMask;
2013 void Magick::Image::blueShift(const double factor_)
2019 newImage=BlueShiftImage(constImage(),factor_,&exceptionInfo);
2020 replaceImage(newImage);
2024 void Magick::Image::blur(const double radius_,const double sigma_)
2030 newImage=BlurImage(constImage(),radius_,sigma_,&exceptionInfo);
2031 replaceImage(newImage);
2035 void Magick::Image::blurChannel(const ChannelType channel_,
2036 const double radius_,const double sigma_)
2042 SetPPChannelMask(channel_);
2043 newImage=BlurImage(constImage(),radius_,sigma_,&exceptionInfo);
2044 RestorePPChannelMask;
2045 replaceImage(newImage);
2049 void Magick::Image::border(const Geometry &geometry_)
2055 borderInfo=geometry_;
2058 newImage=BorderImage(constImage(),&borderInfo,image()->compose,
2060 replaceImage(newImage);
2064 void Magick::Image::brightnessContrast(const double brightness_,
2065 const double contrast_)
2069 BrightnessContrastImage(image(),brightness_,contrast_,&exceptionInfo);
2073 void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
2074 const double brightness_,const double contrast_)
2078 SetPPChannelMask(channel_);
2079 BrightnessContrastImage(image(),brightness_,contrast_,&exceptionInfo);
2080 RestorePPChannelMask;
2084 void Magick::Image::channel(const ChannelType channel_)
2090 newImage=SeparateImage(image(),channel_,&exceptionInfo);
2091 replaceImage(newImage);
2095 void Magick::Image::charcoal(const double radius_,const double sigma_)
2101 newImage=CharcoalImage(image(),radius_,sigma_,&exceptionInfo);
2102 replaceImage(newImage);
2106 void Magick::Image::chop(const Geometry &geometry_)
2115 newImage=ChopImage(image(),&chopInfo,&exceptionInfo);
2116 replaceImage(newImage);
2120 void Magick::Image::chromaBluePrimary(const double x_,const double y_)
2123 image()->chromaticity.blue_primary.x=x_;
2124 image()->chromaticity.blue_primary.y=y_;
2127 void Magick::Image::chromaBluePrimary(double *x_,double *y_) const
2129 *x_=constImage()->chromaticity.blue_primary.x;
2130 *y_=constImage()->chromaticity.blue_primary.y;
2133 void Magick::Image::chromaGreenPrimary(const double x_,const double y_)
2136 image()->chromaticity.green_primary.x=x_;
2137 image()->chromaticity.green_primary.y=y_;
2140 void Magick::Image::chromaGreenPrimary(double *x_,double *y_) const
2142 *x_=constImage()->chromaticity.green_primary.x;
2143 *y_=constImage()->chromaticity.green_primary.y;
2146 void Magick::Image::chromaRedPrimary(const double x_,const double y_)
2149 image()->chromaticity.red_primary.x=x_;
2150 image()->chromaticity.red_primary.y=y_;
2153 void Magick::Image::chromaRedPrimary(double *x_,double *y_) const
2155 *x_=constImage()->chromaticity.red_primary.x;
2156 *y_=constImage()->chromaticity.red_primary.y;
2159 void Magick::Image::chromaWhitePoint(const double x_,const double y_)
2162 image()->chromaticity.white_point.x=x_;
2163 image()->chromaticity.white_point.y=y_;
2166 void Magick::Image::chromaWhitePoint(double *x_,double *y_) const
2168 *x_=constImage()->chromaticity.white_point.x;
2169 *y_=constImage()->chromaticity.white_point.y;
2172 void Magick::Image::cdl(const std::string &cdl_)
2176 (void) ColorDecisionListImage(image(),cdl_.c_str(),&exceptionInfo);
2180 void Magick::Image::clamp(void)
2184 ClampImage(image(),&exceptionInfo);
2188 void Magick::Image::clampChannel(const ChannelType channel_)
2192 SetPPChannelMask(channel_);
2193 ClampImage(image(),&exceptionInfo);
2194 RestorePPChannelMask;
2198 void Magick::Image::clip(void)
2202 ClipImage(image(),&exceptionInfo);
2206 void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
2210 ClipImagePath(image(),pathname_.c_str(),(MagickBooleanType) inside_,
2215 void Magick::Image::clut(const Image &clutImage_,
2216 const PixelInterpolateMethod method)
2220 ClutImage(image(),clutImage_.constImage(),method,&exceptionInfo);
2224 void Magick::Image::clutChannel(const ChannelType channel_,
2225 const Image &clutImage_,const PixelInterpolateMethod method)
2229 SetPPChannelMask(channel_);
2230 ClutImage(image(),clutImage_.constImage(),method,&exceptionInfo);
2231 RestorePPChannelMask;
2235 void Magick::Image::colorize(const unsigned int alpha_,const Color &penColor_)
2237 colorize(alpha_,alpha_,alpha_,penColor_);
2240 void Magick::Image::colorize(const unsigned int alphaRed_,
2241 const unsigned int alphaGreen_,const unsigned int alphaBlue_,
2242 const Color &penColor_)
2245 blend[MaxTextExtent];
2254 if (!penColor_.isValid())
2255 throwExceptionExplicit(OptionError,"Pen color argument is invalid");
2257 FormatLocaleString(blend,MaxTextExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
2260 GetPixelInfo(image(),&target);
2261 pixel=static_cast<PixelInfo>(penColor_);
2262 target.red=pixel.red;
2263 target.green=pixel.green;
2264 target.blue=pixel.blue;
2265 target.alpha=pixel.alpha;
2267 newImage=ColorizeImage(image(),blend,&target,&exceptionInfo);
2268 replaceImage(newImage);
2272 void Magick::Image::colorMap(const size_t index_,const Color &color_)
2279 if (index_ > (MaxColormapSize-1))
2280 throwExceptionExplicit(OptionError,
2281 "Colormap index must be less than MaxColormapSize");
2283 if (!color_.isValid())
2284 throwExceptionExplicit(OptionError,"Color argument is invalid");
2288 // Ensure that colormap size is large enough
2289 if (colorMapSize() < (index_+1))
2290 colorMapSize(index_+1);
2292 // Set color at index in colormap
2293 (imageptr->colormap)[index_]=color_;
2296 Magick::Color Magick::Image::colorMap(const size_t index_) const
2298 if (!constImage()->colormap)
2300 throwExceptionExplicit(OptionError,"Image does not contain a colormap");
2304 if (index_ > constImage()->colors-1)
2305 throwExceptionExplicit(OptionError,"Index out of range");
2307 return(Magick::Color((constImage()->colormap)[index_]));
2310 void Magick::Image::colorMatrix(const size_t order_,
2311 const double *color_matrix_)
2317 kernel_info=AcquireKernelInfo((const char *) NULL);
2318 kernel_info->width=order_;
2319 kernel_info->height=order_;
2320 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2321 order_*sizeof(*kernel_info->values));
2322 if (kernel_info->values != (MagickRealType *) NULL)
2327 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2328 kernel_info->values[i]=color_matrix_[i];
2329 newImage=ColorMatrixImage(image(),kernel_info,&exceptionInfo);
2330 replaceImage(newImage);
2332 kernel_info=DestroyKernelInfo(kernel_info);
2336 bool Magick::Image::compare(const Image &reference_)
2347 status=static_cast<bool>(IsImagesEqual(image(),ref.image(),&exceptionInfo));
2352 double Magick::Image::compare(const Image &reference_,const MetricType metric_)
2358 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2364 double Magick::Image::compareChannel(const ChannelType channel_,
2365 const Image &reference_,const MetricType metric_)
2371 SetPPChannelMask(channel_);
2372 GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2374 RestorePPChannelMask;
2379 Magick::Image Magick::Image::compare(const Image &reference_,
2380 const MetricType metric_,double *distortion)
2386 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2389 if (newImage == (MagickCore::Image *) NULL)
2390 return(Magick::Image());
2392 return(Magick::Image(newImage));
2395 Magick::Image Magick::Image::compareChannel(const ChannelType channel_,
2396 const Image &reference_,const MetricType metric_,double *distortion)
2402 SetPPChannelMask(channel_);
2403 newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2405 RestorePPChannelMask;
2407 if (newImage == (MagickCore::Image *) NULL)
2408 return(Magick::Image());
2410 return(Magick::Image(newImage));
2413 void Magick::Image::composite(const Image &compositeImage_,
2414 const Geometry &offset_,const CompositeOperator compose_)
2424 ParseMetaGeometry(static_cast<std::string>(offset_).c_str(),&x,&y,&width,
2429 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickFalse,
2430 x,y,&exceptionInfo);
2434 void Magick::Image::composite(const Image &compositeImage_,
2435 const GravityType gravity_,const CompositeOperator compose_)
2441 SetGeometry(compositeImage_.constImage(),&geometry);
2442 GravityAdjustGeometry(columns(),rows(),gravity_,&geometry);
2445 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickFalse,
2446 geometry.x,geometry.y,&exceptionInfo);
2450 void Magick::Image::composite(const Image &compositeImage_,
2451 const ssize_t xOffset_,const ssize_t yOffset_,
2452 const CompositeOperator compose_)
2454 // Image supplied as compositeImage is composited with current image and
2455 // results in updating current image.
2458 CompositeImage(image(),compositeImage_.constImage(),compose_,MagickFalse,
2459 xOffset_,yOffset_,&exceptionInfo);
2463 void Magick::Image::contrast(const size_t sharpen_)
2467 ContrastImage(image(),(MagickBooleanType) sharpen_,&exceptionInfo);
2471 void Magick::Image::contrastStretch(const double blackPoint_,
2472 const double whitePoint_)
2476 ContrastStretchImage(image(),blackPoint_,whitePoint_,&exceptionInfo);
2480 void Magick::Image::contrastStretchChannel(const ChannelType channel_,
2481 const double blackPoint_,const double whitePoint_)
2485 SetPPChannelMask(channel_);
2486 ContrastStretchImage(image(),blackPoint_,whitePoint_,&exceptionInfo);
2487 RestorePPChannelMask;
2491 void Magick::Image::convolve(const size_t order_,const double *kernel_)
2497 kernel_info=AcquireKernelInfo((const char *) NULL);
2498 kernel_info->width=order_;
2499 kernel_info->height=order_;
2500 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2501 order_*sizeof(*kernel_info->values));
2502 if (kernel_info->values != (MagickRealType *) NULL)
2507 for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2508 kernel_info->values[i]=kernel_[i];
2509 newImage=ConvolveImage(image(),kernel_info,&exceptionInfo);
2510 replaceImage(newImage);
2512 kernel_info=DestroyKernelInfo(kernel_info);
2516 void Magick::Image::crop(const Geometry &geometry_)
2525 newImage=CropImage(constImage(),&cropInfo,&exceptionInfo);
2526 replaceImage(newImage);
2530 void Magick::Image::cycleColormap(const ssize_t amount_)
2534 CycleColormapImage(image(),amount_,&exceptionInfo);
2538 void Magick::Image::decipher(const std::string &passphrase_)
2542 DecipherImage(image(),passphrase_.c_str(),&exceptionInfo);
2546 void Magick::Image::defineSet(const std::string &magick_,
2547 const std::string &key_,bool flag_)
2553 definition=magick_ + ":" + key_;
2555 (void) SetImageOption(imageInfo(),definition.c_str(),"");
2557 DeleteImageOption(imageInfo(),definition.c_str());
2560 bool Magick::Image::defineSet(const std::string &magick_,
2561 const std::string &key_ ) const
2569 key=magick_ + ":" + key_;
2570 option=GetImageOption(constImageInfo(),key.c_str());
2576 void Magick::Image::defineValue(const std::string &magick_,
2577 const std::string &key_,const std::string &value_)
2584 format=magick_ + ":" + key_;
2586 (void) SetImageOption(imageInfo(),format.c_str(),option.c_str());
2589 std::string Magick::Image::defineValue(const std::string &magick_,
2590 const std::string &key_) const
2598 definition=magick_ + ":" + key_;
2599 option=GetImageOption(constImageInfo(),definition.c_str());
2601 return(std::string(option));
2602 return(std::string());
2605 void Magick::Image::deskew(const double threshold_)
2611 newImage=DeskewImage(constImage(),threshold_,&exceptionInfo);
2612 replaceImage(newImage);
2616 void Magick::Image::despeckle(void)
2622 newImage=DespeckleImage(constImage(),&exceptionInfo);
2623 replaceImage(newImage);
2627 void Magick::Image::display(void)
2630 DisplayImages(imageInfo(),image(),&exceptionInfo);
2634 void Magick::Image::distort(const DistortImageMethod method_,
2635 const size_t numberArguments_,const double *arguments_,const bool bestfit_)
2641 newImage=DistortImage(constImage(), method_,numberArguments_,arguments_,
2642 bestfit_ == true ? MagickTrue : MagickFalse,&exceptionInfo);
2643 replaceImage(newImage);
2647 void Magick::Image::draw(const Magick::Drawable &drawable_)
2654 wand=DrawAllocateWand(options()->drawInfo(),image());
2658 drawable_.operator()(wand);
2662 ClonePPDrawException(wand);
2663 wand=DestroyDrawingWand(wand);
2664 ThrowPPDrawException;
2668 void Magick::Image::draw(const std::list<Magick::Drawable> &drawable_)
2675 wand=DrawAllocateWand(options()->drawInfo(),image());
2679 for (std::list<Magick::Drawable>::const_iterator p = drawable_.begin();
2680 p != drawable_.end(); p++ )
2682 p->operator()(wand);
2683 if (DrawGetExceptionType(wand) != UndefinedException)
2687 if (DrawGetExceptionType(wand) == UndefinedException)
2690 ClonePPDrawException(wand);
2691 wand=DestroyDrawingWand(wand);
2692 ThrowPPDrawException;
2696 void Magick::Image::edge(const double radius_)
2702 newImage=EdgeImage(constImage(),radius_,&exceptionInfo);
2703 replaceImage(newImage);
2707 void Magick::Image::emboss(const double radius_,const double sigma_)
2713 newImage=EmbossImage(constImage(),radius_,sigma_,&exceptionInfo);
2714 replaceImage(newImage);
2718 void Magick::Image::encipher(const std::string &passphrase_)
2722 EncipherImage(image(),passphrase_.c_str(),&exceptionInfo);
2726 void Magick::Image::enhance(void)
2732 newImage=EnhanceImage(constImage(),&exceptionInfo);
2733 replaceImage(newImage);
2737 void Magick::Image::equalize(void)
2741 EqualizeImage(image(),&exceptionInfo);
2745 void Magick::Image::erase(void)
2749 SetImageBackgroundColor(image(),&exceptionInfo);
2753 void Magick::Image::extent(const Geometry &geometry_ )
2759 extentInfo=geometry_;
2762 extentInfo.x=geometry_.xOff();
2763 extentInfo.y=geometry_.yOff();
2765 newImage=ExtentImage(image(),&extentInfo,&exceptionInfo);
2766 replaceImage(newImage);
2770 void Magick::Image::extent(const Geometry &geometry_,
2771 const Color &backgroundColor_)
2773 backgroundColor(backgroundColor_);
2777 void Magick::Image::extent(const Geometry &geometry_,
2778 const Color &backgroundColor_,const GravityType gravity_)
2780 backgroundColor(backgroundColor_);
2781 extent(geometry_,gravity_);
2784 void Magick::Image::extent(const Geometry &geometry_,
2785 const GravityType gravity_)
2790 SetGeometry(image(),&geometry);
2791 geometry.width=geometry_.width();
2792 geometry.height=geometry_.height();
2793 GravityAdjustGeometry(image()->columns,image()->rows,gravity_,&geometry);
2797 void Magick::Image::flip(void)
2803 newImage=FlipImage(constImage(),&exceptionInfo);
2804 replaceImage(newImage);
2808 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2809 const unsigned int alpha_,const PaintMethod method_)
2816 GetPixelInfo(image(),&target);
2817 pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2818 target.red=pixel.red;
2819 target.green=pixel.green;
2820 target.blue=pixel.blue;
2821 target.alpha=alpha_;
2824 FloodfillPaintImage(image(),options()->drawInfo(),&target,
2825 static_cast<ssize_t>(x_), static_cast<ssize_t>(y_),
2826 method_ == FloodfillMethod ? MagickFalse : MagickTrue,&exceptionInfo);
2830 void Magick::Image::floodFillColor(const Geometry &point_,
2831 const Magick::Color &fillColor_)
2833 floodFillTexture(point_,Image(Geometry(1,1),fillColor_));
2836 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2837 const Magick::Color &fillColor_)
2839 floodFillTexture(x_,y_,Image(Geometry(1,1),fillColor_));
2842 void Magick::Image::floodFillColor(const Geometry &point_,
2843 const Magick::Color &fillColor_,const Magick::Color &borderColor_)
2845 floodFillTexture(point_,Image(Geometry(1,1),fillColor_),borderColor_);
2848 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2849 const Magick::Color &fillColor_,const Magick::Color &borderColor_)
2851 floodFillTexture(x_,y_,Image(Geometry(1,1),fillColor_),borderColor_);
2854 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2855 const Magick::Image &texture_)
2857 floodFillTexture(point_.xOff(),point_.yOff(),texture_);
2860 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2861 const Magick::Image &texture_)
2871 // Set drawing fill pattern
2872 fillPattern=(MagickCore::Image *)NULL;
2873 if (options()->fillPattern() != (MagickCore::Image *)NULL)
2876 fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
2880 options()->fillPattern(texture_.constImage());
2883 Pixels pixels(*this);
2885 p=pixels.get(x_,y_,1,1);
2892 GetPixelInfo(constImage(),&target);
2893 target.red=GetPixelRed(constImage(),p);
2894 target.green=GetPixelGreen(constImage(),p);
2895 target.blue=GetPixelBlue(constImage(),p);
2897 FloodfillPaintImage(image(),options()->drawInfo(),&target,
2898 static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),MagickFalse,
2900 options()->fillPattern(fillPattern);
2904 options()->fillPattern(fillPattern);
2907 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2908 const Magick::Image &texture_,const Magick::Color &borderColor_)
2910 floodFillTexture(point_.xOff(),point_.yOff(),texture_,borderColor_);
2913 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2914 const Magick::Image &texture_,const Magick::Color &borderColor_)
2924 // Set drawing fill pattern
2925 fillPattern=(MagickCore::Image *)NULL;
2926 if (options()->fillPattern() != (MagickCore::Image *)NULL)
2929 fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
2933 options()->fillPattern(texture_.constImage());
2935 GetPixelInfo(constImage(),&target);
2936 target.red=static_cast<PixelInfo>(borderColor_).red;
2937 target.green=static_cast<PixelInfo>(borderColor_).green;
2938 target.blue=static_cast<PixelInfo>(borderColor_).blue;
2940 FloodfillPaintImage(image(),options()->drawInfo(),&target,
2941 static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),MagickTrue,
2943 options()->fillPattern(fillPattern);
2947 void Magick::Image::flop(void)
2953 newImage=FlopImage(constImage(),&exceptionInfo);
2954 replaceImage(newImage);
2958 void Magick::Image::fontTypeMetrics(const std::string &text_,
2959 TypeMetric *metrics)
2964 drawInfo=options()->drawInfo();
2965 drawInfo->text=const_cast<char *>(text_.c_str());
2967 GetTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),&exceptionInfo);
2972 void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
2973 TypeMetric *metrics)
2978 drawInfo=options()->drawInfo();
2979 drawInfo->text=const_cast<char *>(text_.c_str());
2981 GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),&exceptionInfo);
2986 void Magick::Image::frame(const Geometry &geometry_)
2994 info.x=static_cast<ssize_t>(geometry_.width());
2995 info.y=static_cast<ssize_t>(geometry_.height());
2996 info.width=columns() + (static_cast<size_t>(info.x) << 1);
2997 info.height=rows() + (static_cast<size_t>(info.y) << 1);
2998 info.outer_bevel=geometry_.xOff();
2999 info.inner_bevel=geometry_.yOff();
3002 newImage=FrameImage(constImage(),&info,image()->compose,&exceptionInfo);
3003 replaceImage(newImage);
3007 void Magick::Image::frame(const size_t width_,const size_t height_,
3008 const ssize_t outerBevel_,const ssize_t innerBevel_)
3016 info.x=static_cast<ssize_t>(width_);
3017 info.y=static_cast<ssize_t>(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=static_cast<ssize_t>(outerBevel_);
3021 info.inner_bevel=static_cast<ssize_t>(innerBevel_);
3024 newImage=FrameImage(constImage(),&info,image()->compose,&exceptionInfo);
3025 replaceImage(newImage);
3029 void Magick::Image::fx(const std::string expression_)
3035 newImage=FxImage(constImage(),expression_.c_str(),&exceptionInfo);
3036 replaceImage(newImage);
3040 void Magick::Image::fx(const std::string expression_,
3041 const Magick::ChannelType channel_)
3047 SetPPChannelMask(channel_);
3048 newImage=FxImage(constImage(),expression_.c_str(),&exceptionInfo);
3049 RestorePPChannelMask;
3050 replaceImage(newImage);
3054 void Magick::Image::gamma(const double gamma_)
3058 GammaImage(image(),gamma_,&exceptionInfo);
3062 void Magick::Image::gamma(const double gammaRed_,const double gammaGreen_,
3063 const double gammaBlue_)
3066 gamma[MaxTextExtent + 1];
3068 FormatLocaleString(gamma,MaxTextExtent,"%3.6f/%3.6f/%3.6f/",gammaRed_,
3069 gammaGreen_,gammaBlue_);
3073 GammaImage(image(),atof(gamma),&exceptionInfo);
3077 void Magick::Image::gaussianBlur(const double width_,const double sigma_)
3083 newImage=GaussianBlurImage(constImage(),width_,sigma_,&exceptionInfo);
3084 replaceImage(newImage);
3088 void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
3089 const double width_,const double sigma_)
3095 SetPPChannelMask(channel_);
3096 newImage=GaussianBlurImage(constImage(),width_,sigma_,&exceptionInfo);
3097 RestorePPChannelMask;
3098 replaceImage(newImage);
3102 const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
3103 const ssize_t y_,const size_t columns_,const size_t rows_) const
3109 p=(*GetVirtualPixels)(constImage(),x_, y_,columns_, rows_,&exceptionInfo);
3114 const void *Magick::Image::getConstMetacontent(void) const
3119 result=GetVirtualMetacontent(constImage());
3122 throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
3127 void *Magick::Image::getMetacontent(void )
3132 result=GetAuthenticMetacontent(image());
3135 throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
3140 Magick::Quantum *Magick::Image::getPixels(const ssize_t x_,const ssize_t y_,
3141 const size_t columns_,const size_t rows_)
3148 result=(*GetAuthenticPixels)(image(),x_, y_,columns_,rows_,&exceptionInfo);
3154 void Magick::Image::haldClut(const Image &clutImage_)
3158 (void) HaldClutImage(image(),clutImage_.constImage(),&exceptionInfo);
3162 void Magick::Image::implode(const double factor_)
3168 newImage=ImplodeImage(constImage(),factor_,image()->interpolate,
3170 replaceImage(newImage);
3174 void Magick::Image::inverseFourierTransform(const Image &phase_)
3176 inverseFourierTransform(phase_,true);
3179 void Magick::Image::inverseFourierTransform(const Image &phase_,
3180 const bool magnitude_)
3186 newImage=InverseFourierTransformImage(constImage(),phase_.constImage(),
3187 magnitude_ == true ? MagickTrue : MagickFalse,&exceptionInfo);
3188 replaceImage(newImage);
3192 void Magick::Image::level(const double blackPoint_,const double whitePoint_,
3193 const double gamma_)
3197 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,&exceptionInfo);
3201 void Magick::Image::levelChannel(const ChannelType channel_,
3202 const double blackPoint_,const double whitePoint_,const double gamma_)
3206 SetPPChannelMask(channel_);
3207 (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,&exceptionInfo);
3208 RestorePPChannelMask;
3212 void Magick::Image::levelColors(const Color &blackColor_,
3213 const Color &whiteColor_,const bool invert_)
3222 GetPixelInfo(image(),&black);
3223 pixel=static_cast<PixelInfo>(blackColor_);
3224 black.red=pixel.red;
3225 black.green=pixel.green;
3226 black.blue=pixel.blue;
3227 black.alpha=pixel.alpha;
3229 GetPixelInfo(image(),&white);
3230 pixel=static_cast<PixelInfo>(whiteColor_);
3231 white.red=pixel.red;
3232 white.green=pixel.green;
3233 white.blue=pixel.blue;
3234 white.alpha=pixel.alpha;
3237 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3238 MagickTrue : MagickFalse,&exceptionInfo);
3242 void Magick::Image::levelColorsChannel(const ChannelType channel_,
3243 const Color &blackColor_,const Color &whiteColor_,const bool invert_)
3252 GetPixelInfo(image(),&black);
3253 pixel=static_cast<PixelInfo>(blackColor_);
3254 black.red=pixel.red;
3255 black.green=pixel.green;
3256 black.blue=pixel.blue;
3257 black.alpha=pixel.alpha;
3259 GetPixelInfo(image(),&white);
3260 pixel=static_cast<PixelInfo>(whiteColor_);
3261 white.red=pixel.red;
3262 white.green=pixel.green;
3263 white.blue=pixel.blue;
3264 white.alpha=pixel.alpha;
3267 SetPPChannelMask(channel_);
3268 (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3269 MagickTrue : MagickFalse,&exceptionInfo);
3270 RestorePPChannelMask;
3274 void Magick::Image::linearStretch(const double blackPoint_,
3275 const double whitePoint_)
3279 LinearStretchImage(image(),blackPoint_,whitePoint_,&exceptionInfo);
3283 void Magick::Image::liquidRescale(const Geometry &geometry_)
3296 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3300 newImage=LiquidRescaleImage(image(),width,height,x,y,&exceptionInfo);
3301 replaceImage(newImage);
3305 void Magick::Image::magnify(void)
3311 newImage=MagnifyImage(constImage(),&exceptionInfo);
3312 replaceImage(newImage);
3316 void Magick::Image::map(const Image &mapImage_,const bool dither_)
3320 options()->quantizeDither(dither_);
3321 RemapImage(options()->quantizeInfo(),image(),mapImage_.constImage(),
3326 void Magick::Image::medianFilter(const double radius_)
3332 newImage=StatisticImage(image(),MedianStatistic,(size_t) radius_,
3333 (size_t) radius_,&exceptionInfo);
3334 replaceImage(newImage);
3338 void Magick::Image::minify(void)
3344 newImage=MinifyImage(constImage(),&exceptionInfo);
3345 replaceImage(newImage);
3349 void Magick::Image::modulate(const double brightness_,const double saturation_,
3353 modulate[MaxTextExtent + 1];
3355 FormatLocaleString(modulate,MaxTextExtent,"%3.6f,%3.6f,%3.6f",brightness_,
3360 ModulateImage(image(),modulate,&exceptionInfo);
3364 void Magick::Image::morphology(const MorphologyMethod method_,
3365 const std::string kernel_,const ssize_t iterations_)
3373 kernel=AcquireKernelInfo(kernel_.c_str());
3374 if (kernel == (KernelInfo *)NULL)
3375 throwExceptionExplicit(OptionError,"Unable to parse kernel.");
3378 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3380 replaceImage(newImage);
3381 kernel=DestroyKernelInfo(kernel);
3385 void Magick::Image::morphology(const MorphologyMethod method_,
3386 const KernelInfoType kernel_,const std::string arguments_,
3387 const ssize_t iterations_)
3395 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3396 if (option == (const char *)NULL)
3397 throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
3399 kernel=std::string(option);
3400 if (!arguments_.empty())
3401 kernel+=":"+arguments_;
3403 morphology(method_,kernel,iterations_);
3406 void Magick::Image::morphologyChannel(const ChannelType channel_,
3407 const MorphologyMethod method_,const std::string kernel_,
3408 const ssize_t iterations_)
3416 kernel=AcquireKernelInfo(kernel_.c_str());
3417 if (kernel == (KernelInfo *)NULL)
3418 throwExceptionExplicit(OptionError,"Unable to parse kernel.");
3421 SetPPChannelMask(channel_);
3422 newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3424 RestorePPChannelMask;
3425 replaceImage(newImage);
3426 kernel=DestroyKernelInfo(kernel);
3430 void Magick::Image::morphologyChannel(const ChannelType channel_,
3431 const MorphologyMethod method_,const KernelInfoType kernel_,
3432 const std::string arguments_,const ssize_t iterations_)
3440 option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3441 if (option == (const char *)NULL)
3442 throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
3444 kernel=std::string(option);
3445 if (!arguments_.empty())
3446 kernel+=":"+arguments_;
3448 morphologyChannel(channel_,method_,kernel,iterations_);
3451 void Magick::Image::motionBlur(const double radius_,const double sigma_,
3452 const double angle_)
3458 newImage=MotionBlurImage(constImage(),radius_,sigma_,angle_,&exceptionInfo);
3459 replaceImage(newImage);
3463 void Magick::Image::negate(const bool grayscale_)
3467 NegateImage(image(),(MagickBooleanType) grayscale_,&exceptionInfo);
3471 void Magick::Image::negateChannel(const ChannelType channel_,
3472 const bool grayscale_)
3476 SetPPChannelMask(channel_);
3477 NegateImage(image(),(MagickBooleanType) grayscale_,&exceptionInfo);
3478 RestorePPChannelMask;
3482 void Magick::Image::normalize(void)
3486 NormalizeImage(image(),&exceptionInfo);
3490 void Magick::Image::oilPaint(const double radius_,const double sigma_)
3496 newImage=OilPaintImage(constImage(),radius_,sigma_,&exceptionInfo);
3497 replaceImage(newImage);
3501 void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_)
3511 if (!opaqueColor_.isValid())
3512 throwExceptionExplicit(OptionError,"Opaque color argument is invalid");
3514 if (!penColor_.isValid())
3515 throwExceptionExplicit(OptionError,"Pen color argument is invalid");
3518 opaqueColor=opaqueColor_;
3522 (void) QueryColorCompliance(opaqueColor.c_str(),AllCompliance,&opaque,
3524 (void) QueryColorCompliance(penColor.c_str(),AllCompliance,&pen,
3526 OpaquePaintImage(image(),&opaque,&pen,MagickFalse,&exceptionInfo);
3530 void Magick::Image::orderedDither(std::string thresholdMap_)
3534 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),&exceptionInfo);
3538 void Magick::Image::orderedDitherChannel(const ChannelType channel_,
3539 std::string thresholdMap_)
3543 SetPPChannelMask(channel_);
3544 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),&exceptionInfo);
3545 RestorePPChannelMask;
3549 void Magick::Image::perceptible(const double epsilon_)
3553 PerceptibleImage(image(),epsilon_,&exceptionInfo);
3557 void Magick::Image::perceptibleChannel(const ChannelType channel_,
3558 const double epsilon_)
3562 SetPPChannelMask(channel_);
3563 PerceptibleImage(image(),epsilon_,&exceptionInfo);
3564 RestorePPChannelMask;
3568 void Magick::Image::ping(const std::string &imageSpec_)
3574 options()->fileName(imageSpec_);
3575 newImage=PingImage(imageInfo(),&exceptionInfo);
3576 replaceImage(newImage);
3580 void Magick::Image::ping(const Blob& blob_)
3586 newImage=PingBlob(imageInfo(),blob_.data(),blob_.length(),&exceptionInfo);
3587 replaceImage(newImage);
3591 void Magick::Image::pixelColor(const ssize_t x_,const ssize_t y_,
3592 const Color &color_)
3600 // Test arguments to ensure they are within the image.
3601 if (y_ > (ssize_t) rows() || x_ > (ssize_t) columns())
3602 throwExceptionExplicit(OptionError,"Access outside of image boundary");
3606 // Set image to DirectClass
3607 classType(DirectClass );
3610 Pixels pixels(*this);
3612 pixel=pixels.get(x_, y_, 1, 1 );
3614 MagickCore::SetPixelInfoPixel(constImage(),&packet,pixel);
3615 // Tell ImageMagick that pixels have been updated
3619 Magick::Color Magick::Image::pixelColor(const ssize_t x_,
3620 const ssize_t y_) const
3625 pixel=getConstPixels(x_,y_,1,1);
3631 MagickCore::GetPixelInfoPixel(constImage(),pixel,&packet);
3632 return(Color(packet));
3635 return(Color()); // invalid
3638 void Magick::Image::polaroid(const std::string &caption_,const double angle_,
3639 const PixelInterpolateMethod method_)
3645 newImage=PolaroidImage(constImage(),options()->drawInfo(),caption_.c_str(),
3646 angle_,method_,&exceptionInfo);
3647 replaceImage(newImage);
3651 void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
3655 PosterizeImage(image(),levels_,method_,&exceptionInfo);
3659 void Magick::Image::posterizeChannel(const ChannelType channel_,
3660 const size_t levels_,const DitherMethod method_)
3664 SetPPChannelMask(channel_);
3665 PosterizeImage(image(),levels_,method_,&exceptionInfo);
3666 RestorePPChannelMask;
3670 void Magick::Image::process(std::string name_,const ssize_t argc,
3676 (void) InvokeDynamicImageFilter(name_.c_str(),&image(),argc,argv,
3681 void Magick::Image::profile(const std::string name_,
3682 const Magick::Blob &profile_)
3686 (void) ProfileImage(image(),name_.c_str(),(unsigned char *)profile_.data(),
3687 profile_.length(),&exceptionInfo);
3691 Magick::Blob Magick::Image::profile(const std::string name_) const
3696 profile=GetImageProfile(constImage(),name_.c_str());
3698 if (profile == (StringInfo *) NULL)
3700 return(Blob((void*) GetStringInfoDatum(profile),GetStringInfoLength(
3704 void Magick::Image::quantize(const bool measureError_)
3709 options()->quantizeInfo()->measure_error=MagickTrue;
3711 options()->quantizeInfo()->measure_error=MagickFalse;
3714 QuantizeImage(options()->quantizeInfo(),image(),&exceptionInfo);
3718 void Magick::Image::quantumOperator(const ChannelType channel_,
3719 const MagickEvaluateOperator operator_,double rvalue_)
3722 SetPPChannelMask(channel_);
3723 EvaluateImage(image(),operator_,rvalue_,&exceptionInfo);
3724 RestorePPChannelMask;
3728 void Magick::Image::quantumOperator(const ssize_t x_,const ssize_t y_,
3729 const size_t columns_,const size_t rows_,const ChannelType channel_,
3730 const MagickEvaluateOperator operator_,const double rvalue_)
3738 geometry.width = columns_;
3739 geometry.height = rows_;
3744 cropImage=CropImage(image(),&geometry,&exceptionInfo);
3745 SetPPChannelMask(channel_);
3746 EvaluateImage(cropImage,operator_,rvalue_,&exceptionInfo);
3747 RestorePPChannelMask;
3748 (void) CompositeImage(image(),cropImage,image()->alpha_trait ==
3749 BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
3750 geometry.x,geometry.y,&exceptionInfo );
3751 cropImage=DestroyImageList(cropImage);
3755 void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
3758 raiseInfo=geometry_;
3762 RaiseImage(image(),&raiseInfo,raisedFlag_ == true ? MagickTrue : MagickFalse,
3767 void Magick::Image::randomThreshold(const Geometry &thresholds_)
3770 (void) RandomThresholdImage(image(),static_cast<std::string>(
3771 thresholds_).c_str(),&exceptionInfo);
3775 void Magick::Image::randomThresholdChannel(const ChannelType channel_,
3776 const Geometry &thresholds_)
3780 SetPPChannelMask(channel_);
3781 (void) RandomThresholdImage(image(),static_cast<std::string>(
3782 thresholds_).c_str(),&exceptionInfo);
3783 RestorePPChannelMask;
3787 void Magick::Image::read(const Blob &blob_)
3793 newImage=BlobToImage(imageInfo(),static_cast<const void *>(blob_.data()),
3794 blob_.length(),&exceptionInfo);
3795 replaceImage(newImage);
3799 void Magick::Image::read(const Blob &blob_,const Geometry &size_)
3805 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3806 const size_t depth_)
3813 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3814 const size_t depth_,const std::string &magick_)
3819 // Set explicit image format
3820 fileName(magick_ + ':');
3824 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3825 const std::string &magick_)
3829 // Set explicit image format
3830 fileName(magick_ + ':');
3834 void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_)
3840 void Magick::Image::read(const size_t width_,const size_t height_,
3841 const std::string &map_,const StorageType type_,const void *pixels_)
3847 newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
3849 replaceImage(newImage);
3853 void Magick::Image::read(const std::string &imageSpec_)
3859 options()->fileName(imageSpec_);
3860 newImage=ReadImage(imageInfo(),&exceptionInfo);
3862 // Ensure that multiple image frames were not read.
3863 if (newImage && newImage->next)
3868 // Destroy any extra image frames
3869 next=newImage->next;
3872 DestroyImageList(next);
3874 replaceImage(newImage);
3878 void Magick::Image::readPixels(const Magick::QuantumType quantum_,
3879 const unsigned char *source_)
3884 quantum_info=AcquireQuantumInfo(imageInfo(),image());
3886 ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
3887 quantum_,source_,&exceptionInfo);
3888 quantum_info=DestroyQuantumInfo(quantum_info);
3892 void Magick::Image::reduceNoise(void)
3897 void Magick::Image::reduceNoise(const double order_)
3903 newImage=StatisticImage(constImage(),NonpeakStatistic,(size_t) order_,
3904 (size_t) order_,&exceptionInfo);
3905 replaceImage(newImage);
3909 void Magick::Image::resample(const Geometry &geometry_)
3922 // Calculate new size. This code should be supported using binary arguments
3923 // in the ImageMagick library.
3924 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3928 newImage=ResampleImage(constImage(),width,height,image()->filter,
3930 replaceImage(newImage);
3934 void Magick::Image::resize(const Geometry &geometry_)
3947 // Calculate new size. This code should be supported using binary arguments
3948 // in the ImageMagick library.
3949 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3953 newImage=ResizeImage(constImage(),width,height,image()->filter,
3955 replaceImage(newImage);
3959 void Magick::Image::roll(const Geometry &roll_)
3968 if (roll_.xNegative())
3970 if (roll_.yNegative())
3974 newImage=RollImage(constImage(),xOff,yOff,&exceptionInfo);
3975 replaceImage(newImage);
3979 void Magick::Image::roll(const size_t columns_,const size_t rows_)
3985 newImage=RollImage(constImage(),static_cast<ssize_t>(columns_),
3986 static_cast<ssize_t>(rows_),&exceptionInfo);
3987 replaceImage(newImage);
3991 void Magick::Image::rotate(const double degrees_)
3997 newImage=RotateImage(constImage(),degrees_,&exceptionInfo);
3998 replaceImage(newImage);
4002 void Magick::Image::rotationalBlur(const double angle_)
4008 newImage=RotationalBlurImage(constImage(),angle_,&exceptionInfo);
4009 replaceImage(newImage);
4013 void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
4014 const double angle_)
4020 SetPPChannelMask(channel_);
4021 newImage=RotationalBlurImage(constImage(),angle_,&exceptionInfo);
4022 RestorePPChannelMask;
4023 replaceImage(newImage);
4027 void Magick::Image::sample(const Geometry &geometry_)
4040 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4044 newImage=SampleImage(constImage(),width,height,&exceptionInfo);
4045 replaceImage(newImage);
4049 void Magick::Image::scale(const Geometry &geometry_)
4062 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4066 newImage=ScaleImage(constImage(),width,height,&exceptionInfo);
4067 replaceImage(newImage);
4071 void Magick::Image::segment(const double clusterThreshold_,
4072 const double smoothingThreshold_)
4076 SegmentImage(image(),options()->quantizeColorSpace(),
4077 (MagickBooleanType) options()->verbose(),clusterThreshold_,
4078 smoothingThreshold_,&exceptionInfo);
4079 SyncImage(image(),&exceptionInfo);
4083 void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
4084 const double threshold_)
4090 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4092 replaceImage(newImage);
4096 void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
4097 const double radius_,const double sigma_,const double threshold_)
4103 SetPPChannelMask(channel_);
4104 newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4106 RestorePPChannelMask;
4107 replaceImage(newImage);
4111 Magick::Image Magick::Image::separate(const ChannelType channel_)
4117 image=SeparateImage(constImage(),channel_,&exceptionInfo);
4119 if (image == (MagickCore::Image *) NULL)
4120 return(Magick::Image());
4122 return(Magick::Image(image));
4125 void Magick::Image::sepiaTone(const double threshold_)
4131 newImage=SepiaToneImage(constImage(),threshold_,&exceptionInfo);
4132 replaceImage(newImage);
4136 Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
4137 const size_t columns_,const size_t rows_)
4144 result=(*QueueAuthenticPixels)(image(),x_,y_,columns_,rows_,&exceptionInfo);
4149 void Magick::Image::shade(const double azimuth_,const double elevation_,
4150 const bool colorShading_)
4156 newImage=ShadeImage(constImage(),colorShading_ == true ?
4157 MagickTrue : MagickFalse,azimuth_,elevation_,&exceptionInfo);
4158 replaceImage(newImage);
4162 void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
4163 const ssize_t x_,const ssize_t y_)
4169 newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
4171 replaceImage(newImage);
4175 void Magick::Image::sharpen(const double radius_,const double sigma_)
4181 newImage=SharpenImage(constImage(),radius_,sigma_,&exceptionInfo);
4182 replaceImage(newImage);
4186 void Magick::Image::sharpenChannel(const ChannelType channel_,
4187 const double radius_,const double sigma_)
4193 SetPPChannelMask(channel_);
4194 newImage=SharpenImage(constImage(),radius_,sigma_,&exceptionInfo);
4195 RestorePPChannelMask;
4196 replaceImage(newImage);
4200 void Magick::Image::shave(const Geometry &geometry_)
4206 shaveInfo=geometry_;
4209 newImage=ShaveImage(constImage(),&shaveInfo,&exceptionInfo);
4210 replaceImage(newImage);
4214 void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
4220 newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,&exceptionInfo);
4221 replaceImage(newImage);
4225 void Magick::Image::sigmoidalContrast(const size_t sharpen_,
4226 const double contrast,const double midpoint)
4230 (void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
4231 midpoint,&exceptionInfo);
4235 std::string Magick::Image::signature(const bool force_) const
4240 Lock(&_imgRef->_mutexLock);
4242 // Re-calculate image signature if necessary
4244 if (force_ || !GetImageProperty(constImage(),"Signature",&exceptionInfo) ||
4245 constImage()->taint)
4246 SignatureImage(const_cast<MagickCore::Image *>(constImage()),
4249 property=GetImageProperty(constImage(),"Signature",&exceptionInfo);
4252 return(std::string(property));
4255 void Magick::Image::sketch(const double radius_,const double sigma_,
4256 const double angle_)
4262 newImage=SketchImage(constImage(),radius_,sigma_,angle_,&exceptionInfo);
4263 replaceImage(newImage);
4267 void Magick::Image::solarize(const double factor_)
4271 SolarizeImage(image(),factor_,&exceptionInfo);
4275 void Magick::Image::sparseColor(const ChannelType channel_,
4276 const SparseColorMethod method_,const size_t numberArguments_,
4277 const double *arguments_)
4283 SetPPChannelMask(channel_);
4284 newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
4286 RestorePPChannelMask;
4287 replaceImage(newImage);
4291 void Magick::Image::splice(const Geometry &geometry_)
4297 spliceInfo=geometry_;
4300 newImage=SpliceImage(constImage(),&spliceInfo,&exceptionInfo);
4301 replaceImage(newImage);
4305 void Magick::Image::spread(const size_t amount_)
4311 newImage=SpreadImage(constImage(),amount_,image()->interpolate,
4313 replaceImage(newImage);
4317 void Magick::Image::statistics(ImageStatistics *statistics)
4325 SetPPChannelMask(RedChannel);
4326 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4327 statistics->red.minimum=minimum;
4328 statistics->red.maximum=maximum;
4329 (void) GetImageMean(constImage(),&statistics->red.mean,
4330 &statistics->red.standard_deviation,&exceptionInfo);
4331 (void) GetImageKurtosis(constImage(),&statistics->red.kurtosis,
4332 &statistics->red.skewness,&exceptionInfo);
4334 (void) SetImageChannelMask(image(),GreenChannel);
4335 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4336 statistics->green.minimum=minimum;
4337 statistics->green.maximum=maximum;
4338 (void) GetImageMean(constImage(),&statistics->green.mean,
4339 &statistics->green.standard_deviation,&exceptionInfo);
4340 (void) GetImageKurtosis(constImage(),&statistics->green.kurtosis,
4341 &statistics->green.skewness,&exceptionInfo);
4343 (void) SetImageChannelMask(image(),GreenChannel);
4344 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4345 statistics->blue.minimum=minimum;
4346 statistics->blue.maximum=maximum;
4347 (void) GetImageMean(constImage(),&statistics->blue.mean,
4348 &statistics->blue.standard_deviation,&exceptionInfo);
4349 (void) GetImageKurtosis(constImage(),&statistics->blue.kurtosis,
4350 &statistics->blue.skewness,&exceptionInfo);
4352 (void) SetImageChannelMask(image(),AlphaChannel);
4353 (void) GetImageRange(constImage(),&minimum,&maximum,&exceptionInfo);
4354 statistics->alpha.minimum=minimum;
4355 statistics->alpha.maximum=maximum;
4356 (void) GetImageMean(constImage(),&statistics->alpha.mean,
4357 &statistics->alpha.standard_deviation,&exceptionInfo);
4358 (void) GetImageKurtosis(constImage(),&statistics->alpha.kurtosis,
4359 &statistics->alpha.skewness,&exceptionInfo);
4360 RestorePPChannelMask;
4364 void Magick::Image::stegano(const Image &watermark_)
4370 newImage=SteganoImage(constImage(),watermark_.constImage(),&exceptionInfo);
4371 replaceImage(newImage);
4375 void Magick::Image::stereo(const Image &rightImage_)
4381 newImage=StereoImage(constImage(),rightImage_.constImage(),&exceptionInfo);
4382 replaceImage(newImage);
4386 void Magick::Image::strip(void)
4390 StripImage(image(),&exceptionInfo);
4394 Magick::Image Magick::Image::subImageSearch(const Image &reference_,
4395 const MetricType metric_,Geometry *offset_,double *similarityMetric_,
4396 const double similarityThreshold)
4405 newImage=SimilarityImage(image(),reference_.constImage(),metric_,
4406 similarityThreshold,&offset,similarityMetric_,&exceptionInfo);
4408 if (offset_ != (Geometry *) NULL)
4410 if (newImage == (MagickCore::Image *) NULL)
4411 return(Magick::Image());
4413 return(Magick::Image(newImage));
4416 void Magick::Image::swirl(const double degrees_)
4422 newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
4424 replaceImage(newImage);
4428 void Magick::Image::syncPixels(void)
4431 (*SyncAuthenticPixels)(image(),&exceptionInfo);
4435 void Magick::Image::texture(const Image &texture_)
4439 TextureImage(image(),texture_.constImage(),&exceptionInfo);
4443 void Magick::Image::threshold(const double threshold_)
4447 BilevelImage(image(),threshold_,&exceptionInfo);
4451 void Magick::Image::thumbnail(const Geometry &geometry_)
4464 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4468 newImage=ThumbnailImage(constImage(),width,height,&exceptionInfo);
4469 replaceImage(newImage);
4473 void Magick::Image::tint(const std::string opacity_)
4482 color=static_cast<PixelInfo>(constOptions()->fillColor());
4483 newImage=TintImage(constImage(),opacity_.c_str(),&color,&exceptionInfo);
4484 replaceImage(newImage);
4488 void Magick::Image::transform(const Geometry &imageGeometry_)
4492 TransformImage(&(image()),0,std::string(imageGeometry_).c_str(),
4497 void Magick::Image::transform(const Geometry &imageGeometry_,
4498 const Geometry &cropGeometry_)
4502 TransformImage(&(image()),std::string(cropGeometry_).c_str(),std::string(
4503 imageGeometry_).c_str(), &exceptionInfo);
4507 void Magick::Image::transformOrigin(const double x_,const double y_)
4510 options()->transformOrigin(x_,y_);
4513 void Magick::Image::transformReset(void)
4516 options()->transformReset();
4519 void Magick::Image::transformScale(const double sx_,const double sy_)
4522 options()->transformScale(sx_,sy_);
4525 void Magick::Image::transparent(const Color &color_)
4533 if (!color_.isValid())
4534 throwExceptionExplicit(OptionError,"Color argument is invalid");
4538 (void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
4541 TransparentPaintImage(image(),&target,TransparentAlpha,MagickFalse,
4546 void Magick::Image::transparentChroma(const Color &colorLow_,
4547 const Color &colorHigh_)
4557 if (!colorLow_.isValid() || !colorHigh_.isValid())
4558 throwExceptionExplicit(OptionError,"Color argument is invalid");
4561 colorHigh=colorHigh_;
4564 (void) QueryColorCompliance(colorLow.c_str(),AllCompliance,&targetLow,
4566 (void) QueryColorCompliance(colorHigh.c_str(),AllCompliance,&targetHigh,
4569 TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
4570 MagickFalse,&exceptionInfo);
4574 void Magick::Image::transpose(void)
4580 newImage=TransposeImage(constImage(),&exceptionInfo);
4581 replaceImage(newImage);
4585 void Magick::Image::transverse(void)
4591 newImage=TransverseImage(constImage(),&exceptionInfo);
4592 replaceImage(newImage);
4596 void Magick::Image::trim(void)
4602 newImage=TrimImage(constImage(),&exceptionInfo);
4603 replaceImage(newImage);
4607 Magick::Image Magick::Image::uniqueColors(void)
4613 image=UniqueImageColors(constImage(),&exceptionInfo);
4615 if (image == (MagickCore::Image *) NULL)
4616 return(Magick::Image());
4618 return(Magick::Image(image));
4621 void Magick::Image::unsharpmask(const double radius_,const double sigma_,
4622 const double amount_,const double threshold_)
4628 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4630 replaceImage(newImage);
4634 void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
4635 const double radius_,const double sigma_,const double amount_,
4636 const double threshold_)
4642 SetPPChannelMask(channel_);
4643 newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4645 RestorePPChannelMask;
4646 replaceImage(newImage);
4650 void Magick::Image::vignette(const double radius_,const double sigma_,
4651 const ssize_t x_,const ssize_t y_)
4657 newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,&exceptionInfo);
4658 replaceImage(newImage);
4662 void Magick::Image::wave(const double amplitude_,const double wavelength_)
4668 newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
4670 replaceImage(newImage);
4674 void Magick::Image::whiteThreshold(const std::string &threshold_)
4678 WhiteThresholdImage(image(),threshold_.c_str(),&exceptionInfo);
4682 void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
4683 const std::string &threshold_)
4687 SetPPChannelMask(channel_);
4688 WhiteThresholdImage(image(),threshold_.c_str(),&exceptionInfo);
4689 RestorePPChannelMask;
4693 void Magick::Image::write(Blob *blob_)
4696 length=2048; // Efficient size for small images
4703 data=ImagesToBlob(constImageInfo(),image(),&length,&exceptionInfo);
4705 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4708 void Magick::Image::write(Blob *blob_,const std::string &magick_)
4711 length=2048; // Efficient size for small images
4719 data=ImagesToBlob(constImageInfo(),image(),&length,&exceptionInfo);
4721 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4724 void Magick::Image::write(Blob *blob_,const std::string &magick_,
4725 const size_t depth_)
4728 length=2048; // Efficient size for small images
4737 data=ImagesToBlob(constImageInfo(),image(),&length,&exceptionInfo);
4739 blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4742 void Magick::Image::write(const ssize_t x_,const ssize_t y_,
4743 const size_t columns_,const size_t rows_,const std::string &map_,
4744 const StorageType type_,void *pixels_)
4747 ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
4752 void Magick::Image::write(const std::string &imageSpec_)
4755 fileName(imageSpec_);
4757 WriteImage(constImageInfo(),image(),&exceptionInfo);
4761 void Magick::Image::writePixels(const Magick::QuantumType quantum_,
4762 unsigned char *destination_)
4767 quantum_info=AcquireQuantumInfo(imageInfo(),image());
4769 ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4770 quantum_,destination_, &exceptionInfo);
4771 quantum_info=DestroyQuantumInfo(quantum_info);
4775 void Magick::Image::zoom(const Geometry &geometry_)
4788 ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4792 newImage=ResizeImage(constImage(),width,height,image()->filter,&exceptionInfo);
4793 replaceImage(newImage);
4797 Magick::Image::Image(MagickCore::Image *image_)
4798 : _imgRef(new ImageRef(image_))
4802 MagickCore::Image *&Magick::Image::image(void)
4804 return(_imgRef->image());
4807 const MagickCore::Image *Magick::Image::constImage(void) const
4809 return(_imgRef->image());
4812 MagickCore::ImageInfo *Magick::Image::imageInfo(void)
4814 return(_imgRef->options()->imageInfo());
4817 const MagickCore::ImageInfo *Magick::Image::constImageInfo(void) const
4819 return(_imgRef->options()->imageInfo());
4822 Magick::Options *Magick::Image::options(void)
4824 return(_imgRef->options());
4827 const Magick::Options *Magick::Image::constOptions(void) const
4829 return(_imgRef->options());
4832 MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)
4834 return(_imgRef->options()->quantizeInfo());
4837 const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
4839 return(_imgRef->options()->quantizeInfo());
4842 void Magick::Image::modifyImage(void)
4845 Lock(&_imgRef->_mutexLock);
4846 if (_imgRef->_refCount == 1)
4848 // De-register image and return
4855 replaceImage(CloneImage(image(),0,0,MagickTrue,&exceptionInfo));
4859 ssize_t Magick::Image::registerId(void)
4861 Lock(&_imgRef->_mutexLock);
4862 if ( _imgRef->id() < 0)
4868 _imgRef->id(_imgRef->id()+1);
4869 sprintf(id,"%.20g\n",(double) _imgRef->id());
4870 SetImageRegistry(ImageRegistryType,id,image(),&exceptionInfo);
4873 return(_imgRef->id());
4876 MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
4882 image = replacement_;
4886 image=AcquireImage(constImageInfo(),&exceptionInfo);
4891 Lock(&_imgRef->_mutexLock);
4893 if (_imgRef->_refCount == 1)
4895 // We own the image, just replace it, and de-register
4897 _imgRef->image(image);
4901 // We don't own the image, dereference and replace with copy
4902 --_imgRef->_refCount;
4903 _imgRef=new ImageRef(image,constOptions());
4907 return(_imgRef->_image);
4910 void Magick::Image::unregisterId(void)