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