]> granicus.if.org Git - imagemagick/blobdiff - Magick++/lib/Image.cpp
(no commit message)
[imagemagick] / Magick++ / lib / Image.cpp
index c2a6b0401387d2ac2ffc11ceaa0c69c0ca219032..d1d6246908c3c57e9d3b777f7842117eb1feb165 100644 (file)
@@ -8,15 +8,12 @@
 #define MAGICKCORE_IMPLEMENTATION  1
 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
 
-#include "Magick++/Include.h"
 #include <cstdlib>
 #include <string>
 #include <string.h>
 #include <errno.h>
 #include <math.h>
-#if !defined(MAGICKCORE_WINDOWS_SUPPORT)
-#include <strings.h>
-#endif
+#include "Magick++/Include.h"
 
 using namespace std;
 
@@ -27,7 +24,6 @@ using namespace std;
 #include "Magick++/ImageRef.h"
 
 #define AbsoluteValue(x)  ((x) < 0 ? -(x) : (x))
-#define MagickPI  3.14159265358979323846264338327950288419716939937510
 #define DegreesToRadians(x)  (MagickPI*(x)/180.0)
 
 MagickDLLDeclExtern const char *Magick::borderGeometryDefault = "6x6+0+0";
@@ -346,11 +342,12 @@ void Magick::Image::addNoiseChannel( const ChannelType channel_,
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetPixelChannelMask( image(), channel_);
   MagickCore::Image* newImage =
-    AddNoiseImageChannel ( image(),
-                           channel_,
+    AddNoiseImage ( image(),
                            noiseType_,
                            &exceptionInfo );
+  (void) SetPixelChannelMap( image(), channel_mask );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -410,7 +407,7 @@ void Magick::Image::annotate ( const std::string &text_,
   if ( boundingArea_.isValid() ){
     if ( boundingArea_.width() == 0 || boundingArea_.height() == 0 )
       {
-        FormatMagickString( boundingArea, MaxTextExtent, "%+.20g%+.20g",
+        FormatLocaleString( boundingArea, MaxTextExtent, "%+.20g%+.20g",
           (double) boundingArea_.xOff(), (double) boundingArea_.yOff() );
       }
     else
@@ -495,8 +492,10 @@ void Magick::Image::blurChannel( const ChannelType channel_,
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetPixelChannelMask( image(), channel_ );
   MagickCore::Image* newImage =
-    BlurImageChannel( image(), channel_,radius_, sigma_, &exceptionInfo);
+    BlurImage( image(), radius_, sigma_, &exceptionInfo);
+  (void) SetPixelChannelMap( image(), channel_mask );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -520,26 +519,26 @@ void Magick::Image::border( const Geometry &geometry_ )
 void Magick::Image::channel ( const ChannelType channel_ )
 {
   modifyImage();
-  SeparateImageChannel ( image(), channel_ );
+  ChannelType channel_mask = SetPixelChannelMask( image(), channel_ );
+  SeparateImage ( image() );
+  (void) SetPixelChannelMap( image(), channel_mask );
   throwImageException();
 }
 
 // Set or obtain modulus channel depth
-void Magick::Image::channelDepth ( const ChannelType channel_,
-                                   const size_t depth_)
+void Magick::Image::channelDepth ( const size_t depth_ )
 {
   modifyImage();
-  SetImageChannelDepth( image(), channel_, depth_);
+  SetImageDepth( image(), depth_);
   throwImageException();
 }
-size_t Magick::Image::channelDepth ( const ChannelType channel_ )
+size_t Magick::Image::channelDepth ( )
 {
   size_t channel_depth;
 
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  channel_depth=GetImageChannelDepth( constImage(), channel_,
-                                      &exceptionInfo );
+  channel_depth=GetImageDepth( constImage(), &exceptionInfo );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
   return channel_depth;
@@ -576,14 +575,17 @@ void Magick::Image::chop( const Geometry &geometry_ )
 void Magick::Image::cdl ( const std::string &cdl_ )
 {
   modifyImage();
-  (void) ColorDecisionListImage( image(), cdl_.c_str() );
-  throwImageException();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  (void) ColorDecisionListImage( image(), cdl_.c_str(), &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Colorize
-void Magick::Image::colorize ( const unsigned int opacityRed_,
-                               const unsigned int opacityGreen_,
-                               const unsigned int opacityBlue_,
+void Magick::Image::colorize ( const unsigned int alphaRed_,
+                               const unsigned int alphaGreen_,
+                               const unsigned int alphaBlue_,
                               const Color &penColor_ )
 {
   if ( !penColor_.isValid() )
@@ -592,22 +594,22 @@ void Magick::Image::colorize ( const unsigned int opacityRed_,
                            "Pen color argument is invalid");
   }
 
-  char opacity[MaxTextExtent];
-  FormatMagickString(opacity,MaxTextExtent,"%u/%u/%u",opacityRed_,opacityGreen_,opacityBlue_);
+  char alpha[MaxTextExtent];
+  FormatLocaleString(alpha,MaxTextExtent,"%u/%u/%u",alphaRed_,alphaGreen_,alphaBlue_);
 
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-  ColorizeImage ( image(), opacity,
+  ColorizeImage ( image(), alpha,
                  penColor_, &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
-void Magick::Image::colorize ( const unsigned int opacity_,
+void Magick::Image::colorize ( const unsigned int alpha_,
                               const Color &penColor_ )
 {
-  colorize( opacity_, opacity_, opacity_, penColor_ );
+  colorize( alpha_, alpha_, alpha_, penColor_ );
 }
 
 // Apply a color matrix to the image channels.  The user supplied
@@ -620,7 +622,7 @@ void Magick::Image::colorMatrix (const size_t order_,
 
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-    kernel_info=AcquireKernelInfo("1");
+  kernel_info=AcquireKernelInfo((const char *) NULL);
   kernel_info->width=order_;
   kernel_info->height=order_;
   kernel_info->values=(double *) color_matrix_;
@@ -704,8 +706,11 @@ void Magick::Image::composite ( const Image &compositeImage_,
 void Magick::Image::contrast ( const size_t sharpen_ )
 {
   modifyImage();
-  ContrastImage ( image(), (MagickBooleanType) sharpen_ );
-  throwImageException();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  ContrastImage ( image(), (MagickBooleanType) sharpen_, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Convolve image.  Applies a general image convolution kernel to the image.
@@ -714,11 +719,20 @@ void Magick::Image::contrast ( const size_t sharpen_ )
 void Magick::Image::convolve ( const size_t order_,
                                const double *kernel_ )
 {
+  KernelInfo
+    *kernel_info;
+
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
+  kernel_info=AcquireKernelInfo((const char *) NULL);
+  kernel_info->width=order_;
+  kernel_info->height=order_;
+  kernel_info->values=(double *) kernel_;
+  kernel_info->bias=image()->bias;
   MagickCore::Image* newImage =
-  ConvolveImage ( image(), order_,
-                 kernel_, &exceptionInfo );
+    ConvolveImage ( image(), kernel_info, &exceptionInfo );
+  kernel_info->values=(double *) NULL;
+  kernel_info=DestroyKernelInfo(kernel_info);
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -869,9 +883,11 @@ void Magick::Image::enhance ( void )
 // Equalize image (histogram equalization)
 void Magick::Image::equalize ( void )
 {
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   modifyImage();
-  EqualizeImage( image() );
-  throwImageException();
+  EqualizeImage( image(), &exceptionInfo );
+  throwException( exceptionInfo );
 }
 
 // Erase image to current "background color"
@@ -960,27 +976,30 @@ void Magick::Image::floodFillColor( const Geometry &point_,
 }
 
 // Floodfill pixels matching color (within fuzz factor) of target
-// pixel(x,y) with replacement opacity value using method.
+// pixel(x,y) with replacement alpha value using method.
 void Magick::Image::floodFillOpacity( const ssize_t x_,
                                       const ssize_t y_,
-                                      const unsigned int opacity_,
+                                      const unsigned int alpha_,
                                       const PaintMethod method_ )
 {
   modifyImage();
-  MagickPixelPacket target;
-  GetMagickPixelPacket(image(),&target);
+  PixelInfo target;
+  GetPixelInfo(image(),&target);
   PixelPacket pixel=static_cast<PixelPacket>(pixelColor(x_,y_));
   target.red=pixel.red;
   target.green=pixel.green;
   target.blue=pixel.blue;
-  target.opacity=opacity_;
+  target.alpha=alpha_;
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   FloodfillPaintImage ( image(),
-                        DefaultChannels,
                         options()->drawInfo(), // const DrawInfo *draw_info
                         &target,
                                        static_cast<ssize_t>(x_), static_cast<ssize_t>(y_),
-                        method_  == FloodfillMethod ? MagickFalse : MagickTrue);
-  throwImageException();
+                        method_  == FloodfillMethod ? MagickFalse : MagickTrue,
+    &exceptionInfo);
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Flood-fill texture across pixels that match the color of the
@@ -998,23 +1017,25 @@ void Magick::Image::floodFillTexture( const ssize_t x_,
   // Get pixel view
   Pixels pixels(*this);
   // Fill image
-  PixelPacket *p = pixels.get(x_, y_, 1, 1 );
-  MagickPixelPacket target;
-  GetMagickPixelPacket(constImage(),&target);
-  target.red=p->red;
-  target.green=p->green;
-  target.blue=p->blue;
+  Quantum *p = pixels.get(x_, y_, 1, 1 );
+  PixelInfo target;
+  GetPixelInfo(constImage(),&target);
+  target.red=GetPixelRed(constImage(),p);
+  target.green=GetPixelGreen(constImage(),p);
+  target.blue=GetPixelBlue(constImage(),p);
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   if (p)
     FloodfillPaintImage ( image(), // Image *image
-                          DefaultChannels,
                           options()->drawInfo(), // const DrawInfo *draw_info
                           &target, // const MagickPacket target
                           static_cast<ssize_t>(x_), // const ssize_t x_offset
                           static_cast<ssize_t>(y_), // const ssize_t y_offset
-                          MagickFalse // const PaintMethod method
-      );
+                          MagickFalse, // const PaintMethod method
+      &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 
-  throwImageException();
 }
 void Magick::Image::floodFillTexture( const Magick::Geometry &point_,
                                      const Magick::Image &texture_ )
@@ -1035,20 +1056,22 @@ void Magick::Image::floodFillTexture( const ssize_t x_,
   // Set drawing fill pattern
   options()->fillPattern(texture_.constImage());
 
-  MagickPixelPacket target;
-  GetMagickPixelPacket(constImage(),&target);
+  PixelInfo target;
+  GetPixelInfo(constImage(),&target);
   target.red=static_cast<PixelPacket>(borderColor_).red;
   target.green=static_cast<PixelPacket>(borderColor_).green;
   target.blue=static_cast<PixelPacket>(borderColor_).blue;
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   FloodfillPaintImage ( image(),
-                        DefaultChannels,
                         options()->drawInfo(),
                         &target,
                         static_cast<ssize_t>(x_),
                         static_cast<ssize_t>(y_),
-                        MagickTrue);
+                        MagickTrue, &exceptionInfo);
 
-  throwImageException();
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 void  Magick::Image::floodFillTexture( const Magick::Geometry &point_,
                                       const Magick::Image &texture_,
@@ -1069,29 +1092,6 @@ void Magick::Image::flop ( void )
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
-// Implements the discrete Fourier transform (DFT) of the image either as a
-// magnitude / phase or real / imaginary image pair.
-void Magick::Image::forwardFourierTransform ( void )
-{
-  ExceptionInfo exceptionInfo;
-  GetExceptionInfo( &exceptionInfo );
-  MagickCore::Image* newImage = ForwardFourierTransformImage ( image(),
-    MagickTrue, &exceptionInfo );
-  replaceImage( newImage );
-  throwException( exceptionInfo );
-  (void) DestroyExceptionInfo( &exceptionInfo );
-}
-void Magick::Image::forwardFourierTransform ( const bool magnitude_ )
-{
-  ExceptionInfo exceptionInfo;
-  GetExceptionInfo( &exceptionInfo );
-  MagickCore::Image* newImage = ForwardFourierTransformImage ( image(),
-    magnitude_ == true ? MagickTrue : MagickFalse, &exceptionInfo );
-  replaceImage( newImage );
-  throwException( exceptionInfo );
-  (void) DestroyExceptionInfo( &exceptionInfo );
-}
-
 // Frame image
 void Magick::Image::frame ( const Geometry &geometry_ )
 {
@@ -1139,7 +1139,7 @@ void Magick::Image::fx ( const std::string expression )
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    FxImageChannel ( image(), DefaultChannels, expression.c_str(), &exceptionInfo );
+    FxImage ( image(), expression.c_str(), &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -1149,8 +1149,10 @@ void Magick::Image::fx ( const std::string expression,
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetPixelChannelMask( image(), channel );
   MagickCore::Image* newImage =
-    FxImageChannel ( image(), channel, expression.c_str(), &exceptionInfo );
+    FxImage ( image(), expression.c_str(), &exceptionInfo );
+  (void) SetPixelChannelMap( image(), channel_mask );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -1159,11 +1161,12 @@ void Magick::Image::fx ( const std::string expression,
 // Gamma correct image
 void Magick::Image::gamma ( const double gamma_ )
 {
-  char gamma[MaxTextExtent + 1];
-  FormatMagickString( gamma, MaxTextExtent, "%3.6f", gamma_);
-
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   modifyImage();
-  GammaImage ( image(), gamma );
+  GammaImage ( image(), gamma_, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 void Magick::Image::gamma ( const double gammaRed_,
@@ -1171,12 +1174,15 @@ void Magick::Image::gamma ( const double gammaRed_,
                            const double gammaBlue_ )
 {
   char gamma[MaxTextExtent + 1];
-  FormatMagickString( gamma, MaxTextExtent, "%3.6f/%3.6f/%3.6f/",
+  FormatLocaleString( gamma, MaxTextExtent, "%3.6f/%3.6f/%3.6f/",
                gammaRed_, gammaGreen_, gammaBlue_);
 
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   modifyImage();
-  GammaImage ( image(), gamma );
-  throwImageException();
+  GammaImage ( image(), atof(gamma), &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Gaussian blur image
@@ -1200,8 +1206,10 @@ void Magick::Image::gaussianBlurChannel ( const ChannelType channel_,
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetPixelChannelMask( image(), channel_ );
   MagickCore::Image* newImage =
-    GaussianBlurImageChannel( image(), channel_, width_, sigma_, &exceptionInfo );
+    GaussianBlurImage( image(), width_, sigma_, &exceptionInfo );
+  (void) SetPixelChannelMap( image(), channel_mask );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -1210,9 +1218,12 @@ void Magick::Image::gaussianBlurChannel ( const ChannelType channel_,
 // Apply a color lookup table (Hald CLUT) to the image.
 void  Magick::Image::haldClut ( const Image &clutImage_ )
 {
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   modifyImage();
-  (void) HaldClutImage( image(), clutImage_.constImage() );
-  throwImageException();
+  (void) HaldClutImage( image(), clutImage_.constImage(), &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Implode image
@@ -1266,33 +1277,12 @@ void Magick::Image::level ( const double black_point,
                             const double white_point,
                             const double gamma )
 {
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   modifyImage();
-  char levels[MaxTextExtent];
-  FormatMagickString( levels, MaxTextExtent, "%g,%g,%g",black_point,white_point,gamma);
-  (void) LevelImage( image(), levels );
-  throwImageException();
-}
-
-// Level image channel. Adjust the levels of the image channel by
-// scaling the values falling between specified white and black points
-// to the full available quantum range. The parameters provided
-// represent the black, mid (gamma), and white points.  The black
-// point specifies the darkest color in the image. Colors darker than
-// the black point are set to zero. Mid point (gamma) specifies a
-// gamma correction to apply to the image. White point specifies the
-// lightest color in the image.  Colors brighter than the white point
-// are set to the maximum quantum value. The black and white point
-// have the valid range 0 to QuantumRange while gamma has a useful range of
-// 0 to ten.
-void  Magick::Image::levelChannel ( const Magick::ChannelType channel,
-                                    const double black_point,
-                                    const double white_point,
-                                    const double gamma )
-{
-  modifyImage();
-  (void) LevelImageChannel( image(), channel, black_point, white_point,
-                            gamma );
-  throwImageException();
+  (void) LevelImage( image(), black_point, white_point, gamma, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Magnify image by integral size
@@ -1316,22 +1306,27 @@ void Magick::Image::map ( const Image &mapImage_ , const bool dither_ )
              mapImage_.constImage());
   throwImageException();
 }
-// Floodfill designated area with replacement opacity value
+// Floodfill designated area with replacement alpha value
 void Magick::Image::matteFloodfill ( const Color &target_ ,
-                                    const unsigned int opacity_,
+                                    const unsigned int alpha_,
                                     const ssize_t x_, const ssize_t y_,
                                     const Magick::PaintMethod method_ )
 {
   modifyImage();
-  MagickPixelPacket target;
-  GetMagickPixelPacket(constImage(),&target);
+  PixelInfo target;
+  GetPixelInfo(constImage(),&target);
   target.red=static_cast<PixelPacket>(target_).red;
   target.green=static_cast<PixelPacket>(target_).green;
   target.blue=static_cast<PixelPacket>(target_).blue;
-  target.opacity=opacity_;
-  FloodfillPaintImage ( image(), OpacityChannel, options()->drawInfo(), &target,
-    x_, y_, method_ == FloodfillMethod ? MagickFalse : MagickTrue);
-  throwImageException();
+  target.alpha=alpha_;
+  ChannelType channel_mask = SetPixelChannelMask( image(), AlphaChannel );
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  FloodfillPaintImage ( image(), options()->drawInfo(), &target, x_, y_,
+    method_ == FloodfillMethod ? MagickFalse : MagickTrue, &exceptionInfo);
+  (void) SetPixelChannelMap( image(), channel_mask );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Filter image by replacing each pixel component with the median
@@ -1341,7 +1336,8 @@ void Magick::Image::medianFilter ( const double radius_ )
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    MedianFilterImage ( image(), radius_, &exceptionInfo );
+    StatisticImage ( image(), MedianStatistic, (size_t) radius_, (size_t)
+    radius_,&exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -1365,12 +1361,15 @@ void Magick::Image::modulate ( const double brightness_,
                               const double hue_ )
 {
   char modulate[MaxTextExtent + 1];
-  FormatMagickString( modulate, MaxTextExtent, "%3.6f,%3.6f,%3.6f",
+  FormatLocaleString( modulate, MaxTextExtent, "%3.6f,%3.6f,%3.6f",
                brightness_, saturation_, hue_);
 
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   modifyImage();
-  ModulateImage( image(), modulate );
-  throwImageException();
+  ModulateImage( image(), modulate, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Motion blur image with specified blur factor
@@ -1396,41 +1395,48 @@ void            Magick::Image::motionBlur ( const double radius_,
 // only
 void Magick::Image::negate ( const bool grayscale_ )
 {
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   modifyImage();
-  NegateImage ( image(), grayscale_ == true ? MagickTrue : MagickFalse );
-  throwImageException();
+  NegateImage ( image(), grayscale_ == true ? MagickTrue : MagickFalse, 
+    &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Normalize image
 void Magick::Image::normalize ( void )
 {
   modifyImage();
-  NormalizeImage ( image() );
-  throwImageException();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  NormalizeImage ( image(), &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Oilpaint image
-void Magick::Image::oilPaint ( const double radius_ )
+void Magick::Image::oilPaint ( const double radius_, const double sigma_ )
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    OilPaintImage( image(), radius_, &exceptionInfo );
+    OilPaintImage( image(), radius_, sigma_, &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
-// Set or attenuate the opacity channel. If the image pixels are
-// opaque then they are set to the specified opacity value, otherwise
-// they are blended with the supplied opacity value.  The value of
-// opacity_ ranges from 0 (completely opaque) to QuantumRange. The defines
-// OpaqueOpacity and TransparentOpacity are available to specify
+// Set or attenuate the alpha channel. If the image pixels are
+// opaque then they are set to the specified alpha value, otherwise
+// they are blended with the supplied alpha value.  The value of
+// alpha_ ranges from 0 (completely opaque) to QuantumRange. The defines
+// OpaqueAlpha and TransparentAlpha are available to specify
 // completely opaque or completely transparent, respectively.
-void Magick::Image::opacity ( const unsigned int opacity_ )
+void Magick::Image::alpha ( const unsigned int alpha_ )
 {
   modifyImage();
-  SetImageOpacity( image(), opacity_ );
+  SetImageOpacity( image(), alpha_ );
 }
 
 // Change the color of an opaque pixel to the pen color.
@@ -1452,12 +1458,15 @@ void Magick::Image::opaque ( const Color &opaqueColor_,
   std::string opaqueColor = opaqueColor_;
   std::string penColor = penColor_;
 
-  MagickPixelPacket opaque;
-  MagickPixelPacket pen;
-  (void) QueryMagickColor(std::string(opaqueColor_).c_str(),&opaque,&image()->exception);
-  (void) QueryMagickColor(std::string(penColor_).c_str(),&pen,&image()->exception);
-  OpaquePaintImage ( image(), &opaque, &pen, MagickFalse );
-  throwImageException();
+  PixelInfo opaque;
+  PixelInfo pen;
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  (void) QueryMagickColor(std::string(opaqueColor_).c_str(),&opaque, &exceptionInfo);
+  (void) QueryMagickColor(std::string(penColor_).c_str(),&pen, &exceptionInfo);
+  OpaquePaintImage ( image(), &opaque, &pen, MagickFalse, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Ping is similar to read except only enough of the image is read to
@@ -1530,7 +1539,9 @@ void Magick::Image::quantumOperator ( const ChannelType channel_,
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  EvaluateImageChannel( image(), channel_, operator_, rvalue_, &exceptionInfo);
+  ChannelType channel_mask = SetPixelChannelMask( image(), channel_ );
+  EvaluateImage( image(), operator_, rvalue_, &exceptionInfo);
+  (void) SetPixelChannelMap( image(), channel_mask );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
@@ -1551,8 +1562,9 @@ void Magick::Image::quantumOperator ( const ssize_t x_,const ssize_t y_,
   geometry.y = y_;
   MagickCore::Image *crop_image = CropImage( image(), &geometry,
     &exceptionInfo );
-  EvaluateImageChannel( crop_image, channel_, operator_, rvalue_,
-    &exceptionInfo );
+  ChannelType channel_mask = SetPixelChannelMask( image(), channel_);
+  EvaluateImage( crop_image, operator_, rvalue_, &exceptionInfo );
+  (void) SetPixelChannelMap( image(), channel_mask );
   (void) CompositeImage( image(), image()->matte != MagickFalse ?
     OverCompositeOp : CopyCompositeOp, crop_image, geometry.x, geometry.y );
   crop_image = DestroyImageList(crop_image);
@@ -1565,10 +1577,13 @@ void Magick::Image::quantumOperator ( const ssize_t x_,const ssize_t y_,
 void Magick::Image::raise ( const Geometry &geometry_ ,
                            const bool raisedFlag_ )
 {
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   RectangleInfo raiseInfo = geometry_;
   modifyImage();
-  RaiseImage ( image(), &raiseInfo, raisedFlag_ == true ? MagickTrue : MagickFalse );
-  throwImageException();
+  RaiseImage ( image(), &raiseInfo, raisedFlag_ == true ? MagickTrue : MagickFalse, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 
@@ -1592,10 +1607,11 @@ void Magick::Image::randomThresholdChannel( const Geometry &thresholds_,
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   modifyImage();
-  (void) RandomThresholdImageChannel( image(),
-                                      channel_,
+  ChannelType channel_mask = SetPixelChannelMask( image(), channel_);
+  (void) RandomThresholdImage( image(),
                                       static_cast<std::string>(thresholds_).c_str(),
                                       &exceptionInfo );
+  (void) SetPixelChannelMap( image(), channel_mask );
   throwImageException();
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
@@ -1732,7 +1748,8 @@ void Magick::Image::reduceNoise ( const double order_ )
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    ReduceNoiseImage( image(), order_, &exceptionInfo );
+    StatisticImage( image(), NonpeakStatistic, (size_t) order_, (size_t) order_,
+    &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -1907,12 +1924,13 @@ void Magick::Image::sharpenChannel ( const ChannelType channel_,
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetPixelChannelMask( image(), channel_ );
   MagickCore::Image* newImage =
-    SharpenImageChannel( image(),
-                         channel_,
+    SharpenImage( image(),
                          radius_,
                          sigma_,
                          &exceptionInfo );
+  (void) SetPixelChannelMap( image(), channel_mask );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -1952,9 +1970,12 @@ void Magick::Image::shear ( const double xShearAngle_,
 // Contrast image
 void Magick::Image::sigmoidalContrast ( const size_t sharpen_, const double contrast, const double midpoint )
 {
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   modifyImage();
-  (void) SigmoidalContrastImageChannel( image(), DefaultChannels, (MagickBooleanType) sharpen_, contrast, midpoint );
-  throwImageException();
+  (void) SigmoidalContrastImage( image(), (MagickBooleanType) sharpen_, contrast, midpoint, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Solarize image (similar to effect seen when exposing a photographic
@@ -1976,8 +1997,11 @@ void Magick::Image::sparseColor ( const ChannelType channel,
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  MagickCore::Image* newImage = SparseColorImage ( image(), channel, method,
+
+  ChannelType channel_mask = SetPixelChannelMask( image(), channel );
+  MagickCore::Image* newImage = SparseColorImage ( image(), method,
     number_arguments, arguments, &exceptionInfo );
+  (void) SetPixelChannelMap( image(), channel_mask );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -2083,11 +2107,15 @@ void Magick::Image::transparent ( const Color &color_ )
 
   std::string color = color_;
 
-  MagickPixelPacket target;
+  PixelInfo target;
   (void) QueryMagickColor(std::string(color_).c_str(),&target,&image()->exception);
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   modifyImage();
-  TransparentPaintImage ( image(), &target, TransparentOpacity, MagickFalse );
-  throwImageException();
+  TransparentPaintImage ( image(), &target, TransparentAlpha, MagickFalse,
+    &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Add matte image to image, setting pixels matching color to transparent
@@ -2103,16 +2131,19 @@ void Magick::Image::transparentChroma(const Color &colorLow_,
   std::string colorLow = colorLow_;
   std::string colorHigh = colorHigh_;
 
-  MagickPixelPacket targetLow;
-  MagickPixelPacket targetHigh;
+  PixelInfo targetLow;
+  PixelInfo targetHigh;
   (void) QueryMagickColor(std::string(colorLow_).c_str(),&targetLow,
     &image()->exception);
   (void) QueryMagickColor(std::string(colorHigh_).c_str(),&targetHigh,
     &image()->exception);
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   modifyImage();
   TransparentPaintImageChroma ( image(), &targetLow, &targetHigh,
-    TransparentOpacity, MagickFalse );
-  throwImageException();
+    TransparentAlpha, MagickFalse, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 
@@ -2167,14 +2198,15 @@ void Magick::Image::unsharpmaskChannel ( const ChannelType channel_,
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetPixelChannelMask( image(), channel_ );
   MagickCore::Image* newImage =
-    UnsharpMaskImageChannel( image(),
-                             channel_,
+    UnsharpMaskImage( image(),
                              radius_,
                              sigma_,
                              amount_,
                              threshold_,
                              &exceptionInfo );
+  (void) SetPixelChannelMap( image(), channel_mask );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -2198,10 +2230,13 @@ void Magick::Image::wave ( const double amplitude_, const double wavelength_ )
 // Write image to file
 void Magick::Image::write( const std::string &imageSpec_ )
 {
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   modifyImage();
   fileName( imageSpec_ );
-  WriteImage( imageInfo(), image() );
-  throwImageException();
+  WriteImage( imageInfo(), image(), &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Write image to in-memory BLOB
@@ -2679,10 +2714,12 @@ void Magick::Image::colorSpace( const ColorspaceType colorSpace_ )
   modifyImage();
 
   if ( colorSpace_ != RGBColorspace &&
+       colorSpace_ != sRGBColorspace &&
        colorSpace_ != TransparentColorspace &&
        colorSpace_ != GRAYColorspace )
     {
       if (image()->colorspace != RGBColorspace &&
+          image()->colorspace != sRGBColorspace &&
           image()->colorspace != TransparentColorspace &&
           image()->colorspace != GRAYColorspace)
         {
@@ -2697,6 +2734,7 @@ void Magick::Image::colorSpace( const ColorspaceType colorSpace_ )
     }
 
   if ( colorSpace_ == RGBColorspace ||
+       colorSpace_ == sRGBColorspace ||
        colorSpace_ == TransparentColorspace ||
        colorSpace_ == GRAYColorspace )
     {
@@ -3223,7 +3261,7 @@ void Magick::Image::matte ( const bool matteFlag_ )
   // desired, then set the matte channel to opaque.
   if ((matteFlag_ && !constImage()->matte) ||
       (constImage()->matte && !matteFlag_))
-    SetImageOpacity(image(),OpaqueOpacity);
+    SetImageOpacity(image(),OpaqueAlpha);
 
   image()->matte = (MagickBooleanType) matteFlag_;
 }
@@ -3385,7 +3423,9 @@ void Magick::Image::pixelColor ( const ssize_t x_, const ssize_t y_,
   // Get pixel view
   Pixels pixels(*this);
     // Set pixel value
-  *(pixels.get(x_, y_, 1, 1 )) = color_;
+  Quantum *pixel = pixels.get(x_, y_, 1, 1 );
+  PixelPacket packet = color_;
+  MagickCore::SetPixelPacket(constImage(),&packet,pixel);
   // Tell ImageMagick that pixels have been updated
   pixels.sync();
 
@@ -3399,19 +3439,12 @@ Magick::Color Magick::Image::pixelColor ( const ssize_t x_,
   ClassType storage_class;
   storage_class = classType();
   // DirectClass
-  const PixelPacket* pixel = getConstPixels( x_, y_, 1, 1 );
-  if ( storage_class == DirectClass )
-    {
-      if ( pixel )
-        return Color( *pixel );
-    }
-
-  // PseudoClass
-  if ( storage_class == PseudoClass )
+  const Quantum* pixel = getConstPixels( x_, y_, 1, 1 );
+  if ( pixel )
     {
-      const IndexPacket* indexes = getConstIndexes();
-      if ( indexes )
-        return colorMap( (size_t) *indexes );
+      PixelPacket packet;
+      MagickCore::GetPixelPacket(constImage(),pixel,&packet);
+      return Color( packet );
     }
 
   return Color(); // invalid
@@ -3599,7 +3632,7 @@ void Magick::Image::splice( const Geometry &geometry_ )
 // Obtain image statistics. Statistics are normalized to the range of
 // 0.0 to 1.0 and are output to the specified ImageStatistics
 // structure.
-void Magick::Image::statistics ( ImageStatistics *statistics ) const
+void Magick::Image::statistics ( ImageStatistics *statistics ) 
 {
   double
     maximum,
@@ -3607,44 +3640,59 @@ void Magick::Image::statistics ( ImageStatistics *statistics ) const
 
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  (void) GetImageChannelRange(constImage(),RedChannel,&minimum,&maximum,
-    &exceptionInfo);
+
+  ChannelType channel_mask = SetPixelChannelMask( image(), RedChannel);
+  (void) GetImageRange( image(),&minimum,&maximum,&exceptionInfo);
   statistics->red.minimum=minimum;
-       statistics->red.maximum=maximum;
-  (void) GetImageChannelMean(constImage(),RedChannel,
-    &statistics->red.mean,&statistics->red.standard_deviation,&exceptionInfo);
-  (void) GetImageChannelKurtosis(constImage(),RedChannel,
-    &statistics->red.kurtosis,&statistics->red.skewness,&exceptionInfo);
-  (void) GetImageChannelRange(constImage(),GreenChannel,&minimum,&maximum,
-    &exceptionInfo);
+  statistics->red.maximum=maximum;
+  (void) GetImageMean( image(),&statistics->red.mean,
+    &statistics->red.standard_deviation,&exceptionInfo);
+  (void) GetImageKurtosis( image(),&statistics->red.kurtosis,
+    &statistics->red.skewness,&exceptionInfo);
+  (void) SetPixelChannelMap( image(), channel_mask );
+
+  channel_mask = SetPixelChannelMask( image(), GreenChannel);
+  (void) GetImageRange( image(),&minimum,&maximum,&exceptionInfo);
   statistics->green.minimum=minimum;
-       statistics->green.maximum=maximum;
-  (void) GetImageChannelMean(constImage(),GreenChannel,
-    &statistics->green.mean,&statistics->green.standard_deviation,
-    &exceptionInfo);
-  (void) GetImageChannelKurtosis(constImage(),GreenChannel,
-    &statistics->green.kurtosis,&statistics->green.skewness,&exceptionInfo);
-  (void) GetImageChannelRange(constImage(),BlueChannel,&minimum,&maximum,
-    &exceptionInfo);
+  statistics->green.maximum=maximum;
+  (void) GetImageMean( image(),&statistics->green.mean,
+    &statistics->green.standard_deviation,&exceptionInfo);
+  (void) GetImageKurtosis( image(),&statistics->green.kurtosis,
+    &statistics->green.skewness,&exceptionInfo);
+  (void) SetPixelChannelMap( image(), channel_mask );
+
+  channel_mask = SetPixelChannelMask( image(), GreenChannel);
+  (void) GetImageRange( image(),&minimum,&maximum,&exceptionInfo);
   statistics->blue.minimum=minimum;
-       statistics->blue.maximum=maximum;
-  (void) GetImageChannelMean(constImage(),BlueChannel,
-    &statistics->blue.mean,&statistics->blue.standard_deviation,&exceptionInfo);
-  (void) GetImageChannelKurtosis(constImage(),BlueChannel,
-    &statistics->blue.kurtosis,&statistics->blue.skewness,&exceptionInfo);
-  (void) GetImageChannelRange(constImage(),OpacityChannel,&minimum,&maximum,
-    &exceptionInfo);
-  statistics->opacity.minimum=minimum;
-       statistics->opacity.maximum=maximum;
-  (void) GetImageChannelMean(constImage(),OpacityChannel,
-    &statistics->opacity.mean,&statistics->opacity.standard_deviation,
-    &exceptionInfo);
-  (void) GetImageChannelKurtosis(constImage(),OpacityChannel,
-    &statistics->opacity.kurtosis,&statistics->opacity.skewness,&exceptionInfo);
+  statistics->blue.maximum=maximum;
+  (void) GetImageMean( image(),&statistics->blue.mean,
+    &statistics->blue.standard_deviation,&exceptionInfo);
+  (void) GetImageKurtosis( image(),&statistics->blue.kurtosis,
+    &statistics->blue.skewness,&exceptionInfo);
+  (void) SetPixelChannelMap( image(), channel_mask );
+
+  channel_mask = SetPixelChannelMask( image(), AlphaChannel);
+  (void) GetImageRange( image(),&minimum,&maximum,&exceptionInfo);
+  statistics->alpha.minimum=minimum;
+  statistics->alpha.maximum=maximum;
+  (void) GetImageMean( image(),&statistics->alpha.mean,
+    &statistics->alpha.standard_deviation,&exceptionInfo);
+  (void) GetImageKurtosis( image(),&statistics->alpha.kurtosis,
+    &statistics->alpha.skewness,&exceptionInfo);
+  (void) SetPixelChannelMap( image(), channel_mask );
+
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
+// Strip strips an image of all profiles and comments.
+void Magick::Image::strip ( void )
+{
+  modifyImage();
+  StripImage( image() );
+  throwImageException();
+}
+
 // enabled/disable stroke anti-aliasing
 void Magick::Image::strokeAntiAlias ( const bool flag_ )
 {
@@ -3808,16 +3856,6 @@ std::string Magick::Image::textEncoding ( void ) const
   return constOptions()->textEncoding( );
 }
 
-void Magick::Image::tileName ( const std::string &tileName_ )
-{
-  modifyImage();
-  options()->tileName( tileName_ );
-}
-std::string Magick::Image::tileName ( void ) const
-{
-  return constOptions()->tileName( );
-}
-
 size_t Magick::Image::totalColors ( void )
 {
   ExceptionInfo exceptionInfo;
@@ -3993,14 +4031,14 @@ Magick::Image& Magick::Image::operator=( const Magick::Image &image_ )
 
 // Transfers read-only pixels from the image to the pixel cache as
 // defined by the specified region
-const Magick::PixelPacket* Magick::Image::getConstPixels
+const Magick::Quantum* Magick::Image::getConstPixels
   ( const ssize_t x_, const ssize_t y_,
     const size_t columns_,
     const size_t rows_ ) const
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  const PixelPacket* p = (*GetVirtualPixels)( constImage(),
+  const Quantum* p = (*GetVirtualPixels)( constImage(),
                                                 x_, y_,
                                                 columns_, rows_,
                                                 &exceptionInfo );
@@ -4009,10 +4047,10 @@ const Magick::PixelPacket* Magick::Image::getConstPixels
   return p;
 }
 
-// Obtain read-only pixel indexes (valid for PseudoClass images)
-const Magick::IndexPacket* Magick::Image::getConstIndexes ( void ) const
+// Obtain read-only pixel associated pixels channels
+const void* Magick::Image::getConstMetacontent ( void ) const
 {
-  const Magick::IndexPacket* result = GetVirtualIndexQueue( constImage() );
+  const void* result = GetVirtualMetacontent( constImage() );
 
   if( !result )
     throwImageException();
@@ -4020,10 +4058,10 @@ const Magick::IndexPacket* Magick::Image::getConstIndexes ( void ) const
   return result;
 }
 
-// Obtain image pixel indexes (valid for PseudoClass images)
-Magick::IndexPacket* Magick::Image::getIndexes ( void )
+// Obtain image pixel associated pixels channels
+void* Magick::Image::getMetacontent ( void )
 {
-  Magick::IndexPacket* result = GetAuthenticIndexQueue( image() );
+  void* result = GetAuthenticMetacontent( image() );
 
   if( !result )
     throwImageException();
@@ -4034,14 +4072,14 @@ Magick::IndexPacket* Magick::Image::getIndexes ( void )
 // Transfers pixels from the image to the pixel cache as defined
 // by the specified region. Modified pixels may be subsequently
 // transferred back to the image via syncPixels.
-Magick::PixelPacket* Magick::Image::getPixels ( const ssize_t x_, const ssize_t y_,
+Magick::Quantum* Magick::Image::getPixels ( const ssize_t x_, const ssize_t y_,
                                                const size_t columns_,
                                                const size_t rows_ )
 {
   modifyImage();
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  PixelPacket* result = (*GetAuthenticPixels)( image(),
+  Quantum* result = (*GetAuthenticPixels)( image(),
                                            x_, y_,
                                            columns_, rows_, &exceptionInfo );
   throwException( exceptionInfo );
@@ -4053,14 +4091,14 @@ Magick::PixelPacket* Magick::Image::getPixels ( const ssize_t x_, const ssize_t
 // Allocates a pixel cache region to store image pixels as defined
 // by the region rectangle.  This area is subsequently transferred
 // from the pixel cache to the image via syncPixels.
-Magick::PixelPacket* Magick::Image::setPixels ( const ssize_t x_, const ssize_t y_,
+Magick::Quantum* Magick::Image::setPixels ( const ssize_t x_, const ssize_t y_,
                                                const size_t columns_,
                                                const size_t rows_ )
 {
   modifyImage();
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  PixelPacket* result = (*QueueAuthenticPixels)( image(),
+  Quantum* result = (*QueueAuthenticPixels)( image(),
                                            x_, y_,
                                            columns_, rows_, &exceptionInfo );
   throwException( exceptionInfo );