]> granicus.if.org Git - imagemagick/blob - Magick++/lib/Image.cpp
Removed calls to SyncImageSettings.
[imagemagick] / Magick++ / lib / Image.cpp
1 // This may look like C code, but it is really -*- C++ -*-
2 //
3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
4 // Copyright Dirk Lemstra 2013-2015
5 //
6 // Implementation of Image
7 //
8
9 #define MAGICKCORE_IMPLEMENTATION  1
10 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
11
12 #include "Magick++/Include.h"
13 #include <cstdlib>
14 #include <string>
15 #include <string.h>
16 #include <errno.h>
17 #include <math.h>
18
19 using namespace std;
20
21 #include "Magick++/Image.h"
22 #include "Magick++/Functions.h"
23 #include "Magick++/Pixels.h"
24 #include "Magick++/Options.h"
25 #include "Magick++/ImageRef.h"
26
27 #define AbsoluteValue(x)  ((x) < 0 ? -(x) : (x))
28 #define MagickPI  3.14159265358979323846264338327950288419716939937510
29 #define DegreesToRadians(x)  (MagickPI*(x)/180.0)
30 #define ThrowImageException ThrowPPException(quiet())
31
32 MagickPPExport const char *Magick::borderGeometryDefault="6x6+0+0";
33 MagickPPExport const char *Magick::frameGeometryDefault="25x25+6+6";
34 MagickPPExport const char *Magick::raiseGeometryDefault="6x6+0+0";
35
36 MagickPPExport int Magick::operator == (const Magick::Image &left_,
37   const Magick::Image &right_)
38 {
39   // If image pixels and signature are the same, then the image is identical
40   return((left_.rows() == right_.rows()) &&
41     (left_.columns() == right_.columns()) &&
42     (left_.signature() == right_.signature()));
43 }
44
45 MagickPPExport int Magick::operator != (const Magick::Image &left_,
46   const Magick::Image &right_)
47 {
48   return(!(left_ == right_));
49 }
50
51 MagickPPExport int Magick::operator > (const Magick::Image &left_,
52   const Magick::Image &right_)
53 {
54   return(!(left_ < right_) && (left_ != right_));
55 }
56
57 MagickPPExport int Magick::operator < (const Magick::Image &left_,
58   const Magick::Image &right_)
59 {
60   // If image pixels are less, then image is smaller
61   return((left_.rows() * left_.columns()) <
62     (right_.rows() * right_.columns()));
63 }
64
65 MagickPPExport int Magick::operator >= (const Magick::Image &left_,
66   const Magick::Image &right_)
67 {
68   return((left_ > right_) || (left_ == right_));
69 }
70
71 MagickPPExport int Magick::operator <= (const Magick::Image &left_,
72   const Magick::Image &right_)
73 {
74   return((left_ < right_) || ( left_ == right_));
75 }
76
77 Magick::Image::Image(void)
78   : _imgRef(new ImageRef)
79 {
80 }
81
82 Magick::Image::Image(const Blob &blob_)
83   : _imgRef(new ImageRef)
84 {
85   try
86   {
87     // Initialize, Allocate and Read images
88     quiet(true);
89     read(blob_);
90     quiet(false);
91   }
92   catch (const Error&)
93   {
94     // Release resources
95     delete _imgRef;
96     throw;
97   }
98 }
99
100 Magick::Image::Image(const Blob &blob_,const Geometry &size_)
101   : _imgRef(new ImageRef)
102 {
103   try
104   {
105     // Read from Blob
106     quiet(true);
107     read(blob_, size_);
108     quiet(false);
109   }
110   catch(const Error&)
111   {
112     // Release resources
113     delete _imgRef;
114     throw;
115   }
116 }
117
118 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
119   const size_t depth_)
120   : _imgRef(new ImageRef)
121 {
122   try
123   {
124     // Read from Blob
125     quiet(true);
126     read(blob_,size_,depth_);
127     quiet(false);
128   }
129   catch(const Error&)
130   {
131     // Release resources
132     delete _imgRef;
133     throw;
134   }
135 }
136
137 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
138   const size_t depth_,const std::string &magick_)
139   : _imgRef(new ImageRef)
140 {
141   try
142   {
143     // Read from Blob
144     quiet(true);
145     read(blob_,size_,depth_,magick_);
146     quiet(false);
147   }
148   catch(const Error&)
149   {
150     // Release resources
151     delete _imgRef;
152     throw;
153   }
154 }
155
156 Magick::Image::Image(const Blob &blob_,const Geometry &size_,
157   const std::string &magick_)
158   : _imgRef(new ImageRef)
159 {
160   try
161   {
162     // Read from Blob
163     quiet(true);
164     read(blob_,size_,magick_);
165     quiet(false);
166   }
167   catch(const Error&)
168   {
169     // Release resources
170     delete _imgRef;
171     throw;
172   }
173 }
174
175 Magick::Image::Image(const Geometry &size_,const Color &color_)
176   : _imgRef(new ImageRef)
177 {
178   // xc: prefix specifies an X11 color string
179   std::string imageSpec("xc:");
180   imageSpec+=color_;
181
182   try
183   {
184     quiet(true);
185     // Set image size
186     size(size_);
187
188     // Initialize, Allocate and Read images
189     read(imageSpec);
190     quiet(false);
191   }
192   catch(const Error&)
193   {
194     // Release resources
195     delete _imgRef;
196     throw;
197   }
198 }
199
200 Magick::Image::Image(const Image &image_)
201   : _imgRef(image_._imgRef)
202 {
203   _imgRef->increase();
204 }
205
206 Magick::Image::Image(const size_t width_,const size_t height_,
207   const std::string &map_,const StorageType type_,const void *pixels_)
208   : _imgRef(new ImageRef)
209 {
210   try
211   {
212     quiet(true);
213     read(width_,height_,map_.c_str(),type_,pixels_);
214     quiet(false);
215   }
216   catch(const Error&)
217   {
218     // Release resources
219     delete _imgRef;
220     throw;
221   }
222 }
223
224 Magick::Image::Image(const std::string &imageSpec_)
225   : _imgRef(new ImageRef)
226 {
227   try
228   {
229     // Initialize, Allocate and Read images
230     quiet(true);
231     read(imageSpec_);
232     quiet(false);
233   }
234   catch(const Error&)
235   {
236     // Release resources
237     delete _imgRef;
238     throw;
239   }
240 }
241
242 Magick::Image::~Image()
243 {
244   if (_imgRef->decrease() == 0)
245     delete _imgRef;
246
247   _imgRef=(Magick::ImageRef *) NULL;
248 }
249
250 Magick::Image& Magick::Image::operator=(const Magick::Image &image_)
251 {
252   if (this != &image_)
253     {
254       image_._imgRef->increase();
255       if (_imgRef->decrease() == 0)
256         delete _imgRef;
257
258       // Use new image reference
259       _imgRef=image_._imgRef;
260     }
261   return(*this);
262 }
263
264 void Magick::Image::adjoin(const bool flag_)
265 {
266   modifyImage();
267   options()->adjoin(flag_);
268 }
269
270 bool Magick::Image::adjoin(void) const
271 {
272   return(constOptions()->adjoin());
273 }
274
275 void Magick::Image::alpha(const bool matteFlag_)
276 {
277   modifyImage();
278
279   // If matte channel is requested, but image doesn't already have a
280   // matte channel, then create an opaque matte channel.  Likewise, if
281   // the image already has a matte channel but a matte channel is not
282   // desired, then set the matte channel to opaque.
283   GetPPException;
284   if ((matteFlag_ && !constImage()->alpha_trait) ||
285       (constImage()->alpha_trait && !matteFlag_))
286     SetImageAlpha(image(),OpaqueAlpha,exceptionInfo);
287   ThrowImageException;
288
289   image()->alpha_trait=matteFlag_ ? BlendPixelTrait : UndefinedPixelTrait;
290 }
291
292 bool Magick::Image::alpha(void) const
293 {
294   if (constImage()->alpha_trait == BlendPixelTrait)
295     return(true);
296   else
297     return(false);
298 }
299
300 void Magick::Image::alphaColor(const Color &alphaColor_)
301 {
302   modifyImage();
303
304   if (alphaColor_.isValid())
305     {
306       image()->matte_color=alphaColor_;
307       options()->matteColor(alphaColor_);
308     }
309   else
310     {
311       // Set to default matte color
312       Color tmpColor("#BDBDBD");
313       image()->matte_color=tmpColor;
314       options()->matteColor(tmpColor);
315     }
316 }
317
318 Magick::Color Magick::Image::alphaColor(void) const
319 {
320   return(Color(constImage()->matte_color));
321 }
322
323 void Magick::Image::antiAlias(const bool flag_)
324 {
325   modifyImage();
326   options()->antiAlias(flag_);
327 }
328
329 bool Magick::Image::antiAlias(void) const
330 {
331   return(constOptions()->antiAlias());
332 }
333
334 void Magick::Image::animationDelay(const size_t delay_)
335 {
336   modifyImage();
337   image()->delay=delay_;
338 }
339
340 size_t Magick::Image::animationDelay(void) const
341 {
342   return(constImage()->delay);
343 }
344
345 void Magick::Image::animationIterations(const size_t iterations_)
346 {
347   modifyImage();
348   image()->iterations=iterations_;
349 }
350
351 size_t Magick::Image::animationIterations(void) const
352 {
353   return(constImage()->iterations);
354 }
355
356 void Magick::Image::attenuate(const double attenuate_)
357 {
358   char
359     value[MagickPathExtent];
360
361   modifyImage();
362   FormatLocaleString(value,MagickPathExtent,"%.20g",attenuate_);
363   (void) SetImageArtifact(image(),"attenuate",value);
364 }
365
366 void Magick::Image::backgroundColor(const Color &backgroundColor_)
367 {
368   modifyImage();
369
370   if (backgroundColor_.isValid())
371     image()->background_color=backgroundColor_;
372   else
373     image()->background_color=Color();
374
375   options()->backgroundColor(backgroundColor_);
376 }
377
378 Magick::Color Magick::Image::backgroundColor(void) const
379 {
380   return(constOptions()->backgroundColor());
381 }
382
383 void Magick::Image::backgroundTexture(const std::string &backgroundTexture_)
384 {
385   modifyImage();
386   options()->backgroundTexture(backgroundTexture_);
387 }
388
389 std::string Magick::Image::backgroundTexture(void) const
390 {
391   return(constOptions()->backgroundTexture());
392 }
393
394 size_t Magick::Image::baseColumns(void) const
395 {
396   return(constImage()->magick_columns);
397 }
398
399 std::string Magick::Image::baseFilename(void) const
400 {
401   return(std::string(constImage()->magick_filename));
402 }
403
404 size_t Magick::Image::baseRows(void) const
405 {
406   return(constImage()->magick_rows);
407 }
408
409 void Magick::Image::blackPointCompensation(const bool flag_)
410 {
411   image()->black_point_compensation=(MagickBooleanType) flag_;
412 }
413
414 bool Magick::Image::blackPointCompensation(void) const
415 {
416   return(static_cast<bool>(constImage()->black_point_compensation));
417 }
418
419 void Magick::Image::borderColor(const Color &borderColor_)
420 {
421   modifyImage();
422
423   if (borderColor_.isValid())
424     image()->border_color=borderColor_;
425   else
426     image()->border_color=Color();
427
428   options()->borderColor(borderColor_);
429 }
430
431 Magick::Color Magick::Image::borderColor(void) const
432 {
433   return(constOptions()->borderColor());
434 }
435
436 Magick::Geometry Magick::Image::boundingBox(void) const
437 {
438   RectangleInfo
439     bbox;
440
441   GetPPException;
442   bbox=GetImageBoundingBox(constImage(),exceptionInfo);
443   ThrowImageException;
444   return(Geometry(bbox));
445 }
446
447 void Magick::Image::boxColor(const Color &boxColor_)
448 {
449   modifyImage();
450   options()->boxColor(boxColor_);
451 }
452
453 Magick::Color Magick::Image::boxColor(void) const
454 {
455   return(constOptions()->boxColor());
456 }
457
458 void Magick::Image::channelDepth(const ChannelType channel_,
459   const size_t depth_)
460 {
461   modifyImage();
462   GetPPException;
463   GetAndSetPPChannelMask(channel_);
464   SetImageDepth(image(),depth_,exceptionInfo);
465   RestorePPChannelMask;
466   ThrowImageException;
467 }
468
469 size_t Magick::Image::channelDepth(const ChannelType channel_)
470 {
471   size_t
472     channel_depth;
473
474   GetPPException;
475   GetAndSetPPChannelMask(channel_);
476   channel_depth=GetImageDepth(constImage(),exceptionInfo);
477   RestorePPChannelMask;
478   ThrowImageException;
479   return(channel_depth);
480 }
481
482 size_t Magick::Image::channels() const
483 {
484   return(constImage()->number_channels);
485 }
486
487 void Magick::Image::classType(const ClassType class_)
488 {
489   if (classType() == PseudoClass && class_ == DirectClass)
490     {
491       // Use SyncImage to synchronize the DirectClass pixels with the
492       // color map and then set to DirectClass type.
493       modifyImage();
494       GetPPException;
495       SyncImage(image(),exceptionInfo);
496       ThrowImageException;
497       image()->colormap=(PixelInfo *)RelinquishMagickMemory(image()->colormap);
498       image()->storage_class=static_cast<MagickCore::ClassType>(DirectClass);
499       return;
500     }
501
502   if (classType() == DirectClass && class_ == PseudoClass)
503     {
504       // Quantize to create PseudoClass color map
505       modifyImage();
506       quantizeColors(MaxColormapSize);
507       quantize();
508       image()->storage_class=static_cast<MagickCore::ClassType>(PseudoClass);
509     }
510 }
511
512 Magick::ClassType Magick::Image::classType(void) const
513 {
514   return static_cast<Magick::ClassType>(constImage()->storage_class);
515 }
516
517 void Magick::Image::colorFuzz(const double fuzz_)
518 {
519   modifyImage();
520   image()->fuzz=fuzz_;
521   options()->colorFuzz(fuzz_);
522 }
523
524 double Magick::Image::colorFuzz(void) const
525 {
526   return(constOptions()->colorFuzz());
527 }
528
529 void Magick::Image::colorMapSize(const size_t entries_)
530 {
531   if (entries_ >MaxColormapSize)
532     throwExceptionExplicit(MagickCore::OptionError,
533       "Colormap entries must not exceed MaxColormapSize");
534
535   modifyImage();
536   GetPPException;
537   (void) AcquireImageColormap(image(),entries_,exceptionInfo);
538   ThrowImageException;
539 }
540
541 size_t Magick::Image::colorMapSize(void) const
542 {
543   if (!constImage()->colormap)
544     throwExceptionExplicit(MagickCore::OptionError,
545       "Image does not contain a colormap");
546
547   return(constImage()->colors);
548 }
549
550 void Magick::Image::colorSpace(const ColorspaceType colorSpace_)
551 {
552   if (image()->colorspace == colorSpace_)
553     return;
554
555   modifyImage();
556   GetPPException;
557   TransformImageColorspace(image(),colorSpace_,exceptionInfo);
558   ThrowImageException;
559 }
560
561 Magick::ColorspaceType Magick::Image::colorSpace(void) const
562 {
563   return (constImage()->colorspace);
564 }
565
566 void Magick::Image::colorSpaceType(const ColorspaceType colorSpace_)
567 {
568   modifyImage();
569   GetPPException;
570   SetImageColorspace(image(),colorSpace_,exceptionInfo);
571   ThrowImageException;
572   options()->colorspaceType(colorSpace_);
573 }
574
575 Magick::ColorspaceType Magick::Image::colorSpaceType(void) const
576 {
577   return(constOptions()->colorspaceType());
578 }
579
580 size_t Magick::Image::columns(void) const
581 {
582   return(constImage()->columns);
583 }
584
585 void Magick::Image::comment(const std::string &comment_)
586 {
587   modifyImage();
588   GetPPException;
589   SetImageProperty(image(),"Comment",NULL,exceptionInfo);
590   if (comment_.length() > 0)
591     SetImageProperty(image(),"Comment",comment_.c_str(),exceptionInfo);
592   ThrowImageException;
593 }
594
595 std::string Magick::Image::comment(void) const
596 {
597   const char
598     *value;
599
600   GetPPException;
601   value=GetImageProperty(constImage(),"Comment",exceptionInfo);
602   ThrowImageException;
603
604   if (value)
605     return(std::string(value));
606
607   return(std::string()); // Intentionally no exception
608 }
609
610 void Magick::Image::compose(const CompositeOperator compose_)
611 {
612   image()->compose=compose_;
613 }
614
615 Magick::CompositeOperator Magick::Image::compose(void) const
616 {
617   return(constImage()->compose);
618 }
619
620 void Magick::Image::compressType(const CompressionType compressType_)
621 {
622   modifyImage();
623   image()->compression=compressType_;
624   options()->compressType(compressType_);
625 }
626
627 Magick::CompressionType Magick::Image::compressType(void) const
628 {
629   return(constImage()->compression);
630 }
631
632 void Magick::Image::debug(const bool flag_)
633 {
634   modifyImage();
635   options()->debug(flag_);
636 }
637
638 bool Magick::Image::debug(void) const
639 {
640   return(constOptions()->debug());
641 }
642
643 void Magick::Image::density(const Point &density_)
644 {
645   modifyImage();
646   options()->density(density_);
647   if (density_.isValid())
648     {
649       image()->resolution.x=density_.x();
650       if (density_.y() != 0.0)
651         image()->resolution.y=density_.y();
652       else
653         image()->resolution.y=density_.x();
654     }
655   else
656     {
657       // Reset to default
658       image()->resolution.x=0.0;
659       image()->resolution.y=0.0;
660     }
661 }
662
663 Magick::Point Magick::Image::density(void) const
664 {
665   if (isValid())
666     {
667       ssize_t
668         x_resolution=72,
669         y_resolution=72;
670
671       if (constImage()->resolution.x > 0.0)
672         x_resolution=constImage()->resolution.x;
673
674       if (constImage()->resolution.y > 0.0)
675         y_resolution=constImage()->resolution.y;
676
677       return(Point(x_resolution,y_resolution));
678     }
679
680   return(constOptions()->density());
681 }
682
683 void Magick::Image::depth(const size_t depth_)
684 {
685   size_t
686     depth = depth_;
687
688   if (depth > MAGICKCORE_QUANTUM_DEPTH)
689     depth=MAGICKCORE_QUANTUM_DEPTH;
690
691   modifyImage();
692   image()->depth=depth;
693   options()->depth(depth);
694 }
695
696 size_t Magick::Image::depth(void) const
697 {
698   return(constImage()->depth);
699 }
700
701 std::string Magick::Image::directory(void) const
702 {
703   if (constImage()->directory)
704     return(std::string(constImage()->directory));
705
706   if (!quiet())
707     throwExceptionExplicit(MagickCore::CorruptImageWarning,
708       "Image does not contain a directory");
709
710   return(std::string());
711 }
712
713 void Magick::Image::endian(const Magick::EndianType endian_)
714 {
715   modifyImage();
716   options()->endian(endian_);
717   image()->endian=endian_;
718 }
719
720 Magick::EndianType Magick::Image::endian(void) const
721 {
722   return(constImage()->endian);
723 }
724
725 void Magick::Image::exifProfile(const Magick::Blob &exifProfile_)
726 {
727   modifyImage();
728
729   if (exifProfile_.data() != 0)
730     {
731       StringInfo
732         *exif_profile;
733
734       exif_profile=AcquireStringInfo(exifProfile_.length());
735       SetStringInfoDatum(exif_profile,(unsigned char *) exifProfile_.data());
736       GetPPException;
737       (void) SetImageProfile(image(),"exif",exif_profile,exceptionInfo);
738       exif_profile=DestroyStringInfo(exif_profile);
739       ThrowImageException;
740     }
741 }
742
743 Magick::Blob Magick::Image::exifProfile(void) const
744 {
745   const StringInfo 
746     *exif_profile;
747
748   exif_profile=GetImageProfile(constImage(),"exif");
749   if (exif_profile == (StringInfo *) NULL)
750     return(Blob());
751   return(Blob(GetStringInfoDatum(exif_profile),
752     GetStringInfoLength(exif_profile)));
753
754
755 void Magick::Image::fileName(const std::string &fileName_)
756 {
757   modifyImage();
758
759   fileName_.copy(image()->filename,sizeof(image()->filename)-1);
760   image()->filename[fileName_.length()]=0; // Null terminate
761
762   options()->fileName(fileName_);
763 }
764
765 std::string Magick::Image::fileName(void) const
766 {
767   return(constOptions()->fileName());
768 }
769
770 MagickCore::MagickSizeType Magick::Image::fileSize(void) const
771 {
772   return(GetBlobSize(constImage()));
773 }
774
775 void Magick::Image::fillColor(const Magick::Color &fillColor_)
776 {
777   modifyImage();
778   options()->fillColor(fillColor_);
779 }
780
781 Magick::Color Magick::Image::fillColor(void) const
782 {
783   return(constOptions()->fillColor());
784 }
785
786 void Magick::Image::fillRule(const Magick::FillRule &fillRule_)
787 {
788   modifyImage();
789   options()->fillRule(fillRule_);
790 }
791
792 Magick::FillRule Magick::Image::fillRule(void) const
793 {
794   return constOptions()->fillRule();
795 }
796
797 void Magick::Image::fillPattern(const Image &fillPattern_)
798 {
799   modifyImage();
800   if (fillPattern_.isValid())
801     options()->fillPattern(fillPattern_.constImage());
802   else
803     options()->fillPattern(static_cast<MagickCore::Image*>(NULL));
804 }
805
806 Magick::Image Magick::Image::fillPattern(void) const
807 {
808   // FIXME: This is inordinately innefficient
809   const MagickCore::Image
810     *tmpTexture;
811
812   Image
813     texture;
814
815   tmpTexture=constOptions()->fillPattern();
816
817   if (tmpTexture)
818     {
819       MagickCore::Image
820         *image;
821
822       GetPPException;
823       image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
824       texture.replaceImage(image);
825       ThrowImageException;
826     }
827   return(texture);
828 }
829
830 void Magick::Image::filterType(const Magick::FilterTypes filterType_)
831 {
832   modifyImage();
833   image()->filter=filterType_;
834 }
835
836 Magick::FilterTypes Magick::Image::filterType(void) const
837 {
838   return(constImage()->filter);
839 }
840
841 void Magick::Image::font(const std::string &font_)
842 {
843   modifyImage();
844   options()->font(font_);
845 }
846
847 std::string Magick::Image::font(void) const
848 {
849   return(constOptions()->font());
850 }
851
852 void Magick::Image::fontFamily(const std::string &family_)
853 {
854   modifyImage();
855   options()->fontFamily(family_);
856 }
857
858 std::string Magick::Image::fontFamily(void) const
859 {
860   return(constOptions()->fontFamily());
861 }
862
863 void Magick::Image::fontPointsize(const double pointSize_)
864 {
865   modifyImage();
866   options()->fontPointsize(pointSize_);
867 }
868
869 double Magick::Image::fontPointsize(void) const
870 {
871   return(constOptions()->fontPointsize());
872 }
873
874 void Magick::Image::fontStyle(const StyleType pointSize_)
875 {
876   modifyImage();
877   options()->fontStyle(pointSize_);
878 }
879
880 Magick::StyleType Magick::Image::fontStyle(void) const
881 {
882   return(constOptions()->fontStyle());
883 }
884
885 void Magick::Image::fontWeight(const size_t weight_)
886 {
887   modifyImage();
888   options()->fontWeight(weight_);
889 }
890
891 size_t Magick::Image::fontWeight(void) const
892 {
893   return(constOptions()->fontWeight());
894 }
895
896 std::string Magick::Image::format(void) const
897 {
898   const MagickInfo 
899    *magick_info;
900
901   GetPPException;
902   magick_info=GetMagickInfo(constImage()->magick,exceptionInfo);
903   ThrowImageException;
904
905   if ((magick_info != 0) && (*magick_info->description != '\0'))
906     return(std::string(magick_info->description));
907
908   if (!quiet())
909     throwExceptionExplicit(MagickCore::CorruptImageWarning,
910       "Unrecognized image magick type");
911
912   return(std::string());
913 }
914
915 std::string Magick::Image::formatExpression(const std::string expression)
916 {
917   char
918     *text;
919
920   std::string
921     text_string;
922
923   GetPPException;
924   modifyImage();
925   text=InterpretImageProperties(imageInfo(),image(),expression.c_str(),
926     exceptionInfo);
927   if (text != (char *) NULL)
928     {
929       text_string=std::string(text);
930       text=DestroyString(text);
931     }
932   ThrowImageException;
933   return(text_string);
934 }
935
936 double Magick::Image::gamma(void) const
937 {
938   return(constImage()->gamma);
939 }
940
941 Magick::Geometry Magick::Image::geometry(void) const
942 {
943   if (constImage()->geometry)
944     return Geometry(constImage()->geometry);
945
946   if (!quiet())
947     throwExceptionExplicit(MagickCore::OptionWarning,
948       "Image does not contain a geometry");
949
950   return(Geometry());
951 }
952
953 void Magick::Image::gifDisposeMethod(
954   const MagickCore::DisposeType disposeMethod_)
955 {
956   modifyImage();
957   image()->dispose=disposeMethod_;
958 }
959
960 MagickCore::DisposeType Magick::Image::gifDisposeMethod(void) const
961 {
962   return(constImage()->dispose);
963 }
964
965 bool Magick::Image::hasChannel(const PixelChannel channel) const
966 {
967   if (GetPixelChannelTraits(constImage(),channel) == UndefinedPixelTrait)
968     return(false);
969
970   if (channel == GreenPixelChannel || channel == BluePixelChannel)
971     return (GetPixelChannelOffset(constImage(),channel) == (ssize_t)channel);
972
973   return(true);
974 }
975
976 void Magick::Image::highlightColor(const Color color_)
977 {
978   std::string
979     value;
980
981   value=color_;
982   artifact("highlight-color",value);
983 }
984
985 void Magick::Image::iccColorProfile(const Magick::Blob &colorProfile_)
986 {
987   profile("icc",colorProfile_);
988 }
989
990 Magick::Blob Magick::Image::iccColorProfile(void) const
991 {
992   const StringInfo
993     *color_profile;
994
995   color_profile=GetImageProfile(constImage(),"icc");
996   if (color_profile == (StringInfo *) NULL)
997     return(Blob());
998   return(Blob(GetStringInfoDatum(color_profile),GetStringInfoLength(
999     color_profile)));
1000 }
1001
1002 void Magick::Image::interlaceType(const Magick::InterlaceType interlace_)
1003 {
1004   modifyImage();
1005   image()->interlace=interlace_;
1006   options()->interlaceType(interlace_);
1007 }
1008
1009 Magick::InterlaceType Magick::Image::interlaceType(void) const
1010 {
1011   return(constImage()->interlace);
1012 }
1013
1014 void Magick::Image::interpolate(const PixelInterpolateMethod interpolate_)
1015 {
1016   modifyImage();
1017   image()->interpolate=interpolate_;
1018 }
1019
1020 Magick::PixelInterpolateMethod Magick::Image::interpolate(void) const
1021 {
1022   return constImage()->interpolate;
1023 }
1024
1025 void Magick::Image::iptcProfile(const Magick::Blob &iptcProfile_)
1026 {
1027   modifyImage();
1028   if (iptcProfile_.data() != 0)
1029     {
1030       StringInfo
1031         *iptc_profile;
1032
1033       iptc_profile=AcquireStringInfo(iptcProfile_.length());
1034       SetStringInfoDatum(iptc_profile,(unsigned char *) iptcProfile_.data());
1035       GetPPException;
1036       (void) SetImageProfile(image(),"iptc",iptc_profile,exceptionInfo);
1037       iptc_profile=DestroyStringInfo(iptc_profile);
1038       ThrowImageException;
1039     }
1040 }
1041
1042 Magick::Blob Magick::Image::iptcProfile(void) const
1043 {
1044   const StringInfo
1045     *iptc_profile;
1046
1047   iptc_profile=GetImageProfile(constImage(),"iptc");
1048   if (iptc_profile == (StringInfo *) NULL)
1049     return(Blob());
1050   return(Blob(GetStringInfoDatum(iptc_profile),GetStringInfoLength(
1051     iptc_profile)));
1052 }
1053
1054 bool Magick::Image::isOpaque(void) const
1055 {
1056   MagickBooleanType
1057     result;
1058
1059   GetPPException;
1060   result=IsImageOpaque(constImage(),exceptionInfo);
1061   ThrowImageException;
1062   return(result != MagickFalse ? true : false);
1063 }
1064
1065 void Magick::Image::isValid(const bool isValid_)
1066 {
1067   if (!isValid_)
1068     {
1069       delete _imgRef;
1070       _imgRef=new ImageRef;
1071     }
1072   else if (!isValid())
1073     {
1074       // Construct with single-pixel black image to make
1075       // image valid. This is an obvious hack.
1076       size(Geometry(1,1));
1077       read("xc:black");
1078     }
1079 }
1080
1081 bool Magick::Image::isValid(void) const
1082 {
1083   return rows() && columns();
1084 }
1085
1086 void Magick::Image::label(const std::string &label_)
1087 {
1088   modifyImage();
1089   GetPPException;
1090   (void) SetImageProperty(image(),"Label",NULL,exceptionInfo);
1091   if (label_.length() > 0)
1092     (void) SetImageProperty(image(),"Label",label_.c_str(),exceptionInfo);
1093   ThrowImageException;
1094 }
1095
1096 std::string Magick::Image::label(void) const
1097 {
1098   const char
1099     *value;
1100
1101   GetPPException;
1102   value=GetImageProperty(constImage(),"Label",exceptionInfo);
1103   ThrowImageException;
1104
1105   if (value)
1106     return(std::string(value));
1107
1108   return(std::string());
1109 }
1110
1111 void Magick::Image::lowlightColor(const Color color_)
1112 {
1113   std::string
1114     value;
1115
1116   value=color_;
1117   artifact("lowlight-color",value);
1118 }
1119
1120 void Magick::Image::mask(const Magick::Image &mask_)
1121 {
1122   modifyImage();
1123
1124   GetPPException;
1125   if (mask_.isValid())
1126     SetImageMask(image(),ReadPixelMask,mask_.constImage(),exceptionInfo);
1127   else
1128     SetImageMask(image(),ReadPixelMask,(MagickCore::Image *) NULL,
1129       exceptionInfo);
1130   ThrowImageException;
1131 }
1132
1133 Magick::Image Magick::Image::mask(void) const
1134 {
1135   MagickCore::Image
1136     *image;
1137
1138   GetPPException;
1139   image=GetImageMask(constImage(),exceptionInfo);
1140   ThrowImageException;
1141
1142   if (image == (MagickCore::Image *) NULL)
1143     return(Magick::Image());
1144   else
1145     return(Magick::Image(image));
1146 }
1147
1148 void Magick::Image::magick(const std::string &magick_)
1149 {
1150   size_t
1151     length;
1152
1153   modifyImage();
1154
1155   length=sizeof(image()->magick)-1;
1156   if (magick_.length() < length)
1157     length=magick_.length();
1158
1159   if (!magick_.empty())
1160     magick_.copy(image()->magick,length);
1161   image()->magick[length]=0;
1162
1163   options()->magick(magick_);
1164 }
1165
1166 std::string Magick::Image::magick(void) const
1167 {
1168   if (*(constImage()->magick) != '\0')
1169     return(std::string(constImage()->magick));
1170
1171   return(constOptions()->magick());
1172 }
1173
1174 double Magick::Image::meanErrorPerPixel(void) const
1175 {
1176   return(constImage()->error.mean_error_per_pixel);
1177 }
1178
1179 void Magick::Image::modulusDepth(const size_t depth_)
1180 {
1181   modifyImage();
1182   GetPPException;
1183   SetImageDepth(image(),depth_,exceptionInfo);
1184   ThrowImageException;
1185   options()->depth(depth_);
1186 }
1187
1188 size_t Magick::Image::modulusDepth(void) const
1189 {
1190   size_t 
1191     depth;
1192
1193   GetPPException;
1194   depth=GetImageDepth(constImage(),exceptionInfo);
1195   ThrowImageException;
1196   return(depth);
1197 }
1198
1199 void Magick::Image::monochrome(const bool monochromeFlag_)
1200 {
1201   modifyImage();
1202   options()->monochrome(monochromeFlag_);
1203 }
1204
1205 bool Magick::Image::monochrome(void) const
1206 {
1207   return(constOptions()->monochrome());
1208 }
1209
1210 Magick::Geometry Magick::Image::montageGeometry(void) const
1211 {
1212   if (constImage()->montage)
1213     return Magick::Geometry(constImage()->montage);
1214
1215   if (!quiet())
1216     throwExceptionExplicit(MagickCore::CorruptImageWarning,
1217     "Image does not contain a montage");
1218
1219   return(Magick::Geometry());
1220 }
1221
1222 double Magick::Image::normalizedMaxError(void) const
1223 {
1224   return(constImage()->error.normalized_maximum_error);
1225 }
1226
1227 double Magick::Image::normalizedMeanError(void) const
1228 {
1229   return(constImage()->error.normalized_mean_error);
1230 }
1231
1232 void Magick::Image::orientation(const Magick::OrientationType orientation_)
1233 {
1234   modifyImage();
1235   image()->orientation=orientation_;
1236 }
1237
1238 Magick::OrientationType Magick::Image::orientation(void) const
1239 {
1240   return(constImage()->orientation);
1241 }
1242
1243 void Magick::Image::page(const Magick::Geometry &pageSize_)
1244 {
1245   modifyImage();
1246   options()->page(pageSize_);
1247   image()->page=pageSize_;
1248 }
1249
1250 Magick::Geometry Magick::Image::page(void) const
1251 {
1252   return(Geometry(constImage()->page.width,constImage()->page.height,
1253     constImage()->page.x,constImage()->page.y));
1254 }
1255
1256 void Magick::Image::quality(const size_t quality_)
1257 {
1258   modifyImage();
1259   image()->quality=quality_;
1260   options()->quality(quality_);
1261 }
1262
1263 size_t Magick::Image::quality(void) const
1264 {
1265   return(constImage()->quality);
1266 }
1267
1268 void Magick::Image::quantizeColors(const size_t colors_)
1269 {
1270   modifyImage();
1271   options()->quantizeColors(colors_);
1272 }
1273
1274 size_t Magick::Image::quantizeColors(void) const
1275 {
1276   return(constOptions()->quantizeColors());
1277 }
1278
1279 void Magick::Image::quantizeColorSpace(
1280   const Magick::ColorspaceType colorSpace_)
1281 {
1282   modifyImage();
1283   options()->quantizeColorSpace(colorSpace_);
1284 }
1285
1286 Magick::ColorspaceType Magick::Image::quantizeColorSpace(void) const
1287 {
1288   return(constOptions()->quantizeColorSpace());
1289 }
1290
1291 void Magick::Image::quantizeDither(const bool ditherFlag_)
1292 {
1293   modifyImage();
1294   options()->quantizeDither(ditherFlag_);
1295 }
1296
1297 bool Magick::Image::quantizeDither(void) const
1298 {
1299   return(constOptions()->quantizeDither());
1300 }
1301
1302 void Magick::Image::quantizeDitherMethod(const DitherMethod ditherMethod_)
1303 {
1304   modifyImage();
1305   options()->quantizeDitherMethod(ditherMethod_);
1306 }
1307
1308 MagickCore::DitherMethod Magick::Image::quantizeDitherMethod(void) const
1309 {
1310   return(constOptions()->quantizeDitherMethod());
1311 }
1312
1313 void Magick::Image::quantizeTreeDepth(const size_t treeDepth_)
1314 {
1315   modifyImage();
1316   options()->quantizeTreeDepth(treeDepth_);
1317 }
1318
1319 size_t Magick::Image::quantizeTreeDepth() const
1320 {
1321   return(constOptions()->quantizeTreeDepth());
1322 }
1323
1324 void Magick::Image::quiet(const bool quiet_)
1325 {
1326   modifyImage();
1327   options()->quiet(quiet_);
1328 }
1329
1330 bool Magick::Image::quiet(void) const
1331 {
1332   return(constOptions()->quiet());
1333 }
1334
1335 void Magick::Image::renderingIntent(
1336   const Magick::RenderingIntent renderingIntent_)
1337 {
1338   modifyImage();
1339   image()->rendering_intent=renderingIntent_;
1340 }
1341
1342 Magick::RenderingIntent Magick::Image::renderingIntent(void) const
1343 {
1344   return(static_cast<Magick::RenderingIntent>(constImage()->rendering_intent));
1345 }
1346
1347 void Magick::Image::resolutionUnits(
1348   const Magick::ResolutionType resolutionUnits_)
1349 {
1350   modifyImage();
1351   image()->units=resolutionUnits_;
1352   options()->resolutionUnits(resolutionUnits_);
1353 }
1354
1355 Magick::ResolutionType Magick::Image::resolutionUnits(void) const
1356 {
1357   return(static_cast<Magick::ResolutionType>(constImage()->units));
1358 }
1359
1360 size_t Magick::Image::rows(void) const
1361 {
1362   return(constImage()->rows);
1363 }
1364
1365 void Magick::Image::scene(const size_t scene_)
1366 {
1367   modifyImage();
1368   image()->scene=scene_;
1369 }
1370
1371 size_t Magick::Image::scene(void) const
1372 {
1373   return(constImage()->scene);
1374 }
1375
1376 void Magick::Image::size(const Geometry &geometry_)
1377 {
1378   modifyImage();
1379   options()->size(geometry_);
1380   image()->rows=geometry_.height();
1381   image()->columns=geometry_.width();
1382 }
1383
1384 Magick::Geometry Magick::Image::size(void) const
1385 {
1386   return(Magick::Geometry(constImage()->columns,constImage()->rows));
1387 }
1388
1389 void Magick::Image::strokeAntiAlias(const bool flag_)
1390 {
1391   modifyImage();
1392   options()->strokeAntiAlias(flag_);
1393 }
1394
1395 bool Magick::Image::strokeAntiAlias(void) const
1396 {
1397   return(constOptions()->strokeAntiAlias());
1398 }
1399
1400 void Magick::Image::strokeColor(const Magick::Color &strokeColor_)
1401 {
1402   std::string
1403     value;
1404
1405   modifyImage();
1406   options()->strokeColor(strokeColor_);
1407   value=strokeColor_;
1408   artifact("stroke",value);
1409 }
1410
1411 Magick::Color Magick::Image::strokeColor(void) const
1412 {
1413   return(constOptions()->strokeColor());
1414 }
1415
1416 void Magick::Image::strokeDashArray(const double *strokeDashArray_)
1417 {
1418   modifyImage();
1419   options()->strokeDashArray(strokeDashArray_);
1420 }
1421
1422 const double* Magick::Image::strokeDashArray(void) const
1423 {
1424   return(constOptions()->strokeDashArray());
1425 }
1426
1427 void Magick::Image::strokeDashOffset(const double strokeDashOffset_)
1428 {
1429   modifyImage();
1430   options()->strokeDashOffset(strokeDashOffset_);
1431 }
1432
1433 double Magick::Image::strokeDashOffset(void) const
1434 {
1435   return(constOptions()->strokeDashOffset());
1436 }
1437
1438 void Magick::Image::strokeLineCap(const Magick::LineCap lineCap_)
1439 {
1440   modifyImage();
1441   options()->strokeLineCap(lineCap_);
1442 }
1443
1444 Magick::LineCap Magick::Image::strokeLineCap(void) const
1445 {
1446   return(constOptions()->strokeLineCap());
1447 }
1448
1449 void Magick::Image::strokeLineJoin(const Magick::LineJoin lineJoin_)
1450 {
1451   modifyImage();
1452   options()->strokeLineJoin(lineJoin_);
1453 }
1454
1455 Magick::LineJoin Magick::Image::strokeLineJoin(void) const
1456 {
1457   return(constOptions()->strokeLineJoin());
1458 }
1459
1460 void Magick::Image::strokeMiterLimit(const size_t strokeMiterLimit_)
1461 {
1462   modifyImage();
1463   options()->strokeMiterLimit(strokeMiterLimit_);
1464 }
1465
1466 size_t Magick::Image::strokeMiterLimit(void) const
1467 {
1468   return(constOptions()->strokeMiterLimit());
1469 }
1470
1471 void Magick::Image::strokePattern(const Image &strokePattern_)
1472 {
1473   modifyImage();
1474   if(strokePattern_.isValid())
1475     options()->strokePattern(strokePattern_.constImage());
1476   else
1477     options()->strokePattern(static_cast<MagickCore::Image*>(NULL));
1478 }
1479
1480 Magick::Image Magick::Image::strokePattern(void) const
1481 {
1482   // FIXME: This is inordinately innefficient
1483   const MagickCore::Image 
1484     *tmpTexture;
1485
1486   Image
1487     texture;
1488
1489   tmpTexture=constOptions()->strokePattern();
1490
1491   if (tmpTexture)
1492     {
1493       MagickCore::Image
1494         *image;
1495
1496       GetPPException;
1497       image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
1498       texture.replaceImage(image);
1499       ThrowImageException;
1500     }
1501   return(texture);
1502 }
1503
1504 void Magick::Image::strokeWidth(const double strokeWidth_)
1505 {
1506   char
1507     value[MagickPathExtent];
1508
1509   modifyImage();
1510   options()->strokeWidth(strokeWidth_);
1511   FormatLocaleString(value,MagickPathExtent,"%.20g",strokeWidth_);
1512   (void) SetImageArtifact(image(),"strokewidth",value);
1513 }
1514
1515 double Magick::Image::strokeWidth(void) const
1516 {
1517   return(constOptions()->strokeWidth());
1518 }
1519
1520 void Magick::Image::subImage(const size_t subImage_)
1521 {
1522   modifyImage();
1523   options()->subImage(subImage_);
1524 }
1525
1526 size_t Magick::Image::subImage(void) const
1527 {
1528   return(constOptions()->subImage());
1529 }
1530
1531 void Magick::Image::subRange(const size_t subRange_)
1532 {
1533   modifyImage();
1534   options()->subRange(subRange_);
1535 }
1536
1537 size_t Magick::Image::subRange(void) const
1538 {
1539   return(constOptions()->subRange());
1540 }
1541
1542 void Magick::Image::textDirection(DirectionType direction_)
1543 {
1544   modifyImage();
1545   options()->textDirection(direction_);
1546 }
1547
1548 Magick::DirectionType Magick::Image::textDirection(void) const
1549 {
1550   return(constOptions()->textDirection());
1551 }
1552
1553 void Magick::Image::textEncoding(const std::string &encoding_)
1554 {
1555   modifyImage();
1556   options()->textEncoding(encoding_);
1557 }
1558
1559 std::string Magick::Image::textEncoding(void) const
1560 {
1561   return(constOptions()->textEncoding());
1562 }
1563
1564 void Magick::Image::textGravity(GravityType gravity_)
1565 {
1566   modifyImage();
1567   options()->textGravity(gravity_);
1568 }
1569
1570 Magick::GravityType Magick::Image::textGravity(void) const
1571 {
1572   return(constOptions()->textGravity());
1573 }
1574
1575 void Magick::Image::textInterlineSpacing(double spacing_)
1576 {
1577   modifyImage();
1578   options()->textInterlineSpacing(spacing_);
1579 }
1580
1581 double Magick::Image::textInterlineSpacing(void) const
1582 {
1583   return(constOptions()->textInterlineSpacing());
1584 }
1585
1586 void Magick::Image::textInterwordSpacing(double spacing_)
1587 {
1588   modifyImage();
1589   options()->textInterwordSpacing(spacing_);
1590 }
1591
1592 double Magick::Image::textInterwordSpacing(void) const
1593 {
1594   return(constOptions()->textInterwordSpacing());
1595 }
1596
1597 void Magick::Image::textKerning(double kerning_)
1598 {
1599   modifyImage();
1600   options()->textKerning(kerning_);
1601 }
1602
1603 double Magick::Image::textKerning(void) const
1604 {
1605   return(constOptions()->textKerning());
1606 }
1607
1608 void Magick::Image::textUnderColor(const Color &underColor_)
1609 {
1610   modifyImage();
1611   options()->textUnderColor(underColor_);
1612 }
1613
1614 Magick::Color Magick::Image::textUnderColor(void) const
1615 {
1616   return(constOptions()->textUnderColor());
1617 }
1618
1619 size_t Magick::Image::totalColors(void) const
1620 {
1621   size_t
1622     colors;
1623
1624   GetPPException;
1625   colors=GetNumberColors(constImage(),(FILE *) NULL,exceptionInfo);
1626   ThrowImageException;
1627   return colors;
1628 }
1629
1630 void Magick::Image::transformRotation(const double angle_)
1631 {
1632   modifyImage();
1633   options()->transformRotation(angle_);
1634 }
1635
1636 void Magick::Image::transformSkewX(const double skewx_)
1637 {
1638   modifyImage();
1639   options()->transformSkewX(skewx_);
1640 }
1641
1642 void Magick::Image::transformSkewY(const double skewy_)
1643 {
1644   modifyImage();
1645   options()->transformSkewY(skewy_);
1646 }
1647
1648 Magick::ImageType Magick::Image::type(void) const
1649 {
1650   if (constOptions()->type() != UndefinedType)
1651     return(constOptions()->type());
1652   return(GetImageType(constImage()));
1653 }
1654
1655 void Magick::Image::type(const Magick::ImageType type_)
1656 {
1657   modifyImage();
1658   options()->type(type_);
1659   GetPPException;
1660   SetImageType(image(),type_,exceptionInfo);
1661   ThrowImageException;
1662 }
1663
1664 void Magick::Image::verbose(const bool verboseFlag_)
1665 {
1666   modifyImage();
1667   options()->verbose(verboseFlag_);
1668 }
1669
1670 bool Magick::Image::verbose(void) const
1671 {
1672   return(constOptions()->verbose());
1673 }
1674
1675 void Magick::Image::view(const std::string &view_)
1676 {
1677   modifyImage();
1678   options()->view(view_);
1679 }
1680
1681 std::string Magick::Image::view(void) const
1682 {
1683   return(constOptions()->view());
1684 }
1685
1686 void Magick::Image::virtualPixelMethod(
1687   const VirtualPixelMethod virtualPixelMethod_)
1688 {
1689   modifyImage();
1690   GetPPException;
1691   SetImageVirtualPixelMethod(image(),virtualPixelMethod_,exceptionInfo);
1692   ThrowImageException;
1693 }
1694
1695 Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod(void) const
1696 {
1697   return(GetImageVirtualPixelMethod(constImage()));
1698 }
1699
1700 void Magick::Image::x11Display(const std::string &display_)
1701 {
1702   modifyImage();
1703   options()->x11Display(display_);
1704 }
1705
1706 std::string Magick::Image::x11Display(void) const
1707 {
1708   return(constOptions()->x11Display());
1709 }
1710
1711 double Magick::Image::xResolution(void) const
1712 {
1713   return(constImage()->resolution.x);
1714 }
1715
1716 double Magick::Image::yResolution(void) const
1717 {
1718   return(constImage()->resolution.y);
1719 }
1720
1721 void Magick::Image::adaptiveBlur(const double radius_,const double sigma_)
1722 {
1723   MagickCore::Image
1724     *newImage;
1725
1726   GetPPException;
1727   newImage=AdaptiveBlurImage(constImage(),radius_,sigma_,exceptionInfo);
1728   replaceImage(newImage);
1729   ThrowImageException;
1730 }
1731
1732 void Magick::Image::adaptiveResize(const Geometry &geometry_)
1733 {
1734   MagickCore::Image
1735     *newImage;
1736
1737   size_t
1738     height=rows(),
1739     width=columns();
1740
1741   ssize_t
1742     x=0,
1743     y=0;
1744
1745   ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
1746     &height);
1747
1748   GetPPException;
1749   newImage=AdaptiveResizeImage(constImage(),width,height,exceptionInfo);
1750   replaceImage(newImage);
1751   ThrowImageException;
1752 }
1753
1754 void Magick::Image::adaptiveSharpen(const double radius_,const double sigma_)
1755 {
1756   MagickCore::Image
1757     *newImage;
1758
1759   GetPPException;
1760   newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1761   replaceImage(newImage);
1762   ThrowImageException;
1763 }
1764
1765 void Magick::Image::adaptiveSharpenChannel(const ChannelType channel_,
1766   const double radius_,const double sigma_ )
1767 {
1768   MagickCore::Image
1769     *newImage;
1770
1771   GetPPException;
1772   GetAndSetPPChannelMask(channel_);
1773   newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1774   RestorePPChannelMask;
1775   replaceImage(newImage);
1776   ThrowImageException;
1777 }
1778
1779 void Magick::Image::adaptiveThreshold(const size_t width_,const size_t height_,
1780    const double bias_)
1781 {
1782
1783   MagickCore::Image
1784     *newImage;
1785
1786   GetPPException;
1787   newImage=AdaptiveThresholdImage(constImage(),width_,height_,bias_,
1788     exceptionInfo);
1789   replaceImage(newImage);
1790   ThrowImageException;
1791 }
1792
1793 void Magick::Image::addNoise(const NoiseType noiseType_)
1794 {
1795   MagickCore::Image
1796     *newImage;
1797
1798   GetPPException;
1799   newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1800   replaceImage(newImage);
1801   ThrowImageException;
1802 }
1803
1804 void Magick::Image::addNoiseChannel(const ChannelType channel_,
1805   const NoiseType noiseType_)
1806 {
1807   MagickCore::Image
1808     *newImage;
1809
1810   GetPPException;
1811   GetAndSetPPChannelMask(channel_);
1812   newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
1813   RestorePPChannelMask;
1814   replaceImage(newImage);
1815   ThrowImageException;
1816 }
1817
1818 void Magick::Image::affineTransform(const DrawableAffine &affine_)
1819 {
1820   AffineMatrix
1821     _affine;
1822
1823   MagickCore::Image
1824     *newImage;
1825
1826   _affine.sx=affine_.sx();
1827   _affine.sy=affine_.sy();
1828   _affine.rx=affine_.rx();
1829   _affine.ry=affine_.ry();
1830   _affine.tx=affine_.tx();
1831   _affine.ty=affine_.ty();
1832
1833   GetPPException;
1834   newImage=AffineTransformImage(constImage(),&_affine,exceptionInfo);
1835   replaceImage(newImage);
1836   ThrowImageException;
1837 }
1838
1839 void Magick::Image::alpha(const unsigned int alpha_)
1840 {
1841   modifyImage();
1842   GetPPException;
1843   SetImageAlpha(image(),alpha_,exceptionInfo);
1844   ThrowImageException;
1845 }
1846
1847 void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
1848 {
1849   modifyImage();
1850   GetPPException;
1851   SetImageAlphaChannel(image(),alphaOption_,exceptionInfo);
1852   ThrowImageException;
1853 }
1854
1855 void Magick::Image::annotate(const std::string &text_,
1856   const Geometry &location_)
1857 {
1858   annotate(text_,location_,NorthWestGravity,0.0);
1859 }
1860
1861 void Magick::Image::annotate(const std::string &text_,
1862   const Geometry &boundingArea_,const GravityType gravity_)
1863 {
1864   annotate(text_,boundingArea_,gravity_,0.0);
1865 }
1866
1867 void Magick::Image::annotate(const std::string &text_,
1868   const Geometry &boundingArea_,const GravityType gravity_,
1869   const double degrees_)
1870 {
1871   AffineMatrix
1872     oaffine;
1873
1874   char
1875     boundingArea[MagickPathExtent];
1876
1877   DrawInfo
1878     *drawInfo;
1879
1880   modifyImage();
1881
1882   drawInfo=options()->drawInfo();
1883   drawInfo->text=const_cast<char *>(text_.c_str());
1884   drawInfo->geometry=0;
1885
1886   if (boundingArea_.isValid())
1887     {
1888       if (boundingArea_.width() == 0 || boundingArea_.height() == 0)
1889         {
1890           FormatLocaleString(boundingArea,MagickPathExtent,"%+.20g%+.20g",
1891             (double) boundingArea_.xOff(),(double) boundingArea_.yOff());
1892         }
1893       else
1894         {
1895           (void) CopyMagickString(boundingArea,
1896             std::string(boundingArea_).c_str(), MagickPathExtent);
1897         }
1898       drawInfo->geometry=boundingArea;
1899     }
1900
1901   drawInfo->gravity=gravity_;
1902
1903   oaffine=drawInfo->affine;
1904   if (degrees_ != 0.0)
1905     {
1906        AffineMatrix
1907          affine,
1908          current;
1909
1910        affine.sx=1.0;
1911        affine.rx=0.0;
1912        affine.ry=0.0;
1913        affine.sy=1.0;
1914        affine.tx=0.0;
1915        affine.ty=0.0;
1916
1917        current=drawInfo->affine;
1918        affine.sx=cos(DegreesToRadians(fmod(degrees_,360.0)));
1919        affine.rx=sin(DegreesToRadians(fmod(degrees_,360.0)));
1920        affine.ry=(-sin(DegreesToRadians(fmod(degrees_,360.0))));
1921        affine.sy=cos(DegreesToRadians(fmod(degrees_,360.0)));
1922
1923        drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
1924        drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
1925        drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
1926        drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
1927        drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty
1928          +current.tx;
1929     }
1930
1931   GetPPException;
1932   AnnotateImage(image(),drawInfo,exceptionInfo);
1933
1934   // Restore original values
1935   drawInfo->affine=oaffine;
1936   drawInfo->text=0;
1937   drawInfo->geometry=0;
1938
1939   ThrowImageException;
1940 }
1941
1942 void Magick::Image::annotate(const std::string &text_,
1943   const GravityType gravity_)
1944 {
1945   DrawInfo
1946     *drawInfo;
1947
1948   modifyImage();
1949
1950   drawInfo=options()->drawInfo();
1951   drawInfo->text=const_cast<char *>(text_.c_str());
1952   drawInfo->gravity=gravity_;
1953
1954   GetPPException;
1955   AnnotateImage(image(),drawInfo,exceptionInfo);
1956
1957   drawInfo->gravity=NorthWestGravity;
1958   drawInfo->text=0;
1959
1960   ThrowImageException;
1961 }
1962
1963 void Magick::Image::artifact(const std::string &name_,const std::string &value_)
1964 {
1965   modifyImage();
1966   (void) SetImageArtifact(image(),name_.c_str(),value_.c_str());
1967 }
1968
1969 std::string Magick::Image::artifact(const std::string &name_) const
1970 {
1971   const char
1972     *value;
1973
1974   value=GetImageArtifact(constImage(),name_.c_str());
1975   if (value)
1976     return(std::string(value));
1977   return(std::string());
1978 }
1979
1980 void Magick::Image::attribute(const std::string name_,const std::string value_)
1981 {
1982   modifyImage();
1983   GetPPException;
1984   SetImageProperty(image(),name_.c_str(),value_.c_str(),exceptionInfo);
1985   ThrowImageException;
1986 }
1987
1988 std::string Magick::Image::attribute(const std::string name_) const
1989 {
1990   const char
1991     *value;
1992
1993   GetPPException;
1994   value=GetImageProperty(constImage(),name_.c_str(),exceptionInfo);
1995   ThrowImageException;
1996
1997   if (value)
1998     return(std::string(value));
1999
2000   return(std::string()); // Intentionally no exception
2001 }
2002
2003 void Magick::Image::autoGamma(void)
2004 {
2005   modifyImage();
2006   GetPPException;
2007   (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2008   (void) AutoGammaImage(image(),exceptionInfo);
2009   ThrowImageException;
2010 }
2011
2012 void Magick::Image::autoGammaChannel(const ChannelType channel_)
2013 {
2014   modifyImage();
2015   GetPPException;
2016   GetAndSetPPChannelMask(channel_);
2017   (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2018   (void) AutoGammaImage(image(),exceptionInfo);
2019   RestorePPChannelMask;
2020   ThrowImageException;
2021 }
2022
2023 void Magick::Image::autoLevel(void)
2024 {
2025   modifyImage();
2026   GetPPException;
2027   (void) AutoLevelImage(image(),exceptionInfo);
2028   ThrowImageException;
2029 }
2030
2031 void Magick::Image::autoLevelChannel(const ChannelType channel_)
2032 {
2033   modifyImage();
2034   GetPPException;
2035   GetAndSetPPChannelMask(channel_);
2036   (void) AutoLevelImage(image(),exceptionInfo);
2037   RestorePPChannelMask;
2038   ThrowImageException;
2039 }
2040
2041 void Magick::Image::autoOrient(void)
2042 {
2043   MagickCore::Image
2044     *newImage;
2045
2046   if (image()->orientation == UndefinedOrientation ||
2047       image()->orientation == TopLeftOrientation)
2048     return;
2049
2050   GetPPException;
2051   newImage=AutoOrientImage(constImage(),image()->orientation,exceptionInfo);
2052   replaceImage(newImage);
2053   ThrowImageException;
2054 }
2055
2056 void Magick::Image::blackThreshold(const std::string &threshold_)
2057 {
2058   modifyImage();
2059   GetPPException;
2060   BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2061   ThrowImageException;
2062 }
2063
2064 void Magick::Image::blackThresholdChannel(const ChannelType channel_,
2065   const std::string &threshold_)
2066 {
2067   modifyImage();
2068   GetPPException;
2069   GetAndSetPPChannelMask(channel_);
2070   BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2071   RestorePPChannelMask;
2072   ThrowImageException;
2073 }
2074
2075 void Magick::Image::blueShift(const double factor_)
2076 {
2077   MagickCore::Image
2078     *newImage;
2079
2080   GetPPException;
2081   newImage=BlueShiftImage(constImage(),factor_,exceptionInfo);
2082   replaceImage(newImage);
2083   ThrowImageException;
2084 }
2085
2086 void Magick::Image::blur(const double radius_,const double sigma_)
2087 {
2088   MagickCore::Image
2089     *newImage;
2090
2091   GetPPException;
2092   newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2093   replaceImage(newImage);
2094   ThrowImageException;
2095 }
2096
2097 void Magick::Image::blurChannel(const ChannelType channel_,
2098   const double radius_,const double sigma_)
2099 {
2100   MagickCore::Image
2101     *newImage;
2102
2103   GetPPException;
2104   GetAndSetPPChannelMask(channel_);
2105   newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2106   RestorePPChannelMask;
2107   replaceImage(newImage);
2108   ThrowImageException;
2109 }
2110
2111 void Magick::Image::border(const Geometry &geometry_)
2112 {
2113   MagickCore::Image
2114     *newImage;
2115
2116   RectangleInfo
2117     borderInfo=geometry_;
2118
2119   GetPPException;
2120   newImage=BorderImage(constImage(),&borderInfo,image()->compose,
2121     exceptionInfo);
2122   replaceImage(newImage);
2123   ThrowImageException;
2124 }
2125
2126 void Magick::Image::brightnessContrast(const double brightness_,
2127   const double contrast_)
2128 {
2129   modifyImage();
2130   GetPPException;
2131   BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2132   ThrowImageException;
2133 }
2134
2135 void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
2136   const double brightness_,const double contrast_)
2137 {
2138   modifyImage();
2139   GetPPException;
2140   GetAndSetPPChannelMask(channel_);
2141   BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2142   RestorePPChannelMask;
2143   ThrowImageException;
2144 }
2145
2146 void Magick::Image::cannyEdge(const double radius_,const double sigma_,
2147   const double lowerPercent_,const double upperPercent_)
2148 {
2149   MagickCore::Image
2150     *newImage;
2151
2152   modifyImage();
2153   GetPPException;
2154   newImage=CannyEdgeImage(constImage(),radius_,sigma_,lowerPercent_,
2155     upperPercent_,exceptionInfo);
2156   replaceImage(newImage);
2157   ThrowImageException;
2158 }
2159
2160 void Magick::Image::cdl(const std::string &cdl_)
2161 {
2162   modifyImage();
2163   GetPPException;
2164   (void) ColorDecisionListImage(image(),cdl_.c_str(),exceptionInfo);
2165   ThrowImageException;
2166 }
2167
2168 void Magick::Image::channel(const ChannelType channel_)
2169 {
2170   MagickCore::Image
2171     *newImage;
2172
2173   GetPPException;
2174   newImage=SeparateImage(image(),channel_,exceptionInfo);
2175   replaceImage(newImage);
2176   ThrowImageException;
2177 }
2178
2179 void Magick::Image::charcoal(const double radius_,const double sigma_)
2180 {
2181   MagickCore::Image
2182     *newImage;
2183
2184   GetPPException;
2185   newImage=CharcoalImage(image(),radius_,sigma_,exceptionInfo);
2186   replaceImage(newImage);
2187   ThrowImageException;
2188 }
2189
2190 void Magick::Image::chop(const Geometry &geometry_)
2191 {
2192   MagickCore::Image
2193     *newImage;
2194
2195   RectangleInfo
2196     chopInfo=geometry_;
2197
2198   GetPPException;
2199   newImage=ChopImage(image(),&chopInfo,exceptionInfo);
2200   replaceImage(newImage);
2201   ThrowImageException;
2202 }
2203
2204 void Magick::Image::chromaBluePrimary(const double x_,const double y_)
2205 {
2206   modifyImage();
2207   image()->chromaticity.blue_primary.x=x_;
2208   image()->chromaticity.blue_primary.y=y_;
2209 }
2210
2211 void Magick::Image::chromaBluePrimary(double *x_,double *y_) const
2212 {
2213   *x_=constImage()->chromaticity.blue_primary.x;
2214   *y_=constImage()->chromaticity.blue_primary.y;
2215 }
2216
2217 void Magick::Image::chromaGreenPrimary(const double x_,const double y_)
2218 {
2219   modifyImage();
2220   image()->chromaticity.green_primary.x=x_;
2221   image()->chromaticity.green_primary.y=y_;
2222 }
2223
2224 void Magick::Image::chromaGreenPrimary(double *x_,double *y_) const
2225 {
2226   *x_=constImage()->chromaticity.green_primary.x;
2227   *y_=constImage()->chromaticity.green_primary.y;
2228 }
2229
2230 void Magick::Image::chromaRedPrimary(const double x_,const double y_)
2231 {
2232   modifyImage();
2233   image()->chromaticity.red_primary.x=x_;
2234   image()->chromaticity.red_primary.y=y_;
2235 }
2236
2237 void Magick::Image::chromaRedPrimary(double *x_,double *y_) const
2238 {
2239   *x_=constImage()->chromaticity.red_primary.x;
2240   *y_=constImage()->chromaticity.red_primary.y;
2241 }
2242
2243 void Magick::Image::chromaWhitePoint(const double x_,const double y_)
2244 {
2245   modifyImage();
2246   image()->chromaticity.white_point.x=x_;
2247   image()->chromaticity.white_point.y=y_;
2248 }
2249
2250 void Magick::Image::chromaWhitePoint(double *x_,double *y_) const
2251 {
2252   *x_=constImage()->chromaticity.white_point.x;
2253   *y_=constImage()->chromaticity.white_point.y;
2254 }
2255
2256 void Magick::Image::clamp(void)
2257 {
2258   modifyImage();
2259   GetPPException;
2260   ClampImage(image(),exceptionInfo);
2261   ThrowImageException;
2262 }
2263
2264 void Magick::Image::clampChannel(const ChannelType channel_)
2265 {
2266   modifyImage();
2267   GetPPException;
2268   GetAndSetPPChannelMask(channel_);
2269   ClampImage(image(),exceptionInfo);
2270   RestorePPChannelMask;
2271   ThrowImageException;
2272 }
2273
2274 void Magick::Image::clip(void)
2275 {
2276   modifyImage();
2277   GetPPException;
2278   ClipImage(image(),exceptionInfo);
2279   ThrowImageException;
2280 }
2281
2282 void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
2283 {
2284   modifyImage();
2285   GetPPException;
2286   ClipImagePath(image(),pathname_.c_str(),(MagickBooleanType) inside_,
2287     exceptionInfo);
2288   ThrowImageException;
2289 }
2290
2291 void Magick::Image::clut(const Image &clutImage_,
2292   const PixelInterpolateMethod method)
2293 {
2294   modifyImage();
2295   GetPPException;
2296   ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2297   ThrowImageException;
2298 }
2299
2300 void Magick::Image::clutChannel(const ChannelType channel_,
2301   const Image &clutImage_,const PixelInterpolateMethod method)
2302 {
2303   modifyImage();
2304   GetPPException;
2305   GetAndSetPPChannelMask(channel_);
2306   ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2307   RestorePPChannelMask;
2308   ThrowImageException;
2309 }
2310
2311 void Magick::Image::colorize(const unsigned int alpha_,const Color &penColor_)
2312 {
2313   colorize(alpha_,alpha_,alpha_,penColor_);
2314 }
2315
2316 void Magick::Image::colorize(const unsigned int alphaRed_,
2317   const unsigned int alphaGreen_,const unsigned int alphaBlue_,
2318   const Color &penColor_)
2319 {
2320   char
2321     blend[MagickPathExtent];
2322
2323   MagickCore::Image
2324     *newImage;
2325
2326   PixelInfo
2327     target;
2328
2329   if (!penColor_.isValid())
2330     throwExceptionExplicit(MagickCore::OptionError,
2331       "Pen color argument is invalid");
2332
2333   FormatLocaleString(blend,MagickPathExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
2334     alphaBlue_);
2335
2336   target=static_cast<PixelInfo>(penColor_);
2337   GetPPException;
2338   newImage=ColorizeImage(image(),blend,&target,exceptionInfo);
2339   replaceImage(newImage);
2340   ThrowImageException;
2341 }
2342
2343 void Magick::Image::colorMap(const size_t index_,const Color &color_)
2344 {
2345   MagickCore::Image
2346     *imageptr;
2347
2348   imageptr=image();
2349
2350   if (index_ > (MaxColormapSize-1))
2351     throwExceptionExplicit(MagickCore::OptionError,
2352       "Colormap index must be less than MaxColormapSize");
2353
2354   if (!color_.isValid())
2355     throwExceptionExplicit(MagickCore::OptionError,
2356       "Color argument is invalid");
2357
2358   modifyImage();
2359
2360   // Ensure that colormap size is large enough
2361   if (colorMapSize() < (index_+1))
2362     colorMapSize(index_+1);
2363
2364   // Set color at index in colormap
2365   (imageptr->colormap)[index_]=color_;
2366 }
2367
2368 Magick::Color Magick::Image::colorMap(const size_t index_) const
2369 {
2370   if (!constImage()->colormap)
2371     {
2372       throwExceptionExplicit(MagickCore::OptionError,
2373         "Image does not contain a colormap");
2374       return(Color());
2375     }
2376
2377   if (index_ > constImage()->colors-1)
2378     throwExceptionExplicit(MagickCore::OptionError,"Index out of range");
2379
2380   return(Magick::Color((constImage()->colormap)[index_]));
2381 }
2382
2383 void Magick::Image::colorMatrix(const size_t order_,
2384   const double *color_matrix_)
2385 {
2386   KernelInfo
2387     *kernel_info;
2388
2389   GetPPException;
2390   kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2391   if (kernel_info != (KernelInfo *) NULL)
2392     {
2393       kernel_info->width=order_;
2394       kernel_info->height=order_;
2395       kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2396         order_*sizeof(*kernel_info->values));
2397       if (kernel_info->values != (MagickRealType *) NULL)
2398         {
2399           MagickCore::Image
2400             *newImage;
2401
2402           for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2403             kernel_info->values[i]=color_matrix_[i];
2404           newImage=ColorMatrixImage(image(),kernel_info,exceptionInfo);
2405           replaceImage(newImage);
2406         }
2407       kernel_info=DestroyKernelInfo(kernel_info);
2408     }
2409   ThrowImageException;
2410 }
2411
2412 bool Magick::Image::compare(const Image &reference_)
2413 {
2414   bool
2415     status;
2416
2417   Image
2418     ref=reference_;
2419
2420   GetPPException;
2421   modifyImage();
2422   status=static_cast<bool>(IsImagesEqual(image(),ref.constImage(),
2423     exceptionInfo));
2424   ThrowImageException;
2425   return(status);
2426 }
2427
2428 double Magick::Image::compare(const Image &reference_,const MetricType metric_)
2429 {
2430   double
2431     distortion=0.0;
2432
2433   GetPPException;
2434   GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2435     exceptionInfo);
2436   ThrowImageException;
2437   return(distortion);
2438 }
2439
2440 double Magick::Image::compareChannel(const ChannelType channel_,
2441   const Image &reference_,const MetricType metric_)
2442 {
2443   double
2444     distortion=0.0;
2445
2446   GetPPException;
2447   GetAndSetPPChannelMask(channel_);
2448   GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2449     exceptionInfo);
2450   RestorePPChannelMask;
2451   ThrowImageException;
2452   return(distortion);
2453 }
2454
2455 Magick::Image Magick::Image::compare(const Image &reference_,
2456   const MetricType metric_,double *distortion)
2457 {
2458   MagickCore::Image
2459     *newImage;
2460
2461   GetPPException;
2462   newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2463     exceptionInfo);
2464   ThrowImageException;
2465   if (newImage == (MagickCore::Image *) NULL)
2466     return(Magick::Image());
2467   else
2468     return(Magick::Image(newImage));
2469 }
2470
2471 Magick::Image Magick::Image::compareChannel(const ChannelType channel_,
2472   const Image &reference_,const MetricType metric_,double *distortion)
2473 {
2474   MagickCore::Image
2475     *newImage;
2476
2477   GetPPException;
2478   GetAndSetPPChannelMask(channel_);
2479   newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2480     exceptionInfo);
2481   RestorePPChannelMask;
2482   ThrowImageException;
2483   if (newImage == (MagickCore::Image *) NULL)
2484     return(Magick::Image());
2485   else
2486     return(Magick::Image(newImage));
2487 }
2488
2489 void Magick::Image::composite(const Image &compositeImage_,
2490   const Geometry &offset_,const CompositeOperator compose_)
2491 {
2492   size_t
2493     height=rows(),
2494     width=columns();
2495
2496   ssize_t
2497     x=offset_.xOff(),
2498     y=offset_.yOff();
2499
2500   ParseMetaGeometry(static_cast<std::string>(offset_).c_str(),&x,&y,&width,
2501     &height);
2502
2503   modifyImage();
2504   GetPPException;
2505   CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2506     x,y,exceptionInfo);
2507   ThrowImageException;
2508 }
2509
2510 void Magick::Image::composite(const Image &compositeImage_,
2511   const GravityType gravity_,const CompositeOperator compose_)
2512 {
2513   RectangleInfo
2514     geometry;
2515
2516   modifyImage();
2517   SetGeometry(compositeImage_.constImage(),&geometry);
2518   GravityAdjustGeometry(columns(),rows(),gravity_,&geometry);
2519
2520   GetPPException;
2521   CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2522     geometry.x,geometry.y,exceptionInfo);
2523   ThrowImageException;
2524 }
2525
2526 void Magick::Image::composite(const Image &compositeImage_,
2527   const ssize_t xOffset_,const ssize_t yOffset_,
2528   const CompositeOperator compose_)
2529 {
2530   // Image supplied as compositeImage is composited with current image and
2531   // results in updating current image.
2532   modifyImage();
2533   GetPPException;
2534   CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2535     xOffset_,yOffset_,exceptionInfo);
2536   ThrowImageException;
2537 }
2538
2539 void Magick::Image::connectedComponents(const size_t connectivity_)
2540 {
2541   MagickCore::Image
2542     *newImage;
2543
2544   GetPPException;
2545   newImage=ConnectedComponentsImage(constImage(),connectivity_,exceptionInfo);
2546   replaceImage(newImage);
2547   ThrowImageException;
2548 }
2549
2550 void Magick::Image::contrast(const bool sharpen_)
2551 {
2552   modifyImage();
2553   GetPPException;
2554   ContrastImage(image(),(MagickBooleanType) sharpen_,exceptionInfo);
2555   ThrowImageException;
2556 }
2557
2558 void Magick::Image::contrastStretch(const double blackPoint_,
2559   const double whitePoint_)
2560 {
2561   modifyImage();
2562   GetPPException;
2563   ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2564   ThrowImageException;
2565 }
2566
2567 void Magick::Image::contrastStretchChannel(const ChannelType channel_,
2568   const double blackPoint_,const double whitePoint_)
2569 {
2570   modifyImage();
2571   GetPPException;
2572   GetAndSetPPChannelMask(channel_);
2573   ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2574   RestorePPChannelMask;
2575   ThrowImageException;
2576 }
2577
2578 void Magick::Image::convolve(const size_t order_,const double *kernel_)
2579 {
2580   KernelInfo
2581     *kernel_info;
2582
2583   GetPPException;
2584   kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2585   kernel_info->width=order_;
2586   kernel_info->height=order_;
2587   kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2588     order_*sizeof(*kernel_info->values));
2589   if (kernel_info->values != (MagickRealType *) NULL)
2590     {
2591       MagickCore::Image
2592         *newImage;
2593
2594       for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2595         kernel_info->values[i]=kernel_[i];
2596       newImage=ConvolveImage(image(),kernel_info,exceptionInfo);
2597       replaceImage(newImage);
2598     }
2599   kernel_info=DestroyKernelInfo(kernel_info);
2600   ThrowImageException;
2601 }
2602
2603 void Magick::Image::copyPixels(const Image &source_,const Geometry &geometry_,
2604   const Offset &offset_)
2605 {
2606   const OffsetInfo
2607     offset=offset_;
2608
2609   const RectangleInfo
2610     geometry=geometry_;
2611
2612   GetPPException;
2613   (void) CopyImagePixels(image(),source_.constImage(),&geometry,&offset,
2614     exceptionInfo);
2615   ThrowImageException;
2616 }
2617
2618 void Magick::Image::crop(const Geometry &geometry_)
2619 {
2620   MagickCore::Image
2621     *newImage;
2622
2623   RectangleInfo
2624     cropInfo=geometry_;
2625
2626   GetPPException;
2627   newImage=CropImage(constImage(),&cropInfo,exceptionInfo);
2628   replaceImage(newImage);
2629   ThrowImageException;
2630 }
2631
2632 void Magick::Image::cycleColormap(const ssize_t amount_)
2633 {
2634   modifyImage();
2635   GetPPException;
2636   CycleColormapImage(image(),amount_,exceptionInfo);
2637   ThrowImageException;
2638 }
2639
2640 void Magick::Image::decipher(const std::string &passphrase_)
2641 {
2642   modifyImage();
2643   GetPPException;
2644   DecipherImage(image(),passphrase_.c_str(),exceptionInfo);
2645   ThrowImageException;
2646 }
2647
2648 void Magick::Image::defineSet(const std::string &magick_,
2649   const std::string &key_,bool flag_)
2650 {
2651   std::string
2652     definition;
2653
2654   modifyImage();
2655   definition=magick_ + ":" + key_;
2656   if (flag_)
2657     (void) SetImageOption(imageInfo(),definition.c_str(),"");
2658   else
2659     DeleteImageOption(imageInfo(),definition.c_str());
2660 }
2661
2662 bool Magick::Image::defineSet(const std::string &magick_,
2663   const std::string &key_ ) const
2664 {
2665   const char
2666     *option;
2667
2668   std::string
2669     key;
2670
2671   key=magick_ + ":" + key_;
2672   option=GetImageOption(constImageInfo(),key.c_str());
2673   if (option)
2674     return(true);
2675   return(false);
2676 }
2677
2678 void Magick::Image::defineValue(const std::string &magick_,
2679   const std::string &key_,const std::string &value_)
2680 {
2681   std::string
2682     format,
2683     option;
2684
2685   modifyImage();
2686   format=magick_ + ":" + key_;
2687   option=value_;
2688   (void) SetImageOption(imageInfo(),format.c_str(),option.c_str());
2689 }
2690
2691 std::string Magick::Image::defineValue(const std::string &magick_,
2692   const std::string &key_) const
2693 {
2694   const char
2695     *option;
2696
2697   std::string
2698     definition;
2699
2700   definition=magick_ + ":" + key_;
2701   option=GetImageOption(constImageInfo(),definition.c_str());
2702   if (option)
2703     return(std::string(option));
2704   return(std::string());
2705 }
2706
2707 void Magick::Image::deskew(const double threshold_)
2708 {
2709   MagickCore::Image
2710     *newImage;
2711
2712   GetPPException;
2713   newImage=DeskewImage(constImage(),threshold_,exceptionInfo);
2714   replaceImage(newImage);
2715   ThrowImageException;
2716 }
2717
2718 void Magick::Image::despeckle(void)
2719 {
2720   MagickCore::Image
2721     *newImage;
2722
2723   GetPPException;
2724   newImage=DespeckleImage(constImage(),exceptionInfo);
2725   replaceImage(newImage);
2726   ThrowImageException;
2727 }
2728
2729 void Magick::Image::display(void)
2730 {
2731   GetPPException;
2732   DisplayImages(imageInfo(),image(),exceptionInfo);
2733   ThrowImageException;
2734 }
2735
2736 void Magick::Image::distort(const DistortImageMethod method_,
2737   const size_t numberArguments_,const double *arguments_,const bool bestfit_)
2738 {
2739   MagickCore::Image
2740     *newImage;
2741
2742   GetPPException;
2743   newImage=DistortImage(constImage(), method_,numberArguments_,arguments_,
2744     bestfit_ == true ? MagickTrue : MagickFalse,exceptionInfo);
2745   replaceImage(newImage);
2746   ThrowImageException;
2747 }
2748
2749 void Magick::Image::draw(const Magick::Drawable &drawable_)
2750 {
2751   DrawingWand
2752     *wand;
2753
2754   modifyImage();
2755
2756   wand=DrawAllocateWand(options()->drawInfo(),image());
2757
2758   if(wand)
2759     {
2760       drawable_.operator()(wand);
2761
2762       DrawRender(wand);
2763
2764       ClonePPDrawException(wand);
2765       wand=DestroyDrawingWand(wand);
2766       ThrowPPDrawException(quiet());
2767     }
2768 }
2769
2770 void Magick::Image::draw(const std::vector<Magick::Drawable> &drawable_)
2771 {
2772   DrawingWand
2773     *wand;
2774
2775   modifyImage();
2776
2777   wand=DrawAllocateWand(options()->drawInfo(),image());
2778
2779   if(wand)
2780     {
2781       for (std::vector<Magick::Drawable>::const_iterator p = drawable_.begin();
2782            p != drawable_.end(); p++ )
2783         {
2784           p->operator()(wand);
2785           if (DrawGetExceptionType(wand) != MagickCore::UndefinedException)
2786             break;
2787         }
2788
2789       if (DrawGetExceptionType(wand) == MagickCore::UndefinedException)
2790         DrawRender(wand);
2791
2792       ClonePPDrawException(wand);
2793       wand=DestroyDrawingWand(wand);
2794       ThrowPPDrawException(quiet());
2795     }
2796 }
2797
2798 void Magick::Image::edge(const double radius_)
2799 {
2800   MagickCore::Image
2801     *newImage;
2802
2803   GetPPException;
2804   newImage=EdgeImage(constImage(),radius_,exceptionInfo);
2805   replaceImage(newImage);
2806   ThrowImageException;
2807 }
2808
2809 void Magick::Image::emboss(const double radius_,const double sigma_)
2810 {
2811   MagickCore::Image
2812     *newImage;
2813
2814   GetPPException;
2815   newImage=EmbossImage(constImage(),radius_,sigma_,exceptionInfo);
2816   replaceImage(newImage);
2817   ThrowImageException;
2818 }
2819
2820 void Magick::Image::encipher(const std::string &passphrase_)
2821 {
2822   modifyImage();
2823   GetPPException;
2824   EncipherImage(image(),passphrase_.c_str(),exceptionInfo);
2825   ThrowImageException;
2826 }
2827
2828 void Magick::Image::enhance(void)
2829 {
2830   MagickCore::Image
2831     *newImage;
2832
2833   GetPPException;
2834   newImage=EnhanceImage(constImage(),exceptionInfo);
2835   replaceImage(newImage);
2836   ThrowImageException;
2837 }
2838
2839 void Magick::Image::equalize(void)
2840 {
2841   modifyImage();
2842   GetPPException;
2843   EqualizeImage(image(),exceptionInfo);
2844   ThrowImageException;
2845 }
2846
2847 void Magick::Image::erase(void)
2848 {
2849   modifyImage();
2850   GetPPException;
2851   (void) SetImageBackgroundColor(image(),exceptionInfo);
2852   ThrowImageException;
2853 }
2854
2855 void Magick::Image::extent(const Geometry &geometry_ )
2856 {
2857   MagickCore::Image
2858     *newImage;
2859
2860   RectangleInfo
2861     extentInfo=geometry_;
2862
2863   modifyImage();
2864   extentInfo.x=geometry_.xOff();
2865   extentInfo.y=geometry_.yOff();
2866   GetPPException;
2867   newImage=ExtentImage(image(),&extentInfo,exceptionInfo);
2868   replaceImage(newImage);
2869   ThrowImageException;
2870 }
2871
2872 void Magick::Image::extent(const Geometry &geometry_,
2873   const Color &backgroundColor_)
2874 {
2875   backgroundColor(backgroundColor_);
2876   extent(geometry_);
2877 }
2878
2879 void Magick::Image::extent(const Geometry &geometry_,
2880   const Color &backgroundColor_,const GravityType gravity_)
2881 {
2882   backgroundColor(backgroundColor_);
2883   extent(geometry_,gravity_);
2884 }
2885
2886 void Magick::Image::extent(const Geometry &geometry_,
2887   const GravityType gravity_)
2888 {
2889   RectangleInfo
2890     geometry;
2891
2892   SetGeometry(image(),&geometry);
2893   geometry.width=geometry_.width();
2894   geometry.height=geometry_.height();
2895   GravityAdjustGeometry(image()->columns,image()->rows,gravity_,&geometry);
2896   extent(geometry);
2897 }
2898
2899 void Magick::Image::flip(void)
2900 {
2901   MagickCore::Image
2902     *newImage;
2903
2904   GetPPException;
2905   newImage=FlipImage(constImage(),exceptionInfo);
2906   replaceImage(newImage);
2907   ThrowImageException;
2908 }
2909
2910 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2911   const unsigned int alpha_,const bool invert_)
2912 {
2913   PixelInfo
2914     target;
2915
2916   modifyImage();
2917
2918   target=static_cast<PixelInfo>(pixelColor(x_,y_));
2919   target.alpha=alpha_;
2920   GetPPException;
2921   GetAndSetPPChannelMask(AlphaChannel);
2922   FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2923     (MagickBooleanType)invert_,exceptionInfo);
2924   RestorePPChannelMask;
2925   ThrowImageException;
2926 }
2927
2928 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
2929   const unsigned int alpha_,const Color &target_,const bool invert_)
2930 {
2931   PixelInfo
2932     target;
2933
2934   modifyImage();
2935
2936   target=static_cast<PixelInfo>(target_);
2937   target.alpha=alpha_;
2938   GetPPException;
2939   GetAndSetPPChannelMask(AlphaChannel);
2940   FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
2941     (MagickBooleanType)invert_,exceptionInfo);
2942   RestorePPChannelMask;
2943   ThrowImageException;
2944 }
2945
2946 void Magick::Image::floodFillColor(const Geometry &point_,
2947   const Magick::Color &fillColor_,const bool invert_)
2948 {
2949   floodFillColor(point_.xOff(),point_.yOff(),fillColor_,invert_);
2950 }
2951
2952 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2953   const Magick::Color &fillColor_,const bool invert_)
2954 {
2955   PixelInfo
2956     pixel;
2957
2958   modifyImage();
2959
2960   pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2961   floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2962 }
2963
2964 void Magick::Image::floodFillColor(const Geometry &point_,
2965   const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2966   const bool invert_)
2967 {
2968   floodFillColor(point_.xOff(),point_.yOff(),fillColor_,borderColor_,invert_);
2969 }
2970
2971 void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
2972   const Magick::Color &fillColor_,const Magick::Color &borderColor_,
2973   const bool invert_)
2974 {
2975   PixelInfo
2976     pixel;
2977
2978   modifyImage();
2979
2980   pixel=static_cast<PixelInfo>(borderColor_);
2981   floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
2982 }
2983
2984 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
2985   const Magick::Image &texture_,const bool invert_)
2986 {
2987   floodFillTexture(point_.xOff(),point_.yOff(),texture_,invert_);
2988 }
2989
2990 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
2991   const Magick::Image &texture_,const bool invert_)
2992 {
2993   PixelInfo
2994     pixel;
2995
2996   modifyImage();
2997
2998   pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
2999   floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
3000 }
3001
3002 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
3003   const Magick::Image &texture_,const Magick::Color &borderColor_,
3004   const bool invert_)
3005 {
3006   floodFillTexture(point_.xOff(),point_.yOff(),texture_,borderColor_,invert_);
3007 }
3008
3009 void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
3010   const Magick::Image &texture_,const Magick::Color &borderColor_,
3011   const bool invert_)
3012 {
3013   PixelInfo
3014     pixel;
3015
3016   modifyImage();
3017
3018   pixel=static_cast<PixelInfo>(borderColor_);
3019   floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
3020 }
3021
3022 void Magick::Image::flop(void)
3023 {
3024   MagickCore::Image
3025     *newImage;
3026
3027   GetPPException;
3028   newImage=FlopImage(constImage(),exceptionInfo);
3029   replaceImage(newImage);
3030   ThrowImageException;
3031 }
3032
3033 void Magick::Image::fontTypeMetrics(const std::string &text_,
3034   TypeMetric *metrics)
3035 {
3036   DrawInfo
3037     *drawInfo;
3038
3039   drawInfo=options()->drawInfo();
3040   drawInfo->text=const_cast<char *>(text_.c_str());
3041   GetPPException;
3042   GetTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3043   drawInfo->text=0;
3044   ThrowImageException;
3045 }
3046
3047 void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
3048   TypeMetric *metrics)
3049 {
3050   DrawInfo
3051     *drawInfo;
3052
3053   drawInfo=options()->drawInfo();
3054   drawInfo->text=const_cast<char *>(text_.c_str());
3055   GetPPException;
3056   GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3057   drawInfo->text=0;
3058   ThrowImageException;
3059 }
3060
3061 void Magick::Image::frame(const Geometry &geometry_)
3062 {
3063   FrameInfo
3064     info;
3065   
3066   MagickCore::Image
3067     *newImage;
3068
3069   info.x=static_cast<ssize_t>(geometry_.width());
3070   info.y=static_cast<ssize_t>(geometry_.height());
3071   info.width=columns() + (static_cast<size_t>(info.x) << 1);
3072   info.height=rows() + (static_cast<size_t>(info.y) << 1);
3073   info.outer_bevel=geometry_.xOff();
3074   info.inner_bevel=geometry_.yOff();
3075
3076   GetPPException;
3077   newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3078   replaceImage(newImage);
3079   ThrowImageException;
3080 }
3081
3082 void Magick::Image::frame(const size_t width_,const size_t height_,
3083   const ssize_t innerBevel_,const ssize_t outerBevel_)
3084 {
3085   FrameInfo
3086     info;
3087
3088   MagickCore::Image
3089     *newImage;
3090
3091   info.x=static_cast<ssize_t>(width_);
3092   info.y=static_cast<ssize_t>(height_);
3093   info.width=columns() + (static_cast<size_t>(info.x) << 1);
3094   info.height=rows() + (static_cast<size_t>(info.y) << 1);
3095   info.outer_bevel=static_cast<ssize_t>(outerBevel_);
3096   info.inner_bevel=static_cast<ssize_t>(innerBevel_);
3097
3098   GetPPException;
3099   newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3100   replaceImage(newImage);
3101   ThrowImageException;
3102 }
3103
3104 void Magick::Image::fx(const std::string expression_)
3105 {
3106   MagickCore::Image
3107     *newImage;
3108
3109   GetPPException;
3110   newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3111   replaceImage(newImage);
3112   ThrowImageException;
3113 }
3114
3115 void Magick::Image::fx(const std::string expression_,
3116   const Magick::ChannelType channel_)
3117 {
3118   MagickCore::Image
3119     *newImage;
3120
3121   GetPPException;
3122   GetAndSetPPChannelMask(channel_);
3123   newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3124   RestorePPChannelMask;
3125   replaceImage(newImage);
3126   ThrowImageException;
3127 }
3128
3129 void Magick::Image::gamma(const double gamma_)
3130 {
3131   modifyImage();
3132   GetPPException;
3133   GammaImage(image(),gamma_,exceptionInfo);
3134   ThrowImageException;
3135 }
3136
3137 void Magick::Image::gamma(const double gammaRed_,const double gammaGreen_,
3138   const double gammaBlue_)
3139 {
3140   modifyImage();
3141   GetPPException;
3142   GetAndSetPPChannelMask(RedChannel);
3143   (void) GammaImage(image(),gammaRed_,exceptionInfo);
3144   SetPPChannelMask(GreenChannel);
3145   (void) GammaImage(image(),gammaGreen_,exceptionInfo);
3146   SetPPChannelMask(BlueChannel);
3147   (void) GammaImage(image(),gammaBlue_,exceptionInfo);
3148   RestorePPChannelMask;
3149   ThrowImageException;
3150 }
3151
3152 void Magick::Image::gaussianBlur(const double width_,const double sigma_)
3153 {
3154   MagickCore::Image
3155     *newImage;
3156
3157   GetPPException;
3158   newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3159   replaceImage(newImage);
3160   ThrowImageException;
3161 }
3162
3163 void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
3164   const double width_,const double sigma_)
3165 {
3166   MagickCore::Image
3167     *newImage;
3168
3169   GetPPException;
3170   GetAndSetPPChannelMask(channel_);
3171   newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
3172   RestorePPChannelMask;
3173   replaceImage(newImage);
3174   ThrowImageException;
3175 }
3176
3177 const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
3178   const ssize_t y_,const size_t columns_,const size_t rows_) const
3179 {
3180   const Quantum
3181     *p;
3182
3183   GetPPException;
3184   p=GetVirtualPixels(constImage(),x_, y_,columns_, rows_,exceptionInfo);
3185   ThrowImageException;
3186   return(p);
3187 }
3188
3189 const void *Magick::Image::getConstMetacontent(void) const
3190 {
3191   const void
3192     *result;
3193
3194   result=GetVirtualMetacontent(constImage());
3195
3196   if(!result)
3197     throwExceptionExplicit(MagickCore::OptionError,
3198       "Unable to retrieve meta content.");
3199
3200   return(result);
3201 }
3202
3203 void *Magick::Image::getMetacontent(void )
3204 {
3205   void
3206     *result;
3207
3208   result=GetAuthenticMetacontent(image());
3209
3210   if(!result)
3211     throwExceptionExplicit(MagickCore::OptionError,
3212       "Unable to retrieve meta content.");
3213
3214   return(result);
3215 }
3216
3217 Magick::Quantum *Magick::Image::getPixels(const ssize_t x_,const ssize_t y_,
3218   const size_t columns_,const size_t rows_)
3219 {
3220   Quantum
3221     *result;
3222
3223   modifyImage();
3224   GetPPException;
3225   result=GetAuthenticPixels(image(),x_, y_,columns_,rows_,exceptionInfo);
3226   ThrowImageException;
3227
3228   return(result);
3229 }
3230
3231 void Magick::Image::grayscale(const PixelIntensityMethod method_)
3232 {
3233   modifyImage();
3234   GetPPException;
3235   (void) GrayscaleImage(image(),method_,exceptionInfo);
3236   ThrowImageException;
3237 }
3238
3239 void  Magick::Image::haldClut(const Image &clutImage_)
3240 {
3241   modifyImage();
3242   GetPPException;
3243   (void) HaldClutImage(image(),clutImage_.constImage(),exceptionInfo);
3244   ThrowImageException;
3245 }
3246
3247 void Magick::Image::houghLine(const size_t width_,const size_t height_,
3248   const size_t threshold_)
3249 {
3250   MagickCore::Image
3251     *newImage;
3252
3253   GetPPException;
3254   newImage=HoughLineImage(constImage(),width_,height_,threshold_,
3255     exceptionInfo);
3256   replaceImage(newImage);
3257   ThrowImageException;
3258 }
3259
3260 Magick::ImageType Magick::Image::identifyType(void) const
3261 {
3262   ImageType
3263     image_type;
3264
3265   GetPPException;
3266   image_type=IdentifyImageType(constImage(),exceptionInfo);
3267   ThrowImageException;
3268   return(image_type);
3269 }
3270
3271 void Magick::Image::implode(const double factor_)
3272 {
3273   MagickCore::Image
3274     *newImage;
3275
3276   GetPPException;
3277   newImage=ImplodeImage(constImage(),factor_,image()->interpolate,
3278     exceptionInfo);
3279   replaceImage(newImage);
3280   ThrowImageException;
3281 }
3282
3283 void Magick::Image::inverseFourierTransform(const Image &phase_)
3284 {
3285   inverseFourierTransform(phase_,true);
3286 }
3287
3288 void Magick::Image::inverseFourierTransform(const Image &phase_,
3289   const bool magnitude_)
3290 {
3291   MagickCore::Image
3292     *newImage;
3293
3294   GetPPException;
3295   newImage=InverseFourierTransformImage(constImage(),phase_.constImage(),
3296     magnitude_ == true ? MagickTrue : MagickFalse,exceptionInfo);
3297   replaceImage(newImage);
3298   ThrowImageException;
3299 }
3300
3301 void Magick::Image::kuwahara(const double radius_,const double sigma_)
3302 {
3303   MagickCore::Image
3304     *newImage;
3305
3306   GetPPException;
3307   newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3308   replaceImage(newImage);
3309   ThrowImageException;
3310 }
3311
3312 void Magick::Image::kuwaharaChannel(const ChannelType channel_,
3313   const double radius_,const double sigma_)
3314 {
3315   MagickCore::Image
3316     *newImage;
3317
3318   GetPPException;
3319   GetAndSetPPChannelMask(channel_);
3320   newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3321   replaceImage(newImage);
3322   RestorePPChannelMask;
3323   ThrowImageException;
3324 }
3325
3326 void Magick::Image::level(const double blackPoint_,const double whitePoint_,
3327   const double gamma_)
3328 {
3329   modifyImage();
3330   GetPPException;
3331   (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3332   ThrowImageException;
3333 }
3334
3335 void Magick::Image::levelChannel(const ChannelType channel_,
3336   const double blackPoint_,const double whitePoint_,const double gamma_)
3337 {
3338   modifyImage();
3339   GetPPException;
3340   GetAndSetPPChannelMask(channel_);
3341   (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3342   RestorePPChannelMask;
3343   ThrowImageException;
3344 }
3345
3346 void Magick::Image::levelColors(const Color &blackColor_,
3347   const Color &whiteColor_,const bool invert_)
3348 {
3349   PixelInfo
3350     black,
3351     white;
3352
3353   modifyImage();
3354
3355   black=static_cast<PixelInfo>(blackColor_);
3356   white=static_cast<PixelInfo>(whiteColor_);
3357   GetPPException;
3358   (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3359     MagickTrue : MagickFalse,exceptionInfo);
3360   ThrowImageException;
3361 }
3362
3363 void Magick::Image::levelColorsChannel(const ChannelType channel_,
3364   const Color &blackColor_,const Color &whiteColor_,const bool invert_)
3365 {
3366   PixelInfo
3367     black,
3368     white;
3369
3370   modifyImage();
3371
3372   black=static_cast<PixelInfo>(blackColor_);
3373   white=static_cast<PixelInfo>(whiteColor_);
3374   GetPPException;
3375   GetAndSetPPChannelMask(channel_);
3376   (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3377     MagickTrue : MagickFalse,exceptionInfo);
3378   RestorePPChannelMask;
3379   ThrowImageException;
3380 }
3381
3382 void Magick::Image::linearStretch(const double blackPoint_,
3383   const double whitePoint_)
3384 {
3385   modifyImage();
3386   GetPPException;
3387   LinearStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
3388   ThrowImageException;
3389 }
3390
3391 void Magick::Image::liquidRescale(const Geometry &geometry_)
3392 {
3393   MagickCore::Image
3394     *newImage;
3395
3396   size_t
3397     height=rows(),
3398     width=columns();
3399
3400   ssize_t
3401     x=0,
3402     y=0;
3403
3404   ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3405     &height);
3406
3407   GetPPException;
3408   newImage=LiquidRescaleImage(image(),width,height,x,y,exceptionInfo);
3409   replaceImage(newImage);
3410   ThrowImageException;
3411 }
3412
3413 void Magick::Image::magnify(void)
3414 {
3415   MagickCore::Image
3416     *newImage;
3417
3418   GetPPException;
3419   newImage=MagnifyImage(constImage(),exceptionInfo);
3420   replaceImage(newImage);
3421   ThrowImageException;
3422 }
3423
3424 void Magick::Image::map(const Image &mapImage_,const bool dither_)
3425 {
3426   modifyImage();
3427   GetPPException;
3428   options()->quantizeDither(dither_);
3429   RemapImage(options()->quantizeInfo(),image(),mapImage_.constImage(),
3430     exceptionInfo);
3431   ThrowImageException;
3432 }
3433
3434 void Magick::Image::medianFilter(const double radius_)
3435 {
3436   MagickCore::Image
3437     *newImage;
3438
3439   GetPPException;
3440   newImage=StatisticImage(image(),MedianStatistic,(size_t) radius_,
3441     (size_t) radius_,exceptionInfo);
3442   replaceImage(newImage);
3443   ThrowImageException;
3444 }
3445
3446 void Magick::Image::minify(void)
3447 {
3448   MagickCore::Image
3449     *newImage;
3450
3451   GetPPException;
3452   newImage=MinifyImage(constImage(),exceptionInfo);
3453   replaceImage(newImage);
3454   ThrowImageException;
3455 }
3456
3457 void Magick::Image::modulate(const double brightness_,const double saturation_,
3458   const double hue_)
3459 {
3460   char
3461     modulate[MagickPathExtent + 1];
3462
3463   FormatLocaleString(modulate,MagickPathExtent,"%3.6f,%3.6f,%3.6f",brightness_,
3464     saturation_,hue_);
3465
3466   modifyImage();
3467   GetPPException;
3468   ModulateImage(image(),modulate,exceptionInfo);
3469   ThrowImageException;
3470 }
3471
3472 Magick::ImageMoments Magick::Image::moments(void) const
3473 {
3474   return(ImageMoments(*this));
3475 }
3476
3477 void Magick::Image::morphology(const MorphologyMethod method_,
3478   const std::string kernel_,const ssize_t iterations_)
3479 {
3480   KernelInfo
3481     *kernel;
3482
3483   MagickCore::Image
3484     *newImage;
3485
3486   GetPPException;
3487   kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3488   if (kernel == (KernelInfo *) NULL)
3489     throwExceptionExplicit(MagickCore::OptionError,"Unable to parse kernel.");
3490   newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3491     exceptionInfo);
3492   replaceImage(newImage);
3493   kernel=DestroyKernelInfo(kernel);
3494   ThrowImageException;
3495 }
3496
3497 void Magick::Image::morphology(const MorphologyMethod method_,
3498   const KernelInfoType kernel_,const std::string arguments_,
3499   const ssize_t iterations_)
3500 {
3501   const char
3502     *option;
3503
3504   std::string
3505     kernel;
3506
3507   option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3508   if (option == (const char *)NULL)
3509     {
3510       throwExceptionExplicit(MagickCore::OptionError,
3511         "Unable to determine kernel type.");
3512       return;
3513     }
3514   kernel=std::string(option);
3515   if (!arguments_.empty())
3516     kernel+=":"+arguments_;
3517
3518   morphology(method_,kernel,iterations_);
3519 }
3520
3521 void Magick::Image::morphologyChannel(const ChannelType channel_,
3522   const MorphologyMethod method_,const std::string kernel_,
3523   const ssize_t iterations_)
3524 {
3525   KernelInfo
3526     *kernel;
3527
3528   MagickCore::Image
3529     *newImage;
3530
3531
3532   GetPPException;
3533   kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3534   if (kernel == (KernelInfo *)NULL)
3535     {
3536       throwExceptionExplicit(MagickCore::OptionError,
3537         "Unable to parse kernel.");
3538       return;
3539     }
3540   GetAndSetPPChannelMask(channel_);
3541   newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3542     exceptionInfo);
3543   RestorePPChannelMask;
3544   replaceImage(newImage);
3545   kernel=DestroyKernelInfo(kernel);
3546   ThrowImageException;
3547 }
3548
3549 void Magick::Image::morphologyChannel(const ChannelType channel_,
3550   const MorphologyMethod method_,const KernelInfoType kernel_,
3551   const std::string arguments_,const ssize_t iterations_)
3552 {
3553   const char
3554     *option;
3555
3556   std::string
3557     kernel;
3558
3559   option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3560   if (option == (const char *)NULL)
3561     {
3562       throwExceptionExplicit(MagickCore::OptionError,
3563         "Unable to determine kernel type.");
3564       return;
3565     }
3566
3567   kernel=std::string(option);
3568   if (!arguments_.empty())
3569     kernel+=":"+arguments_;
3570
3571   morphologyChannel(channel_,method_,kernel,iterations_);
3572 }
3573
3574 void Magick::Image::motionBlur(const double radius_,const double sigma_,
3575   const double angle_)
3576 {
3577   MagickCore::Image
3578     *newImage;
3579
3580   GetPPException;
3581   newImage=MotionBlurImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
3582   replaceImage(newImage);
3583   ThrowImageException;
3584 }
3585
3586 void Magick::Image::negate(const bool grayscale_)
3587 {
3588   modifyImage();
3589   GetPPException;
3590   NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3591   ThrowImageException;
3592 }
3593
3594 void Magick::Image::negateChannel(const ChannelType channel_,
3595   const bool grayscale_)
3596 {
3597   modifyImage();
3598   GetPPException;
3599   GetAndSetPPChannelMask(channel_);
3600   NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3601   RestorePPChannelMask;
3602   ThrowImageException;
3603 }
3604
3605 void Magick::Image::normalize(void)
3606 {
3607   modifyImage();
3608   GetPPException;
3609   NormalizeImage(image(),exceptionInfo);
3610   ThrowImageException;
3611 }
3612
3613 void Magick::Image::oilPaint(const double radius_,const double sigma_)
3614 {
3615   MagickCore::Image
3616     *newImage;
3617
3618   GetPPException;
3619   newImage=OilPaintImage(constImage(),radius_,sigma_,exceptionInfo);
3620   replaceImage(newImage);
3621   ThrowImageException;
3622 }
3623
3624 void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_,
3625   const bool invert_)
3626 {
3627   std::string
3628     opaqueColor,
3629     penColor;
3630
3631   PixelInfo
3632     opaque,
3633     pen;
3634
3635   if (!opaqueColor_.isValid())
3636     throwExceptionExplicit(MagickCore::OptionError,
3637       "Opaque color argument is invalid");
3638
3639   if (!penColor_.isValid())
3640     throwExceptionExplicit(MagickCore::OptionError,
3641       "Pen color argument is invalid");
3642
3643   modifyImage();
3644   opaqueColor=opaqueColor_;
3645   penColor=penColor_;
3646
3647   GetPPException;
3648   (void) QueryColorCompliance(opaqueColor.c_str(),AllCompliance,&opaque,
3649     exceptionInfo);
3650   (void) QueryColorCompliance(penColor.c_str(),AllCompliance,&pen,
3651     exceptionInfo);
3652   OpaquePaintImage(image(),&opaque,&pen,invert_ ? MagickTrue : MagickFalse,
3653     exceptionInfo);
3654   ThrowImageException;
3655 }
3656
3657 void Magick::Image::orderedDither(std::string thresholdMap_)
3658 {
3659   modifyImage();
3660   GetPPException;
3661   (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3662   ThrowImageException;
3663 }
3664
3665 void Magick::Image::orderedDitherChannel(const ChannelType channel_,
3666   std::string thresholdMap_)
3667 {
3668   modifyImage();
3669   GetPPException;
3670   GetAndSetPPChannelMask(channel_);
3671   (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3672   RestorePPChannelMask;
3673   ThrowImageException;
3674 }
3675
3676 void Magick::Image::perceptible(const double epsilon_)
3677 {
3678   modifyImage();
3679   GetPPException;
3680   PerceptibleImage(image(),epsilon_,exceptionInfo);
3681   ThrowImageException;
3682 }
3683
3684 void Magick::Image::perceptibleChannel(const ChannelType channel_,
3685   const double epsilon_)
3686 {
3687   modifyImage();
3688   GetPPException;
3689   GetAndSetPPChannelMask(channel_);
3690   PerceptibleImage(image(),epsilon_,exceptionInfo);
3691   RestorePPChannelMask;
3692   ThrowImageException;
3693 }
3694
3695  Magick::ImagePerceptualHash Magick::Image::perceptualHash() const
3696 {
3697   return(ImagePerceptualHash(*this));
3698 }
3699
3700 void Magick::Image::ping(const std::string &imageSpec_)
3701 {
3702   MagickCore::Image
3703     *newImage;
3704
3705   GetPPException;
3706   options()->fileName(imageSpec_);
3707   newImage=PingImage(imageInfo(),exceptionInfo);
3708   read(newImage,exceptionInfo);
3709 }
3710
3711 void Magick::Image::ping(const Blob& blob_)
3712 {
3713   MagickCore::Image
3714     *newImage;
3715
3716   GetPPException;
3717   newImage=PingBlob(imageInfo(),blob_.data(),blob_.length(),exceptionInfo);
3718   read(newImage,exceptionInfo);
3719 }
3720
3721 void Magick::Image::pixelColor(const ssize_t x_,const ssize_t y_,
3722   const Color &color_)
3723 {
3724   PixelInfo
3725     packet;
3726
3727   Quantum
3728     *pixel;
3729
3730   // Test arguments to ensure they are within the image.
3731   if (y_ > (ssize_t) rows() || x_ > (ssize_t) columns())
3732     throwExceptionExplicit(MagickCore::OptionError,
3733       "Access outside of image boundary");
3734
3735   modifyImage();
3736
3737   // Set image to DirectClass
3738   classType(DirectClass );
3739
3740   // Get pixel view
3741   Pixels pixels(*this);
3742     // Set pixel value
3743   pixel=pixels.get(x_, y_, 1, 1 );
3744   packet=color_;
3745   MagickCore::SetPixelViaPixelInfo(constImage(),&packet,pixel);
3746   // Tell ImageMagick that pixels have been updated
3747   pixels.sync();
3748 }
3749
3750 Magick::Color Magick::Image::pixelColor(const ssize_t x_,
3751   const ssize_t y_) const
3752 {
3753   const Quantum
3754     *pixel;
3755
3756   pixel=getConstPixels(x_,y_,1,1);
3757   if (pixel)
3758     {
3759       PixelInfo
3760         packet;
3761
3762       MagickCore::GetPixelInfoPixel(constImage(),pixel,&packet);
3763       return(Color(packet));
3764     }
3765
3766   return(Color()); // invalid
3767 }
3768
3769 void Magick::Image::polaroid(const std::string &caption_,const double angle_,
3770   const PixelInterpolateMethod method_)
3771 {
3772   MagickCore::Image
3773     *newImage;
3774
3775   GetPPException;
3776   newImage=PolaroidImage(constImage(),options()->drawInfo(),caption_.c_str(),
3777     angle_,method_,exceptionInfo);
3778   replaceImage(newImage);
3779   ThrowImageException;
3780 }
3781
3782 void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
3783 {
3784   modifyImage();
3785   GetPPException;
3786   PosterizeImage(image(),levels_,method_,exceptionInfo);
3787   ThrowImageException;
3788 }
3789
3790 void Magick::Image::posterizeChannel(const ChannelType channel_,
3791   const size_t levels_,const DitherMethod method_)
3792 {
3793   modifyImage();
3794   GetPPException;
3795   GetAndSetPPChannelMask(channel_);
3796   PosterizeImage(image(),levels_,method_,exceptionInfo);
3797   RestorePPChannelMask;
3798   ThrowImageException;
3799 }
3800
3801 void Magick::Image::process(std::string name_,const ssize_t argc,
3802   const char **argv)
3803 {
3804   modifyImage();
3805
3806   GetPPException;
3807   (void) InvokeDynamicImageFilter(name_.c_str(),&image(),argc,argv,
3808       exceptionInfo);
3809   ThrowImageException;
3810 }
3811
3812 void Magick::Image::profile(const std::string name_,
3813   const Magick::Blob &profile_)
3814 {
3815   modifyImage();
3816   GetPPException;
3817   (void) ProfileImage(image(),name_.c_str(),(unsigned char *)profile_.data(),
3818     profile_.length(),exceptionInfo);
3819   ThrowImageException;
3820 }
3821
3822 Magick::Blob Magick::Image::profile(const std::string name_) const
3823 {
3824   const StringInfo
3825     *profile;
3826
3827   profile=GetImageProfile(constImage(),name_.c_str());
3828
3829   if (profile == (StringInfo *) NULL)
3830     return(Blob());
3831   return(Blob((void*) GetStringInfoDatum(profile),GetStringInfoLength(
3832     profile)));
3833 }
3834
3835 void Magick::Image::quantize(const bool measureError_)
3836 {
3837   modifyImage();
3838  
3839   if (measureError_)
3840     options()->quantizeInfo()->measure_error=MagickTrue;
3841   else
3842     options()->quantizeInfo()->measure_error=MagickFalse;
3843
3844   GetPPException;
3845   QuantizeImage(options()->quantizeInfo(),image(),exceptionInfo);
3846   ThrowImageException;
3847 }
3848
3849 void Magick::Image::quantumOperator(const ChannelType channel_,
3850   const MagickEvaluateOperator operator_,double rvalue_)
3851 {
3852   GetPPException;
3853   GetAndSetPPChannelMask(channel_);
3854   EvaluateImage(image(),operator_,rvalue_,exceptionInfo);
3855   RestorePPChannelMask;
3856   ThrowImageException;
3857 }
3858
3859 void Magick::Image::quantumOperator(const ssize_t x_,const ssize_t y_,
3860   const size_t columns_,const size_t rows_,const ChannelType channel_,
3861   const MagickEvaluateOperator operator_,const double rvalue_)
3862 {
3863   RectangleInfo
3864     geometry;
3865
3866   MagickCore::Image
3867     *cropImage;
3868
3869   geometry.width = columns_;
3870   geometry.height = rows_;
3871   geometry.x = x_;
3872   geometry.y = y_;
3873
3874   GetPPException;
3875   cropImage=CropImage(image(),&geometry,exceptionInfo);
3876   GetAndSetPPChannelMask(channel_);
3877   EvaluateImage(cropImage,operator_,rvalue_,exceptionInfo);
3878   RestorePPChannelMask;
3879   (void) CompositeImage(image(),cropImage,image()->alpha_trait == 
3880     BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
3881     geometry.x,geometry.y,exceptionInfo );
3882   cropImage=DestroyImageList(cropImage);
3883   ThrowImageException;
3884 }
3885
3886 void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
3887 {
3888   RectangleInfo
3889     raiseInfo=geometry_;
3890
3891   GetPPException;
3892   modifyImage();
3893   RaiseImage(image(),&raiseInfo,raisedFlag_ == true ? MagickTrue : MagickFalse,
3894     exceptionInfo);
3895   ThrowImageException;
3896 }
3897
3898 void Magick::Image::randomThreshold(const Geometry &thresholds_)
3899 {
3900   GetPPException;
3901   (void) RandomThresholdImage(image(),static_cast<std::string>(
3902     thresholds_).c_str(),exceptionInfo);
3903   ThrowImageException;
3904 }
3905
3906 void Magick::Image::randomThresholdChannel(const ChannelType channel_,
3907   const Geometry &thresholds_)
3908 {
3909   modifyImage();
3910   GetPPException;
3911   GetAndSetPPChannelMask(channel_);
3912   (void) RandomThresholdImage(image(),static_cast<std::string>(
3913     thresholds_).c_str(),exceptionInfo);
3914   RestorePPChannelMask;
3915   ThrowImageException;
3916 }
3917
3918 void Magick::Image::read(const Blob &blob_)
3919 {
3920   MagickCore::Image
3921     *newImage;
3922
3923   GetPPException;
3924   newImage=BlobToImage(imageInfo(),static_cast<const void *>(blob_.data()),
3925     blob_.length(),exceptionInfo);
3926   read(newImage,exceptionInfo);
3927 }
3928
3929 void Magick::Image::read(const Blob &blob_,const Geometry &size_)
3930 {
3931   size(size_);
3932   read(blob_);
3933 }
3934
3935 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3936   const size_t depth_)
3937 {
3938   size(size_);
3939   depth(depth_);
3940   read(blob_);
3941 }
3942
3943 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3944   const size_t depth_,const std::string &magick_)
3945 {
3946   size(size_);
3947   depth(depth_);
3948   magick(magick_);
3949   // Set explicit image format
3950   fileName(magick_ + ':');
3951   read(blob_);
3952 }
3953
3954 void Magick::Image::read(const Blob &blob_,const Geometry &size_,
3955   const std::string &magick_)
3956 {
3957   size(size_);
3958   magick(magick_);
3959   // Set explicit image format
3960   fileName(magick_ + ':');
3961   read(blob_);
3962 }
3963
3964 void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_)
3965 {
3966   size(size_);
3967   read(imageSpec_);
3968 }
3969
3970 void Magick::Image::read(const size_t width_,const size_t height_,
3971   const std::string &map_,const StorageType type_,const void *pixels_)
3972 {
3973   MagickCore::Image
3974     *newImage;
3975
3976   GetPPException;
3977   newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
3978     exceptionInfo);
3979   replaceImage(newImage);
3980   ThrowImageException;
3981 }
3982
3983 void Magick::Image::read(const std::string &imageSpec_)
3984 {
3985   MagickCore::Image
3986     *newImage;
3987
3988   GetPPException;
3989   options()->fileName(imageSpec_);
3990   newImage=ReadImage(imageInfo(),exceptionInfo);
3991   read(newImage,exceptionInfo);
3992 }
3993
3994 void Magick::Image::readPixels(const Magick::QuantumType quantum_,
3995   const unsigned char *source_)
3996 {
3997   QuantumInfo
3998     *quantum_info;
3999
4000   quantum_info=AcquireQuantumInfo(imageInfo(),image());
4001   GetPPException;
4002   ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4003     quantum_,source_,exceptionInfo);
4004   quantum_info=DestroyQuantumInfo(quantum_info);
4005   ThrowImageException;
4006 }
4007
4008 void Magick::Image::reduceNoise(void)
4009 {
4010   reduceNoise(3);
4011 }
4012
4013 void Magick::Image::reduceNoise(const size_t order_)
4014 {
4015   MagickCore::Image
4016     *newImage;
4017
4018   GetPPException;
4019   newImage=StatisticImage(constImage(),NonpeakStatistic,order_,
4020     order_,exceptionInfo);
4021   replaceImage(newImage);
4022   ThrowImageException;
4023 }
4024
4025 void Magick::Image::repage()
4026 {
4027   modifyImage();
4028   options()->page(Geometry());
4029   image()->page.width = 0;
4030   image()->page.height = 0;
4031   image()->page.x = 0;
4032   image()->page.y = 0;
4033 }
4034
4035 void Magick::Image::resample(const Point &density_)
4036 {
4037   MagickCore::Image
4038     *newImage;
4039
4040   GetPPException;
4041   newImage=ResampleImage(constImage(),density_.x(),density_.y(),
4042     image()->filter,exceptionInfo);
4043   replaceImage(newImage);
4044   ThrowImageException;
4045 }
4046
4047 void Magick::Image::resize(const Geometry &geometry_)
4048 {
4049   MagickCore::Image
4050     *newImage;
4051
4052   size_t
4053     height=rows(),
4054     width=columns();
4055
4056   ssize_t
4057     x=0,
4058     y=0;
4059
4060   // Calculate new size.  This code should be supported using binary arguments
4061   // in the ImageMagick library.
4062   ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4063     &height);
4064
4065   GetPPException;
4066   newImage=ResizeImage(constImage(),width,height,image()->filter,
4067     exceptionInfo);
4068   replaceImage(newImage);
4069   ThrowImageException;
4070 }
4071
4072 void Magick::Image::roll(const Geometry &roll_)
4073 {
4074   MagickCore::Image
4075     *newImage;
4076
4077   GetPPException;
4078   newImage=RollImage(constImage(),roll_.xOff(),roll_.yOff(),exceptionInfo);
4079   replaceImage(newImage);
4080   ThrowImageException;
4081 }
4082
4083 void Magick::Image::roll(const size_t columns_,const size_t rows_)
4084 {
4085   MagickCore::Image
4086     *newImage;
4087
4088   GetPPException;
4089   newImage=RollImage(constImage(),static_cast<ssize_t>(columns_),
4090     static_cast<ssize_t>(rows_),exceptionInfo);
4091   replaceImage(newImage);
4092   ThrowImageException;
4093 }
4094
4095 void Magick::Image::rotate(const double degrees_)
4096 {
4097   MagickCore::Image
4098     *newImage;
4099
4100   GetPPException;
4101   newImage=RotateImage(constImage(),degrees_,exceptionInfo);
4102   replaceImage(newImage);
4103   ThrowImageException;
4104 }
4105
4106 void Magick::Image::rotationalBlur(const double angle_)
4107 {
4108   MagickCore::Image
4109     *newImage;
4110
4111   GetPPException;
4112   newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4113   replaceImage(newImage);
4114   ThrowImageException;
4115 }
4116
4117 void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
4118   const double angle_)
4119 {
4120   MagickCore::Image
4121     *newImage;
4122
4123   GetPPException;
4124   GetAndSetPPChannelMask(channel_);
4125   newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4126   RestorePPChannelMask;
4127   replaceImage(newImage);
4128   ThrowImageException;
4129 }
4130
4131 void Magick::Image::sample(const Geometry &geometry_)
4132 {
4133   MagickCore::Image
4134     *newImage;
4135
4136   size_t
4137     height=rows(),
4138     width=columns();
4139
4140   ssize_t
4141     x=0,
4142     y=0;
4143
4144   ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4145     &height);
4146
4147   GetPPException;
4148   newImage=SampleImage(constImage(),width,height,exceptionInfo);
4149   replaceImage(newImage);
4150   ThrowImageException;
4151 }
4152
4153 void Magick::Image::scale(const Geometry &geometry_)
4154 {
4155   MagickCore::Image
4156     *newImage;
4157
4158   size_t
4159     height=rows(),
4160     width=columns();
4161
4162   ssize_t
4163     x=0,
4164     y=0;
4165
4166   ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4167     &height);
4168
4169   GetPPException;
4170   newImage=ScaleImage(constImage(),width,height,exceptionInfo);
4171   replaceImage(newImage);
4172   ThrowImageException;
4173 }
4174
4175 void Magick::Image::segment(const double clusterThreshold_,
4176   const double smoothingThreshold_)
4177 {
4178   modifyImage();
4179   GetPPException;
4180   SegmentImage(image(),options()->quantizeColorSpace(),
4181     (MagickBooleanType) options()->verbose(),clusterThreshold_,
4182     smoothingThreshold_,exceptionInfo);
4183   SyncImage(image(),exceptionInfo);
4184   ThrowImageException;
4185 }
4186
4187 void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
4188   const double threshold_)
4189 {
4190   MagickCore::Image
4191     *newImage;
4192
4193   GetPPException;
4194   newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4195     exceptionInfo);
4196   replaceImage(newImage);
4197   ThrowImageException;
4198 }
4199
4200 void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
4201   const double radius_,const double sigma_,const double threshold_)
4202 {
4203   MagickCore::Image
4204     *newImage;
4205
4206   GetPPException;
4207   GetAndSetPPChannelMask(channel_);
4208   newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4209     exceptionInfo);
4210   RestorePPChannelMask;
4211   replaceImage(newImage);
4212   ThrowImageException;
4213 }
4214
4215 Magick::Image Magick::Image::separate(const ChannelType channel_) const
4216 {
4217   MagickCore::Image
4218     *image;
4219
4220   GetPPException;
4221   image=SeparateImage(constImage(),channel_,exceptionInfo);
4222   ThrowImageException;
4223   if (image == (MagickCore::Image *) NULL)
4224     return(Magick::Image());
4225   else
4226     return(Magick::Image(image));
4227 }
4228
4229 void Magick::Image::sepiaTone(const double threshold_)
4230 {
4231   MagickCore::Image
4232     *newImage;
4233
4234   GetPPException;
4235   newImage=SepiaToneImage(constImage(),threshold_,exceptionInfo);
4236   replaceImage(newImage);
4237   ThrowImageException;
4238 }
4239
4240 Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
4241   const size_t columns_,const size_t rows_)
4242 {
4243   Quantum
4244     *result;
4245
4246   modifyImage();
4247   GetPPException;
4248   result=QueueAuthenticPixels(image(),x_,y_,columns_,rows_,exceptionInfo);
4249   ThrowImageException;
4250   return(result);
4251 }
4252
4253 void Magick::Image::shade(const double azimuth_,const double elevation_,
4254   const bool colorShading_)
4255 {
4256   MagickCore::Image
4257     *newImage;
4258
4259   GetPPException;
4260   newImage=ShadeImage(constImage(),colorShading_ == true ?
4261     MagickTrue : MagickFalse,azimuth_,elevation_,exceptionInfo);
4262   replaceImage(newImage);
4263   ThrowImageException;
4264 }
4265
4266 void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
4267   const ssize_t x_,const ssize_t y_)
4268 {
4269   MagickCore::Image
4270     *newImage;
4271
4272   GetPPException;
4273   newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
4274     exceptionInfo);
4275   replaceImage(newImage);
4276   ThrowImageException;
4277 }
4278
4279 void Magick::Image::sharpen(const double radius_,const double sigma_)
4280 {
4281   MagickCore::Image
4282     *newImage;
4283
4284   GetPPException;
4285   newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4286   replaceImage(newImage);
4287   ThrowImageException;
4288 }
4289
4290 void Magick::Image::sharpenChannel(const ChannelType channel_,
4291   const double radius_,const double sigma_)
4292 {
4293   MagickCore::Image
4294     *newImage;
4295
4296   GetPPException;
4297   GetAndSetPPChannelMask(channel_);
4298   newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4299   RestorePPChannelMask;
4300   replaceImage(newImage);
4301   ThrowImageException;
4302 }
4303
4304 void Magick::Image::shave(const Geometry &geometry_)
4305 {
4306   MagickCore::Image
4307     *newImage;
4308
4309   RectangleInfo
4310     shaveInfo=geometry_;
4311
4312   GetPPException;
4313   newImage=ShaveImage(constImage(),&shaveInfo,exceptionInfo);
4314   replaceImage(newImage);
4315   ThrowImageException;
4316 }
4317
4318 void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
4319 {
4320   MagickCore::Image
4321     *newImage;
4322
4323   GetPPException;
4324   newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,exceptionInfo);
4325   replaceImage(newImage);
4326   ThrowImageException;
4327 }
4328
4329 void Magick::Image::sigmoidalContrast(const bool sharpen_,
4330   const double contrast,const double midpoint)
4331 {
4332   modifyImage();
4333   GetPPException;
4334   (void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
4335     midpoint,exceptionInfo);
4336   ThrowImageException;
4337 }
4338
4339 std::string Magick::Image::signature(const bool force_) const
4340 {
4341   return(_imgRef->signature());
4342 }
4343
4344 void Magick::Image::sketch(const double radius_,const double sigma_,
4345   const double angle_)
4346 {
4347   MagickCore::Image
4348     *newImage;
4349
4350   GetPPException;
4351   newImage=SketchImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
4352   replaceImage(newImage);
4353   ThrowImageException;
4354 }
4355
4356 void Magick::Image::solarize(const double factor_)
4357 {
4358   modifyImage();
4359   GetPPException;
4360   SolarizeImage(image(),factor_,exceptionInfo);
4361   ThrowImageException;
4362 }
4363
4364 void Magick::Image::sparseColor(const ChannelType channel_,
4365   const SparseColorMethod method_,const size_t numberArguments_,
4366   const double *arguments_)
4367 {
4368   MagickCore::Image
4369     *newImage;
4370
4371   GetPPException;
4372   GetAndSetPPChannelMask(channel_);
4373   newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
4374     exceptionInfo);
4375   RestorePPChannelMask;
4376   replaceImage(newImage);
4377   ThrowImageException;
4378 }
4379
4380 void Magick::Image::splice(const Geometry &geometry_)
4381 {
4382   MagickCore::Image
4383     *newImage;
4384
4385   RectangleInfo
4386     spliceInfo=geometry_;
4387
4388   GetPPException;
4389   newImage=SpliceImage(constImage(),&spliceInfo,exceptionInfo);
4390   replaceImage(newImage);
4391   ThrowImageException;
4392 }
4393
4394 void Magick::Image::splice(const Geometry &geometry_,
4395   const Color &backgroundColor_)
4396 {
4397   backgroundColor(backgroundColor_);
4398   splice(geometry_);
4399 }
4400
4401 void Magick::Image::splice(const Geometry &geometry_,
4402   const Color &backgroundColor_,const GravityType gravity_)
4403 {
4404   backgroundColor(backgroundColor_);
4405   image()->gravity=gravity_;
4406   splice(geometry_);
4407 }
4408
4409 void Magick::Image::spread(const size_t amount_)
4410 {
4411   MagickCore::Image
4412     *newImage;
4413
4414   GetPPException;
4415   newImage=SpreadImage(constImage(),image()->interpolate,amount_,exceptionInfo);
4416   replaceImage(newImage);
4417   ThrowImageException;
4418 }
4419
4420 Magick::ImageStatistics Magick::Image::statistics() const
4421 {
4422   return(ImageStatistics(*this));
4423 }
4424
4425 void Magick::Image::stegano(const Image &watermark_)
4426 {
4427   MagickCore::Image
4428     *newImage;
4429
4430   GetPPException;
4431   newImage=SteganoImage(constImage(),watermark_.constImage(),exceptionInfo);
4432   replaceImage(newImage);
4433   ThrowImageException;
4434 }
4435
4436 void Magick::Image::stereo(const Image &rightImage_)
4437 {
4438   MagickCore::Image
4439     *newImage;
4440
4441   GetPPException;
4442   newImage=StereoImage(constImage(),rightImage_.constImage(),exceptionInfo);
4443   replaceImage(newImage);
4444   ThrowImageException;
4445 }
4446
4447 void Magick::Image::strip(void)
4448 {
4449   modifyImage();
4450   GetPPException;
4451   StripImage(image(),exceptionInfo);
4452   ThrowImageException;
4453 }
4454
4455 Magick::Image Magick::Image::subImageSearch(const Image &reference_,
4456   const MetricType metric_,Geometry *offset_,double *similarityMetric_,
4457   const double similarityThreshold)
4458 {
4459   MagickCore::Image
4460     *newImage;
4461
4462   RectangleInfo
4463     offset;
4464
4465   GetPPException;
4466   newImage=SimilarityImage(image(),reference_.constImage(),metric_,
4467     similarityThreshold,&offset,similarityMetric_,exceptionInfo);
4468   ThrowImageException;
4469   if (offset_ != (Geometry *) NULL)
4470     *offset_=offset;
4471   if (newImage == (MagickCore::Image *) NULL)
4472     return(Magick::Image());
4473   else
4474     return(Magick::Image(newImage));
4475 }
4476
4477 void Magick::Image::swirl(const double degrees_)
4478 {
4479   MagickCore::Image
4480     *newImage;
4481
4482   GetPPException;
4483   newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
4484     exceptionInfo);
4485   replaceImage(newImage);
4486   ThrowImageException;
4487 }
4488
4489 void Magick::Image::syncPixels(void)
4490 {
4491   GetPPException;
4492   (void) SyncAuthenticPixels(image(),exceptionInfo);
4493   ThrowImageException;
4494 }
4495
4496 void Magick::Image::texture(const Image &texture_)
4497 {
4498   modifyImage();
4499   GetPPException;
4500   TextureImage(image(),texture_.constImage(),exceptionInfo);
4501   ThrowImageException;
4502 }
4503
4504 void Magick::Image::threshold(const double threshold_)
4505 {
4506   modifyImage();
4507   GetPPException;
4508   BilevelImage(image(),threshold_,exceptionInfo);
4509   ThrowImageException;
4510 }
4511
4512 void Magick::Image::thumbnail(const Geometry &geometry_)
4513 {
4514   MagickCore::Image
4515     *newImage;
4516
4517   size_t
4518     height=rows(),
4519     width=columns();
4520
4521   ssize_t
4522     x=0,
4523     y=0;
4524
4525   ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4526     &height);
4527
4528   GetPPException;
4529   newImage=ThumbnailImage(constImage(),width,height,exceptionInfo);
4530   replaceImage(newImage);
4531   ThrowImageException;
4532 }
4533
4534 void Magick::Image::tint(const std::string opacity_)
4535 {
4536   MagickCore::Image
4537     *newImage;
4538
4539   PixelInfo
4540     color;
4541
4542   GetPPException;
4543   color=static_cast<PixelInfo>(constOptions()->fillColor());
4544   newImage=TintImage(constImage(),opacity_.c_str(),&color,exceptionInfo);
4545   replaceImage(newImage);
4546   ThrowImageException;
4547 }
4548
4549 void Magick::Image::transform(const Geometry &imageGeometry_)
4550 {
4551   modifyImage();
4552   GetPPException;
4553   TransformImage(&(image()),0,std::string(imageGeometry_).c_str(),
4554     exceptionInfo);
4555   ThrowImageException;
4556 }
4557
4558 void Magick::Image::transform(const Geometry &imageGeometry_,
4559   const Geometry &cropGeometry_)
4560 {
4561   modifyImage();
4562   GetPPException;
4563   TransformImage(&(image()),std::string(cropGeometry_).c_str(),std::string(
4564     imageGeometry_).c_str(), exceptionInfo);
4565   ThrowImageException;
4566 }
4567
4568 void Magick::Image::transformOrigin(const double x_,const double y_)
4569 {
4570   modifyImage();
4571   options()->transformOrigin(x_,y_);
4572 }
4573
4574 void Magick::Image::transformReset(void)
4575 {
4576   modifyImage();
4577   options()->transformReset();
4578 }
4579
4580 void Magick::Image::transformScale(const double sx_,const double sy_)
4581 {
4582   modifyImage();
4583   options()->transformScale(sx_,sy_);
4584 }
4585
4586 void Magick::Image::transparent(const Color &color_)
4587 {
4588   PixelInfo
4589     target;
4590
4591   std::string
4592     color;
4593
4594   if (!color_.isValid())
4595     throwExceptionExplicit(MagickCore::OptionError,
4596       "Color argument is invalid");
4597
4598   color=color_;
4599   GetPPException;
4600   (void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
4601     exceptionInfo);
4602   modifyImage();
4603   TransparentPaintImage(image(),&target,TransparentAlpha,MagickFalse,
4604     exceptionInfo);
4605   ThrowImageException;
4606 }
4607
4608 void Magick::Image::transparentChroma(const Color &colorLow_,
4609   const Color &colorHigh_)
4610 {
4611   std::string
4612     colorHigh,
4613     colorLow;
4614
4615   PixelInfo
4616     targetHigh,
4617     targetLow;
4618
4619   if (!colorLow_.isValid() || !colorHigh_.isValid())
4620     throwExceptionExplicit(MagickCore::OptionError,
4621       "Color argument is invalid");
4622
4623   colorLow=colorLow_;
4624   colorHigh=colorHigh_;
4625
4626   GetPPException;
4627   (void) QueryColorCompliance(colorLow.c_str(),AllCompliance,&targetLow,
4628     exceptionInfo);
4629   (void) QueryColorCompliance(colorHigh.c_str(),AllCompliance,&targetHigh,
4630     exceptionInfo);
4631   modifyImage();
4632   TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
4633     MagickFalse,exceptionInfo);
4634   ThrowImageException;
4635 }
4636
4637 void Magick::Image::transpose(void)
4638 {
4639   MagickCore::Image
4640     *newImage;
4641
4642   GetPPException;
4643   newImage=TransposeImage(constImage(),exceptionInfo);
4644   replaceImage(newImage);
4645   ThrowImageException;
4646 }
4647
4648 void Magick::Image::transverse(void)
4649 {
4650   MagickCore::Image
4651     *newImage;
4652
4653   GetPPException;
4654   newImage=TransverseImage(constImage(),exceptionInfo);
4655   replaceImage(newImage);
4656   ThrowImageException;
4657 }
4658
4659 void Magick::Image::trim(void)
4660 {
4661   MagickCore::Image
4662     *newImage;
4663
4664   GetPPException;
4665   newImage=TrimImage(constImage(),exceptionInfo);
4666   replaceImage(newImage);
4667   ThrowImageException;
4668 }
4669
4670 Magick::Image Magick::Image::uniqueColors(void) const
4671 {
4672   MagickCore::Image
4673     *image;
4674
4675   GetPPException;
4676   image=UniqueImageColors(constImage(),exceptionInfo);
4677   ThrowImageException;
4678   if (image == (MagickCore::Image *) NULL)
4679     return(Magick::Image());
4680   else
4681     return(Magick::Image(image));
4682 }
4683
4684 void Magick::Image::unsharpmask(const double radius_,const double sigma_,
4685   const double amount_,const double threshold_)
4686 {
4687   MagickCore::Image
4688     *newImage;
4689
4690   GetPPException;
4691   newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4692     exceptionInfo);
4693   replaceImage(newImage);
4694   ThrowImageException;
4695 }
4696
4697 void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
4698   const double radius_,const double sigma_,const double amount_,
4699   const double threshold_)
4700 {
4701   MagickCore::Image
4702     *newImage;
4703
4704   GetPPException;
4705   GetAndSetPPChannelMask(channel_);
4706   newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4707     exceptionInfo);
4708   RestorePPChannelMask;
4709   replaceImage(newImage);
4710   ThrowImageException;
4711 }
4712
4713 void Magick::Image::vignette(const double radius_,const double sigma_,
4714   const ssize_t x_,const ssize_t y_)
4715 {
4716   MagickCore::Image
4717     *newImage;
4718
4719   GetPPException;
4720   newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,exceptionInfo);
4721   replaceImage(newImage);
4722   ThrowImageException;
4723 }
4724
4725 void Magick::Image::wave(const double amplitude_,const double wavelength_)
4726 {
4727   MagickCore::Image
4728     *newImage;
4729
4730   GetPPException;
4731   newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
4732     exceptionInfo);
4733   replaceImage(newImage);
4734   ThrowImageException;
4735 }
4736
4737 void Magick::Image::whiteThreshold(const std::string &threshold_)
4738 {
4739   modifyImage();
4740   GetPPException;
4741   WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4742   ThrowImageException;
4743 }
4744
4745 void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
4746   const std::string &threshold_)
4747 {
4748   modifyImage();
4749   GetPPException;
4750   GetAndSetPPChannelMask(channel_);
4751   WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4752   RestorePPChannelMask;
4753   ThrowImageException;
4754 }
4755
4756 void Magick::Image::write(Blob *blob_)
4757 {
4758   size_t
4759     length=0;
4760
4761   void
4762     *data;
4763
4764   modifyImage();
4765   GetPPException;
4766   data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4767   if (length > 0)
4768     blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4769   ThrowImageException;
4770 }
4771
4772 void Magick::Image::write(Blob *blob_,const std::string &magick_)
4773 {
4774   size_t
4775     length=0;
4776
4777   void
4778     *data;
4779
4780   modifyImage();
4781   magick(magick_);
4782   GetPPException;
4783   data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4784   if (length > 0)
4785     blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4786   ThrowImageException;
4787 }
4788
4789 void Magick::Image::write(Blob *blob_,const std::string &magick_,
4790   const size_t depth_)
4791 {
4792   size_t
4793     length=0;
4794
4795   void
4796     *data;
4797
4798   modifyImage();
4799   magick(magick_);
4800   depth(depth_);
4801   GetPPException;
4802   data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4803   if (length > 0)
4804     blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4805   ThrowImageException;
4806 }
4807
4808 void Magick::Image::write(const ssize_t x_,const ssize_t y_,
4809   const size_t columns_,const size_t rows_,const std::string &map_,
4810   const StorageType type_,void *pixels_)
4811 {
4812   GetPPException;
4813   ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
4814     exceptionInfo);
4815   ThrowImageException;
4816 }
4817
4818 void Magick::Image::write(const std::string &imageSpec_)
4819 {
4820   modifyImage();
4821   fileName(imageSpec_);
4822   GetPPException;
4823   WriteImage(constImageInfo(),image(),exceptionInfo);
4824   ThrowImageException;
4825 }
4826
4827 void Magick::Image::writePixels(const Magick::QuantumType quantum_,
4828   unsigned char *destination_)
4829 {
4830   QuantumInfo
4831     *quantum_info;
4832
4833   quantum_info=AcquireQuantumInfo(imageInfo(),image());
4834   GetPPException;
4835   ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4836     quantum_,destination_, exceptionInfo);
4837   quantum_info=DestroyQuantumInfo(quantum_info);
4838   ThrowImageException;
4839 }
4840
4841 void Magick::Image::zoom(const Geometry &geometry_)
4842 {
4843   MagickCore::Image
4844     *newImage;
4845
4846   size_t
4847     height=rows(),
4848     width=columns();
4849
4850   ssize_t
4851     x=0,
4852     y=0;
4853
4854   ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4855     &height);
4856
4857   GetPPException;
4858   newImage=ResizeImage(constImage(),width,height,image()->filter,exceptionInfo);
4859   replaceImage(newImage);
4860   ThrowImageException;
4861 }
4862
4863 Magick::Image::Image(MagickCore::Image *image_)
4864   : _imgRef(new ImageRef(image_))
4865 {
4866 }
4867
4868 MagickCore::Image *&Magick::Image::image(void)
4869 {
4870   return(_imgRef->image());
4871 }
4872
4873 const MagickCore::Image *Magick::Image::constImage(void) const
4874 {
4875   return(_imgRef->image());
4876 }
4877
4878 MagickCore::ImageInfo *Magick::Image::imageInfo(void)
4879 {
4880   return(_imgRef->options()->imageInfo());
4881 }
4882
4883 const MagickCore::ImageInfo *Magick::Image::constImageInfo(void) const
4884 {
4885   return(_imgRef->options()->imageInfo());
4886 }
4887
4888 Magick::Options *Magick::Image::options(void)
4889 {
4890   return(_imgRef->options());
4891 }
4892
4893 const Magick::Options *Magick::Image::constOptions(void) const
4894 {
4895   return(_imgRef->options());
4896 }
4897
4898 MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)
4899 {
4900   return(_imgRef->options()->quantizeInfo());
4901 }
4902
4903 const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
4904 {
4905   return(_imgRef->options()->quantizeInfo());
4906 }
4907
4908 void Magick::Image::modifyImage(void)
4909 {
4910   if (!_imgRef->isShared())
4911     return;
4912
4913   GetPPException;
4914   replaceImage(CloneImage(image(),0,0,MagickTrue,exceptionInfo));
4915   ThrowImageException;
4916 }
4917
4918 MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
4919 {
4920   MagickCore::Image
4921     *image;
4922
4923   if (replacement_)
4924     image=replacement_;
4925   else
4926     {
4927       GetPPException;
4928       image=AcquireImage(constImageInfo(),exceptionInfo);
4929       ThrowImageException;
4930     }
4931
4932   _imgRef=ImageRef::replaceImage(_imgRef,image);
4933   return(image);
4934 }
4935
4936 void Magick::Image::read(MagickCore::Image *image,
4937   MagickCore::ExceptionInfo *exceptionInfo)
4938 {
4939   // Ensure that multiple image frames were not read.
4940   if (image != (MagickCore::Image *) NULL &&
4941       image->next != (MagickCore::Image *) NULL)
4942     {
4943       MagickCore::Image
4944         *next;
4945
4946       // Destroy any extra image frames
4947       next=image->next;
4948       image->next=(MagickCore::Image *) NULL;
4949       next->previous=(MagickCore::Image *) NULL;
4950       DestroyImageList(next);
4951     }
4952   replaceImage(image);
4953   if (exceptionInfo->severity == MagickCore::UndefinedException &&
4954       image == (MagickCore::Image *) NULL)
4955     {
4956       (void) MagickCore::DestroyExceptionInfo(exceptionInfo);
4957       if (!quiet())
4958         throwExceptionExplicit(MagickCore::ImageWarning,
4959           "No image was loaded.");
4960     }
4961   ThrowImageException;
4962 }
4963
4964 void Magick::Image::floodFill(const ssize_t x_,const ssize_t y_,
4965   const Magick::Image *fillPattern_,const Magick::Color &fill_,
4966   const MagickCore::PixelInfo *target_,const bool invert_)
4967 {
4968   Magick::Color
4969     fillColor;
4970
4971   MagickCore::Image
4972     *fillPattern;
4973
4974   // Set drawing fill pattern or fill color
4975   fillColor=options()->fillColor();
4976   fillPattern=(MagickCore::Image *)NULL;
4977   if (options()->fillPattern() != (MagickCore::Image *)NULL)
4978     {
4979       GetPPException;
4980       fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
4981         exceptionInfo);
4982       ThrowImageException;
4983     }
4984
4985   if (fillPattern_ == (Magick::Image *)NULL)
4986     {
4987       options()->fillPattern((MagickCore::Image *)NULL);
4988       options()->fillColor(fill_);
4989     }
4990   else
4991     options()->fillPattern(fillPattern_->constImage());
4992
4993   GetPPException;
4994   (void) FloodfillPaintImage(image(),options()->drawInfo(),
4995     target_,static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),
4996     (MagickBooleanType) invert_,exceptionInfo);
4997
4998   options()->fillColor(fillColor);
4999   options()->fillPattern(fillPattern);
5000   ThrowImageException;
5001 }