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