]> granicus.if.org Git - imagemagick/blobdiff - Magick++/lib/Image.cpp
(no commit message)
[imagemagick] / Magick++ / lib / Image.cpp
index 55fb936274895779a25a826f23790f080aa21b7f..4daa9c0b2f42fab402679384d67afda74ba735a9 100644 (file)
@@ -14,9 +14,6 @@
 #include <string.h>
 #include <errno.h>
 #include <math.h>
-#if !defined(MAGICKCORE_WINDOWS_SUPPORT)
-#include <strings.h>
-#endif
 
 using namespace std;
 
@@ -27,12 +24,11 @@ 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";
-MagickDLLDeclExtern const char *Magick::frameGeometryDefault  = "25x25+6+6";
-MagickDLLDeclExtern const char *Magick::raiseGeometryDefault  = "6x6+0+0";
+MagickPPExport const char *Magick::borderGeometryDefault = "6x6+0+0";
+MagickPPExport const char *Magick::frameGeometryDefault  = "25x25+6+6";
+MagickPPExport const char *Magick::raiseGeometryDefault  = "6x6+0+0";
 
 static bool magick_initialized=false;
 
@@ -44,7 +40,7 @@ static bool magick_initialized=false;
 // Friend functions to compare Image objects
 //
 
-MagickDLLDecl int Magick::operator == ( const Magick::Image& left_,
+MagickPPExport int Magick::operator == ( const Magick::Image& left_,
                                         const Magick::Image& right_ )
 {
   // If image pixels and signature are the same, then the image is identical
@@ -53,17 +49,17 @@ MagickDLLDecl int Magick::operator == ( const Magick::Image& left_,
           ( left_.signature() == right_.signature() )
           );
 }
-MagickDLLDecl int Magick::operator != ( const Magick::Image& left_,
+MagickPPExport int Magick::operator != ( const Magick::Image& left_,
                                         const Magick::Image& right_ )
 {
   return ( ! (left_ == right_) );
 }
-MagickDLLDecl int Magick::operator >  ( const Magick::Image& left_,
+MagickPPExport int Magick::operator >  ( const Magick::Image& left_,
                                         const Magick::Image& right_ )
 {
   return ( !( left_ < right_ ) && ( left_ != right_ ) );
 }
-MagickDLLDecl int Magick::operator <  ( const Magick::Image& left_,
+MagickPPExport int Magick::operator <  ( const Magick::Image& left_,
                                         const Magick::Image& right_ )
 {
   // If image pixels are less, then image is smaller
@@ -71,12 +67,12 @@ MagickDLLDecl int Magick::operator <  ( const Magick::Image& left_,
           ( right_.rows() * right_.columns() )
           );
 }
-MagickDLLDecl int Magick::operator >= ( const Magick::Image& left_,
+MagickPPExport int Magick::operator >= ( const Magick::Image& left_,
                                         const Magick::Image& right_ )
 {
   return ( ( left_ > right_ ) || ( left_ == right_ ) );
 }
-MagickDLLDecl int Magick::operator <= ( const Magick::Image& left_,
+MagickPPExport int Magick::operator <= ( const Magick::Image& left_,
                                         const Magick::Image& right_ )
 {
   return ( ( left_ < right_ ) || ( left_ == right_ ) );
@@ -334,7 +330,7 @@ void Magick::Image::addNoise( const NoiseType noiseType_ )
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
     AddNoiseImage ( image(),
-                   noiseType_,
+                   noiseType_, 1.0,
                    &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
@@ -346,11 +342,12 @@ void Magick::Image::addNoiseChannel( const ChannelType channel_,
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetImageChannelMask( image(), channel_);
   MagickCore::Image* newImage =
-    AddNoiseImageChannel ( image(),
-                           channel_,
-                           noiseType_,
+    AddNoiseImage ( image(),
+                           noiseType_, 1.0,
                            &exceptionInfo );
+  (void) SetPixelChannelMask( image(), channel_mask );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -410,8 +407,8 @@ void Magick::Image::annotate ( const std::string &text_,
   if ( boundingArea_.isValid() ){
     if ( boundingArea_.width() == 0 || boundingArea_.height() == 0 )
       {
-        FormatMagickString( boundingArea, MaxTextExtent, "+%u+%u",
-                      boundingArea_.xOff(), boundingArea_.yOff() );
+        FormatLocaleString( boundingArea, MaxTextExtent, "%+.20g%+.20g",
+          (double) boundingArea_.xOff(), (double) boundingArea_.yOff() );
       }
     else
       {
@@ -448,14 +445,17 @@ void Magick::Image::annotate ( const std::string &text_,
           +current.tx;
     }
 
-  AnnotateImage( image(), drawInfo );
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  AnnotateImage( image(), drawInfo, &exceptionInfo );
 
   // Restore original values
   drawInfo->affine = oaffine;
   drawInfo->text = 0;
   drawInfo->geometry = 0;
 
-  throwImageException();
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 // Annotate with text (bounding area is entire image) and placement gravity.
 void Magick::Image::annotate ( const std::string &text_,
@@ -470,12 +470,15 @@ void Magick::Image::annotate ( const std::string &text_,
 
   drawInfo->gravity = gravity_;
 
-  AnnotateImage( image(), drawInfo );
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  AnnotateImage( image(), drawInfo, &exceptionInfo );
 
   drawInfo->gravity = NorthWestGravity;
   drawInfo->text = 0;
 
-  throwImageException();
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Blur image
@@ -495,8 +498,10 @@ void Magick::Image::blurChannel( const ChannelType channel_,
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
   MagickCore::Image* newImage =
-    BlurImageChannel( image(), channel_,radius_, sigma_, &exceptionInfo);
+    BlurImage( image(), radius_, sigma_, &exceptionInfo);
+  (void) SetPixelChannelMask( image(), channel_mask );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -510,7 +515,7 @@ void Magick::Image::border( const Geometry &geometry_ )
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    BorderImage( image(), &borderInfo, &exceptionInfo);
+    BorderImage( image(), &borderInfo, image()->compose, &exceptionInfo);
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -520,26 +525,32 @@ void Magick::Image::border( const Geometry &geometry_ )
 void Magick::Image::channel ( const ChannelType channel_ )
 {
   modifyImage();
-  SeparateImageChannel ( image(), channel_ );
-  throwImageException();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  MagickCore::Image* newImage =
+    SeparateImage( image(), channel_, &exceptionInfo);
+  replaceImage( newImage );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // 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_);
-  throwImageException();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  SetImageDepth( image(), depth_, &exceptionInfo);
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
-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 +587,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 +606,28 @@ 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 blend[MaxTextExtent];
+  FormatLocaleString(blend,MaxTextExtent,"%u/%u/%u",alphaRed_,alphaGreen_,alphaBlue_);
 
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
+  PixelInfo target;
+  GetPixelInfo(image(),&target);
+  PixelInfo pixel=static_cast<PixelInfo>(penColor_);
+  target.red=pixel.red;
+  target.green=pixel.green;
+  target.blue=pixel.blue;
+  target.alpha=pixel.alpha;
   MagickCore::Image* newImage =
-  ColorizeImage ( image(), opacity,
-                 penColor_, &exceptionInfo );
+    ColorizeImage ( image(), blend, &target, &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,15 +640,20 @@ 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_;
-  MagickCore::Image* newImage =
-    ColorMatrixImage( image(), kernel_info, &exceptionInfo );
-  kernel_info->values=(double *) NULL;
+  kernel_info->values=(MagickRealType *)  AcquireAlignedMemory(order_,
+    order_*sizeof(*kernel_info->values));
+  if (kernel_info->values != (MagickRealType *) NULL)
+    {
+      for (ssize_t i=0; i < (order_*order_); i++)
+        kernel_info->values[i]=color_matrix_[i];
+      MagickCore::Image* newImage =
+        ColorMatrixImage( image(), kernel_info, &exceptionInfo );
+      replaceImage( newImage );
+    }
   kernel_info=DestroyKernelInfo(kernel_info);
-  replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
@@ -638,10 +663,16 @@ void Magick::Image::colorMatrix (const size_t order_,
 // in the current image. False is returned if the images are identical.
 bool Magick::Image::compare ( const Image &reference_ )
 {
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   modifyImage();
   Image ref = reference_;
   ref.modifyImage();
-  return static_cast<bool>(IsImagesEqual(image(), ref.image()));
+  bool status =
+    static_cast<bool>(IsImagesEqual(image(), ref.image(), &exceptionInfo));
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+  return status;
 }
 
 // Composite two images
@@ -654,12 +685,15 @@ void Magick::Image::composite ( const Image &compositeImage_,
   // results in updating current image.
   modifyImage();
 
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   CompositeImage( image(),
-                 compose_,
                  compositeImage_.constImage(),
+                 compose_, MagickFalse,
                  xOffset_,
-                  yOffset_ );
-  throwImageException();
+                  yOffset_, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 void Magick::Image::composite ( const Image &compositeImage_,
                                const Geometry &offset_,
@@ -676,11 +710,14 @@ void Magick::Image::composite ( const Image &compositeImage_,
                      &x, &y,
                      &width, &height );
 
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   CompositeImage( image(),
-                 compose_,
                  compositeImage_.constImage(),
-                 x, y );
-  throwImageException();
+                 compose_, MagickFalse,
+                 x, y, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 void Magick::Image::composite ( const Image &compositeImage_,
                                const GravityType gravity_,
@@ -693,19 +730,25 @@ void Magick::Image::composite ( const Image &compositeImage_,
   SetGeometry(compositeImage_.constImage(), &geometry);
   GravityAdjustGeometry(columns(), rows(), gravity_, &geometry);
 
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   CompositeImage( image(),
-                 compose_,
                  compositeImage_.constImage(),
-                 geometry.x, geometry.y );
-  throwImageException();
+                 compose_, MagickFalse,
+                 geometry.x, geometry.y, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Contrast image
 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,12 +757,25 @@ 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 );
-  MagickCore::Image* newImage =
-  ConvolveImage ( image(), order_,
-                 kernel_, &exceptionInfo );
-  replaceImage( newImage );
+  kernel_info=AcquireKernelInfo((const char *) NULL);
+  kernel_info->width=order_;
+  kernel_info->height=order_;
+  kernel_info->values=(MagickRealType *)  AcquireAlignedMemory(order_,
+    order_*sizeof(*kernel_info->values));
+  if (kernel_info->values != (MagickRealType *) NULL)
+    {
+      for (ssize_t i=0; i < (order_*order_); i++)
+        kernel_info->values[i]=kernel_[i];
+      MagickCore::Image* newImage =
+        ConvolveImage ( image(), kernel_info, &exceptionInfo );
+      replaceImage( newImage );
+    }
+  kernel_info=DestroyKernelInfo(kernel_info);
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
@@ -742,9 +798,12 @@ void Magick::Image::crop ( const Geometry &geometry_ )
 // Cycle Color Map
 void Magick::Image::cycleColormap ( const ssize_t amount_ )
 {
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   modifyImage();
-  CycleColormapImage( image(), amount_ );
-  throwImageException();
+  CycleColormapImage( image(), amount_, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Despeckle
@@ -762,7 +821,11 @@ void Magick::Image::despeckle ( void )
 // Display image
 void Magick::Image::display( void )
 {
-  DisplayImages( imageInfo(), image() );
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  DisplayImages( imageInfo(), image(), &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Distort image.  distorts an image using various distortion methods, by
@@ -795,8 +858,7 @@ void Magick::Image::draw ( const Magick::Drawable &drawable_ )
     {
       drawable_.operator()(wand);
 
-      if( constImage()->exception.severity == UndefinedException)
-        DrawRender(wand);
+      DrawRender(wand);
 
       wand=DestroyDrawingWand(wand);
     }
@@ -817,12 +879,9 @@ void Magick::Image::draw ( const std::list<Magick::Drawable> &drawable_ )
            p != drawable_.end(); p++ )
         {
           p->operator()(wand);
-          if( constImage()->exception.severity != UndefinedException)
-            break;
         }
 
-      if( constImage()->exception.severity == UndefinedException)
-        DrawRender(wand);
+      DrawRender(wand);
 
       wand=DestroyDrawingWand(wand);
     }
@@ -831,12 +890,12 @@ void Magick::Image::draw ( const std::list<Magick::Drawable> &drawable_ )
 }
 
 // Hilight edges in image
-void Magick::Image::edge ( const double radius_ )
+void Magick::Image::edge ( const double radius_, const double sigma_ )
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    EdgeImage( image(), radius_, &exceptionInfo );
+    EdgeImage( image(), radius_, sigma_, &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -869,27 +928,35 @@ 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 );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Erase image to current "background color"
 void Magick::Image::erase ( void )
 {
   modifyImage();
-  SetImageBackgroundColor( image() );
-  throwImageException();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  SetImageBackgroundColor( image(), &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Extends image as defined by the geometry.
 //
 void Magick::Image::extent ( const Geometry &geometry_ )
 {
-  RectangleInfo extentInfo = geometry_;
   modifyImage();
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
+  RectangleInfo extentInfo = geometry_;
+  extentInfo.x = geometry_.xOff();
+  extentInfo.y = geometry_.yOff();
   MagickCore::Image* newImage =
     ExtentImage ( image(), &extentInfo, &exceptionInfo );
   replaceImage( newImage );
@@ -903,14 +970,18 @@ void Magick::Image::extent ( const Geometry &geometry_, const Color &backgroundC
 }
 void Magick::Image::extent ( const Geometry &geometry_, const GravityType gravity_ )
 {
-  image()->gravity  = gravity_;
-  extent ( geometry_ );
+  RectangleInfo geometry;
+
+  SetGeometry(image(), &geometry);
+  geometry.width = geometry_.width();
+  geometry.height = geometry_.height();
+  GravityAdjustGeometry(image()->columns, image()->rows, gravity_, &geometry);
+  extent ( geometry );
 }
 void Magick::Image::extent ( const Geometry &geometry_, const Color &backgroundColor_, const GravityType gravity_ )
 {
-  image()->gravity  = gravity_;
   backgroundColor ( backgroundColor_ );
-  extent ( geometry_ );
+  extent ( geometry_, gravity_ );
 }
 
 // Flip image (reflect each scanline in the vertical direction)
@@ -960,27 +1031,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.
-void Magick::Image::floodFillOpacity( const ssize_t x_,
+// pixel(x,y) with replacement alpha value using method.
+void Magick::Image::floodFillAlpha( 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);
-  PixelPacket pixel=static_cast<PixelPacket>(pixelColor(x_,y_));
+  PixelInfo target;
+  GetPixelInfo(image(),&target);
+  PixelInfo pixel=static_cast<PixelInfo>(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 +1072,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 +1111,22 @@ void Magick::Image::floodFillTexture( const ssize_t x_,
   // Set drawing fill pattern
   options()->fillPattern(texture_.constImage());
 
-  MagickPixelPacket target;
-  GetMagickPixelPacket(constImage(),&target);
-  target.red=static_cast<PixelPacket>(borderColor_).red;
-  target.green=static_cast<PixelPacket>(borderColor_).green;
-  target.blue=static_cast<PixelPacket>(borderColor_).blue;
+  PixelInfo target;
+  GetPixelInfo(constImage(),&target);
+  target.red=static_cast<PixelInfo>(borderColor_).red;
+  target.green=static_cast<PixelInfo>(borderColor_).green;
+  target.blue=static_cast<PixelInfo>(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 +1147,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_ )
 {
@@ -1107,7 +1162,7 @@ void Magick::Image::frame ( const Geometry &geometry_ )
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    FrameImage( image(), &info, &exceptionInfo );
+    FrameImage( image(), &info, image()->compose, &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -1127,7 +1182,7 @@ void Magick::Image::frame ( const size_t width_,
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    FrameImage( image(), &info, &exceptionInfo );
+    FrameImage( image(), &info, image()->compose, &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -1139,7 +1194,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 +1204,10 @@ void Magick::Image::fx ( const std::string expression,
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetImageChannelMask( image(), channel );
   MagickCore::Image* newImage =
-    FxImageChannel ( image(), channel, expression.c_str(), &exceptionInfo );
+    FxImage ( image(), expression.c_str(), &exceptionInfo );
+  (void) SetPixelChannelMask( image(), channel_mask );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -1159,11 +1216,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 +1229,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 +1261,10 @@ void Magick::Image::gaussianBlurChannel ( const ChannelType channel_,
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
   MagickCore::Image* newImage =
-    GaussianBlurImageChannel( image(), channel_, width_, sigma_, &exceptionInfo );
+    GaussianBlurImage( image(), width_, sigma_, &exceptionInfo );
+  (void) SetPixelChannelMask( image(), channel_mask );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -1210,9 +1273,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
@@ -1221,7 +1287,7 @@ void Magick::Image::implode ( const double factor_ )
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    ImplodeImage( image(), factor_, &exceptionInfo );
+    ImplodeImage( image(), factor_, image()->interpolate, &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -1266,33 +1332,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
@@ -1310,28 +1355,36 @@ void Magick::Image::magnify ( void )
 // Remap image colors with closest color from reference image
 void Magick::Image::map ( const Image &mapImage_ , const bool dither_ )
 {
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   modifyImage();
   options()->quantizeDither( dither_ );
   RemapImage ( options()->quantizeInfo(), image(),
-             mapImage_.constImage());
-  throwImageException();
+             mapImage_.constImage(), &exceptionInfo);
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
-// 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);
-  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();
+  PixelInfo target;
+  GetPixelInfo(constImage(),&target);
+  target.red=static_cast<PixelInfo>(target_).red;
+  target.green=static_cast<PixelInfo>(target_).green;
+  target.blue=static_cast<PixelInfo>(target_).blue;
+  target.alpha=alpha_;
+  ChannelType channel_mask = SetImageChannelMask( image(), AlphaChannel );
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  FloodfillPaintImage ( image(), options()->drawInfo(), &target, x_, y_,
+    method_ == FloodfillMethod ? MagickFalse : MagickTrue, &exceptionInfo);
+  (void) SetPixelChannelMask( image(), channel_mask );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Filter image by replacing each pixel component with the median
@@ -1341,7 +1394,22 @@ 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 );
+}
+
+// Merge layers
+void Magick::Image::mergeLayers( const LayerMethod layerMethod_ )
+{
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  MagickCore::Image* newImage =
+    MergeImageLayers ( image(),
+        layerMethod_,
+        &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -1365,12 +1433,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 +1467,52 @@ 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_ );
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  SetImageAlpha( image(), alpha_, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Change the color of an opaque pixel to the pen color.
@@ -1452,12 +1534,17 @@ 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) QueryColorCompliance(std::string(opaqueColor_).c_str(),
+    AllCompliance, &opaque, &exceptionInfo);
+  (void) QueryColorCompliance(std::string(penColor_).c_str(),
+    AllCompliance, &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
@@ -1499,12 +1586,14 @@ void Magick::Image::process( std::string name_, const ssize_t argc, const char *
 {
   modifyImage();
 
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   size_t status = 
     InvokeDynamicImageFilter( name_.c_str(), &image(), argc, argv,
-      &image()->exception );
-
-  if (status == false)
-    throwException( image()->exception );
+      &exceptionInfo );
+  (void) status;
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Quantize colors in image using current quantization settings
@@ -1518,9 +1607,12 @@ void Magick::Image::quantize ( const bool measureError_  )
   else
     options()->quantizeInfo()->measure_error=MagickFalse;
 
-  QuantizeImage( options()->quantizeInfo(), image() );
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  QuantizeImage( options()->quantizeInfo(), image(), &exceptionInfo );
 
-  throwImageException();
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Apply an arithmetic or bitwise operator to the image pixel quantums.
@@ -1530,7 +1622,9 @@ void Magick::Image::quantumOperator ( const ChannelType channel_,
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  EvaluateImageChannel( image(), channel_, operator_, rvalue_, &exceptionInfo);
+  ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
+  EvaluateImage( image(), operator_, rvalue_, &exceptionInfo);
+  (void) SetPixelChannelMask( image(), channel_mask );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
@@ -1551,10 +1645,12 @@ 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_,
+  ChannelType channel_mask = SetImageChannelMask( image(), channel_);
+  EvaluateImage( crop_image, operator_, rvalue_, &exceptionInfo );
+  (void) SetPixelChannelMask( image(), channel_mask );
+  (void) CompositeImage( image(), crop_image, image()->alpha_trait == BlendPixelTrait ?
+    OverCompositeOp : CopyCompositeOp, MagickFalse, geometry.x, geometry.y,
     &exceptionInfo );
-  (void) CompositeImage( image(), image()->matte != MagickFalse ?
-    OverCompositeOp : CopyCompositeOp, crop_image, geometry.x, geometry.y );
   crop_image = DestroyImageList(crop_image);
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -1565,10 +1661,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 +1691,11 @@ void Magick::Image::randomThresholdChannel( const Geometry &thresholds_,
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   modifyImage();
-  (void) RandomThresholdImageChannel( image(),
-                                      channel_,
+  ChannelType channel_mask = SetImageChannelMask( image(), channel_);
+  (void) RandomThresholdImage( image(),
                                       static_cast<std::string>(thresholds_).c_str(),
                                       &exceptionInfo );
+  (void) SetPixelChannelMask( image(), channel_mask );
   throwImageException();
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
@@ -1622,8 +1722,6 @@ void Magick::Image::read ( const std::string &imageSpec_ )
     }
   replaceImage( image );
   throwException( exceptionInfo );
-  if ( image )
-    throwException( image->exception );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
@@ -1646,8 +1744,6 @@ void Magick::Image::read ( const Blob &blob_ )
                 blob_.length(), &exceptionInfo );
   replaceImage( image );
   throwException( exceptionInfo );
-  if ( image )
-    throwException( image->exception );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
@@ -1721,8 +1817,6 @@ void Magick::Image::read ( const size_t width_,
                      &exceptionInfo );
   replaceImage( image );
   throwException( exceptionInfo );
-  if ( image )
-    throwException( image->exception );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
@@ -1732,7 +1826,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 );
@@ -1759,7 +1854,6 @@ void Magick::Image::resize( const Geometry &geometry_ )
                width,
                height,
                image()->filter,
-               1.0,
                &exceptionInfo);
   replaceImage( newImage );
   throwException( exceptionInfo );
@@ -1858,15 +1952,17 @@ void Magick::Image::scale ( const Geometry &geometry_ )
 void Magick::Image::segment ( const double clusterThreshold_, 
                              const double smoothingThreshold_ )
 {
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   modifyImage();
   SegmentImage ( image(),
                 options()->quantizeColorSpace(),
                 (MagickBooleanType) options()->verbose(),
                 clusterThreshold_,
-                smoothingThreshold_ );
-  throwImageException();
-  SyncImage( image() );
-  throwImageException();
+                smoothingThreshold_, &exceptionInfo );
+  SyncImage( image(), &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Shade image using distant light source
@@ -1887,6 +1983,19 @@ void Magick::Image::shade ( const double azimuth_,
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
+// Simulate an image shadow
+void Magick::Image::shadow( const double percent_opacity_, const double sigma_,
+  const ssize_t x_, const ssize_t y_ )
+{
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  MagickCore::Image* newImage = ShadowImage( image(), percent_opacity_, sigma_,
+    x_, y_, &exceptionInfo );
+  replaceImage( newImage );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
 // Sharpen pixels in image
 void Magick::Image::sharpen ( const double radius_, const double sigma_ )
 {
@@ -1907,12 +2016,13 @@ void Magick::Image::sharpenChannel ( const ChannelType channel_,
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
   MagickCore::Image* newImage =
-    SharpenImageChannel( image(),
-                         channel_,
+    SharpenImage( image(),
                          radius_,
                          sigma_,
                          &exceptionInfo );
+  (void) SetPixelChannelMask( image(), channel_mask );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -1952,18 +2062,24 @@ 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
 // film to light during the development process)
 void Magick::Image::solarize ( const double factor_ )
 {
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   modifyImage();
-  SolarizeImage ( image(), factor_ );
-  throwImageException();
+  SolarizeImage ( image(), factor_, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Sparse color image, given a set of coordinates, interpolates the colors
@@ -1976,8 +2092,11 @@ void Magick::Image::sparseColor ( const ChannelType channel,
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  MagickCore::Image* newImage = SparseColorImage ( image(), channel, method,
+
+  ChannelType channel_mask = SetImageChannelMask( image(), channel );
+  MagickCore::Image* newImage = SparseColorImage ( image(), method,
     number_arguments, arguments, &exceptionInfo );
+  (void) SetPixelChannelMask( image(), channel_mask );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -1991,6 +2110,7 @@ void Magick::Image::spread ( const size_t amount_ )
   MagickCore::Image* newImage =
     SpreadImage( image(),
                 amount_,
+                 image()->interpolate,
                 &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
@@ -2031,7 +2151,7 @@ void Magick::Image::swirl ( const double degrees_ )
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    SwirlImage( image(), degrees_,
+    SwirlImage( image(), degrees_, image()->interpolate,
                &exceptionInfo);
   replaceImage( newImage );
   throwException( exceptionInfo );
@@ -2042,34 +2162,46 @@ void Magick::Image::swirl ( const double degrees_ )
 void Magick::Image::texture ( const Image &texture_ )
 {
   modifyImage();
-  TextureImage( image(), texture_.constImage() );
-  throwImageException();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  TextureImage( image(), texture_.constImage(), &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Threshold image
 void Magick::Image::threshold ( const double threshold_ )
 {
   modifyImage();
-  BilevelImage( image(), threshold_ );
-  throwImageException();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  BilevelImage( image(), threshold_, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Transform image based on image geometry only
 void Magick::Image::transform ( const Geometry &imageGeometry_ )
 {
   modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   TransformImage ( &(image()), 0,
-                  std::string(imageGeometry_).c_str() );
-  throwImageException();
+                  std::string(imageGeometry_).c_str(), &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 // Transform image based on image and crop geometries
 void Magick::Image::transform ( const Geometry &imageGeometry_,
                                const Geometry &cropGeometry_ )
 {
   modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   TransformImage ( &(image()), std::string(cropGeometry_).c_str(),
-                  std::string(imageGeometry_).c_str() );
-  throwImageException();
+                  std::string(imageGeometry_).c_str(), &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Add matte image to image, setting pixels matching color to transparent
@@ -2083,11 +2215,16 @@ void Magick::Image::transparent ( const Color &color_ )
 
   std::string color = color_;
 
-  MagickPixelPacket target;
-  (void) QueryMagickColor(std::string(color_).c_str(),&target,&image()->exception);
+  PixelInfo target;
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  (void) QueryColorCompliance(std::string(color_).c_str(),AllCompliance,
+    &target,&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 +2240,19 @@ void Magick::Image::transparentChroma(const Color &colorLow_,
   std::string colorLow = colorLow_;
   std::string colorHigh = colorHigh_;
 
-  MagickPixelPacket targetLow;
-  MagickPixelPacket targetHigh;
-  (void) QueryMagickColor(std::string(colorLow_).c_str(),&targetLow,
-    &image()->exception);
-  (void) QueryMagickColor(std::string(colorHigh_).c_str(),&targetHigh,
-    &image()->exception);
+  PixelInfo targetLow;
+  PixelInfo targetHigh;
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  (void) QueryColorCompliance(std::string(colorLow_).c_str(),
+    AllCompliance,&targetLow,&exceptionInfo);
+  (void) QueryColorCompliance(std::string(colorHigh_).c_str(),
+    AllCompliance,&targetHigh,&exceptionInfo);
   modifyImage();
   TransparentPaintImageChroma ( image(), &targetLow, &targetHigh,
-    TransparentOpacity, MagickFalse );
-  throwImageException();
+    TransparentAlpha, MagickFalse, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 
@@ -2167,14 +2307,15 @@ void Magick::Image::unsharpmaskChannel ( const ChannelType channel_,
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
   MagickCore::Image* newImage =
-    UnsharpMaskImageChannel( image(),
-                             channel_,
+    UnsharpMaskImage( image(),
                              radius_,
                              sigma_,
                              amount_,
                              threshold_,
                              &exceptionInfo );
+  (void) SetPixelChannelMask( image(), channel_mask );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -2189,6 +2330,7 @@ void Magick::Image::wave ( const double amplitude_, const double wavelength_ )
     WaveImage( image(),
               amplitude_,
               wavelength_,
+              image()->interpolate,
               &exceptionInfo);
   replaceImage( newImage );
   throwException( exceptionInfo );
@@ -2198,10 +2340,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
@@ -2211,7 +2356,7 @@ void Magick::Image::write ( Blob *blob_ )
   size_t length = 2048; // Efficient size for small images
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  void* data = ImageToBlob( imageInfo(),
+  void* data = ImagesToBlob( imageInfo(),
                            image(),
                            &length,
                            &exceptionInfo);
@@ -2228,7 +2373,7 @@ void Magick::Image::write ( Blob *blob_,
   size_t length = 2048; // Efficient size for small images
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  void* data = ImageToBlob( imageInfo(),
+  void* data = ImagesToBlob( imageInfo(),
                            image(),
                            &length,
                            &exceptionInfo);
@@ -2247,7 +2392,7 @@ void Magick::Image::write ( Blob *blob_,
   size_t length = 2048; // Efficient size for small images
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  void* data = ImageToBlob( imageInfo(),
+  void* data = ImagesToBlob( imageInfo(),
                            image(),
                            &length,
                            &exceptionInfo);
@@ -2294,9 +2439,10 @@ void Magick::Image::zoom( const Geometry &geometry_ )
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    ZoomImage( image(),
+    ResizeImage( image(),
                width,
                height,
+               image()->filter,
                &exceptionInfo);
   replaceImage( newImage );
   throwException( exceptionInfo );
@@ -2357,11 +2503,20 @@ void Magick::Image::attribute ( const std::string name_,
                                 const std::string value_ )
 {
   modifyImage();
-  SetImageProperty( image(), name_.c_str(), value_.c_str() );
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  SetImageProperty( image(), name_.c_str(), value_.c_str(), &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 std::string Magick::Image::attribute ( const std::string name_ )
 {
-  const char *value = GetImageProperty( constImage(), name_.c_str() );
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  const char *value = GetImageProperty( constImage(), name_.c_str(),
+    &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 
   if ( value )
     return std::string( value );
@@ -2370,26 +2525,20 @@ std::string Magick::Image::attribute ( const std::string name_ )
 }
 
 // Background color
-void Magick::Image::backgroundColor ( const Color &color_ )
+void Magick::Image::backgroundColor ( const Color &backgroundColor_ )
 {
   modifyImage();
 
-  if ( color_.isValid() )
+  if ( backgroundColor_.isValid() )
     {
-      image()->background_color.red   = color_.redQuantum();
-      image()->background_color.green = color_.greenQuantum();
-      image()->background_color.blue  = color_.blueQuantum();
-      image()->background_color.opacity  = color_.alphaQuantum();
+      image()->background_color = backgroundColor_;
     }
   else
     {
-      image()->background_color.red   = 0;
-      image()->background_color.green = 0;
-      image()->background_color.blue  = 0;
-      image()->background_color.opacity  = OpaqueOpacity;
+      image()->background_color = Color();
     }
 
-  options()->backgroundColor( color_ );
+  options()->backgroundColor( backgroundColor_ );
 }
 Magick::Color Magick::Image::backgroundColor ( void ) const
 {
@@ -2426,26 +2575,20 @@ size_t Magick::Image::baseRows ( void ) const
 }
 
 // Border color
-void Magick::Image::borderColor ( const Color &color_ )
+void Magick::Image::borderColor ( const Color &borderColor_ )
 {
   modifyImage();
 
-  if ( color_.isValid() )
+  if ( borderColor_.isValid() )
     {
-      image()->border_color.red   = color_.redQuantum();
-      image()->border_color.green = color_.greenQuantum();
-      image()->border_color.blue  = color_.blueQuantum();
-      image()->border_color.opacity  = color_.alphaQuantum();
+      image()->border_color = borderColor_;
     }
   else
     {
-      image()->border_color.red   = 0;
-      image()->border_color.green = 0;
-      image()->border_color.blue  = 0;
-      image()->border_color.opacity = OpaqueOpacity;
+      image()->border_color = Color();
     }
 
-  options()->borderColor( color_ );
+  options()->borderColor( borderColor_ );
 }
 Magick::Color Magick::Image::borderColor ( void ) const
 {
@@ -2541,8 +2684,12 @@ void Magick::Image::classType ( const ClassType class_ )
       // Use SyncImage to synchronize the DirectClass pixels with the
       // color map and then set to DirectClass type.
       modifyImage();
-      SyncImage( image() );
-      image()->colormap = (PixelPacket *)
+      ExceptionInfo exceptionInfo;
+      GetExceptionInfo( &exceptionInfo );
+      SyncImage( image(), &exceptionInfo );
+      throwException( exceptionInfo );
+      (void) DestroyExceptionInfo( &exceptionInfo );
+      image()->colormap = (PixelInfo *)
         RelinquishMagickMemory( image()->colormap );
       image()->storage_class = static_cast<MagickCore::ClassType>(DirectClass);
       return;
@@ -2565,26 +2712,29 @@ void Magick::Image::clipMask ( const Magick::Image & clipMask_ )
 {
   modifyImage();
 
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   if( clipMask_.isValid() )
     {
       // Set clip mask
-      SetImageClipMask( image(), clipMask_.constImage() );
+      SetImageMask( image(), clipMask_.constImage(), &exceptionInfo );
     }
   else
     {
       // Unset existing clip mask
-      SetImageClipMask( image(), 0 );
+      SetImageMask( image(), 0, &exceptionInfo );
     }
+   throwException( exceptionInfo );
+   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 Magick::Image Magick::Image::clipMask ( void  ) const
 {
-      ExceptionInfo exceptionInfo;
-      GetExceptionInfo( &exceptionInfo );
-      MagickCore::Image* image =
-        GetImageClipMask( constImage(), &exceptionInfo );
-      throwException( exceptionInfo );
-  (void) DestroyExceptionInfo( &exceptionInfo );
-      return Magick::Image( image );
+   ExceptionInfo exceptionInfo;
+   GetExceptionInfo( &exceptionInfo );
+   MagickCore::Image* image = GetImageMask( constImage(), &exceptionInfo );
+   throwException( exceptionInfo );
+   (void) DestroyExceptionInfo( &exceptionInfo );
+   return Magick::Image( image );
 }
 
 void Magick::Image::colorFuzz ( const double fuzz_ )
@@ -2651,14 +2801,14 @@ void Magick::Image::colorMapSize ( const size_t entries_ )
     {
       // Allocate colormap
       imageptr->colormap =
-        static_cast<PixelPacket*>(AcquireMagickMemory(entries_*sizeof(PixelPacket)));
+        static_cast<PixelInfo*>(AcquireMagickMemory(entries_*sizeof(PixelInfo)));
       imageptr->colors = 0;
     }
   else if ( entries_ > imageptr->colors )
     {
       // Re-allocate colormap
-      imageptr->colormap=(PixelPacket *)
-        ResizeMagickMemory(imageptr->colormap,(entries_)*sizeof(PixelPacket));
+      imageptr->colormap=(PixelInfo *)
+        ResizeMagickMemory(imageptr->colormap,(entries_)*sizeof(PixelInfo));
     }
 
   // Initialize any new colormap entries as all black
@@ -2682,39 +2832,15 @@ size_t Magick::Image::colorMapSize ( void )
 // Image colorspace
 void Magick::Image::colorSpace( const ColorspaceType colorSpace_ )
 {
-  // Nothing to do?
   if ( image()->colorspace == colorSpace_ )
     return;
 
   modifyImage();
-
-  if ( colorSpace_ != RGBColorspace &&
-       colorSpace_ != TransparentColorspace &&
-       colorSpace_ != GRAYColorspace )
-    {
-      if (image()->colorspace != RGBColorspace &&
-          image()->colorspace != TransparentColorspace &&
-          image()->colorspace != GRAYColorspace)
-        {
-          /* Transform to RGB colorspace as intermediate step */
-          TransformRGBImage( image(), image()->colorspace );
-          throwImageException();
-        }
-      /* Transform to final non-RGB colorspace */
-      RGBTransformImage( image(), colorSpace_ );
-      throwImageException();
-      return;
-    }
-
-  if ( colorSpace_ == RGBColorspace ||
-       colorSpace_ == TransparentColorspace ||
-       colorSpace_ == GRAYColorspace )
-    {
-      /* Transform to a RGB-type colorspace */
-      TransformRGBImage( image(), image()->colorspace );
-      throwImageException();
-      return;
-    }
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  TransformImageColorspace(image(), colorSpace_, &exceptionInfo);
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 Magick::ColorspaceType Magick::Image::colorSpace ( void ) const
 {
@@ -2725,6 +2851,11 @@ Magick::ColorspaceType Magick::Image::colorSpace ( void ) const
 void Magick::Image::colorspaceType( const ColorspaceType colorSpace_ )
 {
   modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  SetImageColorspace(image(), colorSpace_, &exceptionInfo);
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
   options()->colorspaceType( colorSpace_ );
 }
 Magick::ColorspaceType Magick::Image::colorspaceType ( void ) const
@@ -2737,14 +2868,22 @@ Magick::ColorspaceType Magick::Image::colorspaceType ( void ) const
 void Magick::Image::comment ( const std::string &comment_ )
 {
   modifyImage();
-  SetImageProperty( image(), "Comment", NULL );
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  SetImageProperty( image(), "Comment", NULL, &exceptionInfo );
   if ( comment_.length() > 0 )
-    SetImageProperty( image(), "Comment", comment_.c_str() );
-  throwImageException();
+    SetImageProperty( image(), "Comment", comment_.c_str(), &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 std::string Magick::Image::comment ( void ) const
 {
-  const char *value = GetImageProperty( constImage(), "Comment" );
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  const char *value = GetImageProperty( constImage(), "Comment",
+    &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 
   if ( value )
     return std::string( value );
@@ -2850,21 +2989,21 @@ void Magick::Image::density ( const Geometry &density_ )
   options()->density( density_ );
   if ( density_.isValid() )
     {
-      image()->x_resolution = density_.width();
+      image()->resolution.x = density_.width();
       if ( density_.height() != 0 )
         {
-          image()->y_resolution = density_.height();
+          image()->resolution.y = density_.height();
         }
       else
         {
-          image()->y_resolution = density_.width();
+          image()->resolution.y = density_.width();
         }
     }
   else
     {
       // Reset to default
-      image()->x_resolution = 0;
-      image()->y_resolution = 0;
+      image()->resolution.x = 0;
+      image()->resolution.y = 0;
     }
 }
 Magick::Geometry Magick::Image::density ( void ) const
@@ -2874,11 +3013,11 @@ Magick::Geometry Magick::Image::density ( void ) const
       ssize_t x_resolution=72;
       ssize_t y_resolution=72;
 
-      if (constImage()->x_resolution > 0.0)
-        x_resolution=static_cast<ssize_t>(constImage()->x_resolution + 0.5);
+      if (constImage()->resolution.x > 0.0)
+        x_resolution=static_cast<ssize_t>(constImage()->resolution.x + 0.5);
 
-      if (constImage()->y_resolution > 0.0)
-        y_resolution=static_cast<ssize_t>(constImage()->y_resolution + 0.5);
+      if (constImage()->resolution.y > 0.0)
+        y_resolution=static_cast<ssize_t>(constImage()->resolution.y + 0.5);
 
       return Geometry(x_resolution,y_resolution);
     }
@@ -2935,8 +3074,12 @@ void Magick::Image::exifProfile( const Magick::Blob &exifProfile_ )
     {
       StringInfo * exif_profile = AcquireStringInfo( exifProfile_.length() );
       SetStringInfoDatum(exif_profile ,(unsigned char *) exifProfile_.data());
-      (void) SetImageProfile( image(), "exif", exif_profile);
+      ExceptionInfo exceptionInfo;
+      GetExceptionInfo( &exceptionInfo );
+      (void) SetImageProfile( image(), "exif", exif_profile, &exceptionInfo);
       exif_profile =DestroyStringInfo( exif_profile );
+      throwException( exceptionInfo );
+      (void) DestroyExceptionInfo( &exceptionInfo );
     }
 }
 Magick::Blob Magick::Image::exifProfile( void ) const
@@ -3020,7 +3163,7 @@ Magick::Image  Magick::Image::fillPattern ( void  ) const
                     &exceptionInfo);
       texture.replaceImage( image );
       throwException( exceptionInfo );
-  (void) DestroyExceptionInfo( &exceptionInfo );
+      (void) DestroyExceptionInfo( &exceptionInfo );
     }
   return texture;
 }
@@ -3064,8 +3207,12 @@ void Magick::Image::fontTypeMetrics( const std::string &text_,
 {
   DrawInfo *drawInfo = options()->drawInfo();
   drawInfo->text = const_cast<char *>(text_.c_str());
-  GetTypeMetrics( image(), drawInfo, &(metrics->_typeMetric) );
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  GetTypeMetrics( image(), drawInfo, &(metrics->_typeMetric), &exceptionInfo );
   drawInfo->text = 0;
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Image format string
@@ -3149,8 +3296,12 @@ void Magick::Image::iptcProfile( const Magick::Blob &iptcProfile_ )
     {
       StringInfo * iptc_profile = AcquireStringInfo( iptcProfile_.length() );
       SetStringInfoDatum(iptc_profile ,(unsigned char *) iptcProfile_.data());
-      (void) SetImageProfile( image(), "iptc", iptc_profile);
-       iptc_profile =DestroyStringInfo( iptc_profile );
+      ExceptionInfo exceptionInfo;
+      GetExceptionInfo( &exceptionInfo );
+      (void) SetImageProfile( image(), "iptc", iptc_profile, &exceptionInfo);
+      iptc_profile =DestroyStringInfo( iptc_profile );
+      throwException( exceptionInfo );
+      (void) DestroyExceptionInfo( &exceptionInfo );
     }
 }
 Magick::Blob Magick::Image::iptcProfile( void ) const
@@ -3190,14 +3341,21 @@ bool Magick::Image::isValid ( void ) const
 void Magick::Image::label ( const std::string &label_ )
 {
   modifyImage();
-  SetImageProperty ( image(), "Label", NULL );
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  SetImageProperty ( image(), "Label", NULL, &exceptionInfo );
   if ( label_.length() > 0 )
-    SetImageProperty ( image(), "Label", label_.c_str() );
-  throwImageException();
+    SetImageProperty ( image(), "Label", label_.c_str(), &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 std::string Magick::Image::label ( void ) const
 {
-  const char *value = GetImageProperty( constImage(), "Label" );
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  const char *value = GetImageProperty( constImage(), "Label", &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 
   if ( value )
     return std::string( value );
@@ -3231,15 +3389,19 @@ void Magick::Image::matte ( const bool matteFlag_ )
   // matte channel, then create an opaque matte channel.  Likewise, if
   // the image already has a matte channel but a matte channel is not
   // desired, then set the matte channel to opaque.
-  if ((matteFlag_ && !constImage()->matte) ||
-      (constImage()->matte && !matteFlag_))
-    SetImageOpacity(image(),OpaqueOpacity);
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  if ((matteFlag_ && !constImage()->alpha_trait) ||
+      (constImage()->alpha_trait && !matteFlag_))
+    SetImageAlpha(image(),OpaqueAlpha,&exceptionInfo);
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 
-  image()->matte = (MagickBooleanType) matteFlag_;
+  image()->alpha_trait = matteFlag_ ? BlendPixelTrait : UndefinedPixelTrait;
 }
 bool Magick::Image::matte ( void ) const
 {
-  if ( constImage()->matte )
+  if ( constImage()->alpha_trait == BlendPixelTrait )
     return true;
   else
     return false;
@@ -3251,31 +3413,22 @@ void Magick::Image::matteColor ( const Color &matteColor_ )
   
   if ( matteColor_.isValid() )
     {
-      image()->matte_color.red   = matteColor_.redQuantum();
-      image()->matte_color.green = matteColor_.greenQuantum();
-      image()->matte_color.blue  = matteColor_.blueQuantum();
-      image()->matte_color.opacity  = matteColor_.alphaQuantum();
-
-      options()->matteColor( matteColor_ ); 
+      image()->matte_color = matteColor_;
+      options()->matteColor( matteColor_ );
     }
   else
     {
       // Set to default matte color
       Color tmpColor( "#BDBDBD" );
-      image()->matte_color.red   = tmpColor.redQuantum();
-      image()->matte_color.green = tmpColor.greenQuantum();
-      image()->matte_color.blue  = tmpColor.blueQuantum();
-      image()->matte_color.opacity  = tmpColor.alphaQuantum();
-
+      image()->matte_color = tmpColor;
       options()->matteColor( tmpColor );
     }
 }
 Magick::Color Magick::Image::matteColor ( void ) const
 {
-  return Color( constImage()->matte_color.red,
-               constImage()->matte_color.green,
-               constImage()->matte_color.blue,
-               constImage()->matte_color.opacity );
+  return Color( ClampToQuantum( constImage()->matte_color.red ),
+               ClampToQuantum( constImage()->matte_color.green ),
+               ClampToQuantum( constImage()->matte_color.blue ) );
 }
 
 double Magick::Image::meanErrorPerPixel ( void ) const
@@ -3288,7 +3441,11 @@ double Magick::Image::meanErrorPerPixel ( void ) const
 void Magick::Image::modulusDepth ( const size_t depth_ )
 {
   modifyImage();
-  SetImageDepth( image(), depth_ );
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  SetImageDepth( image(), depth_, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
   options()->depth( depth_ );
 }
 size_t Magick::Image::modulusDepth ( void ) const
@@ -3404,7 +3561,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 );
+  PixelInfo packet = color_;
+  MagickCore::SetPixelInfoPixel(constImage(),&packet,pixel);
   // Tell ImageMagick that pixels have been updated
   pixels.sync();
 
@@ -3415,22 +3574,12 @@ void Magick::Image::pixelColor ( const ssize_t x_, const ssize_t y_,
 Magick::Color Magick::Image::pixelColor ( const ssize_t x_,
                                          const ssize_t y_ ) const
 {
-  ClassType storage_class;
-  storage_class = classType();
-  // DirectClass
-  const PixelPacket* pixel = getConstPixels( x_, y_, 1, 1 );
-  if ( storage_class == DirectClass )
+  const Quantum* pixel = getConstPixels( x_, y_, 1, 1 );
+  if ( pixel )
     {
-      if ( pixel )
-        return Color( *pixel );
-    }
-
-  // PseudoClass
-  if ( storage_class == PseudoClass )
-    {
-      const IndexPacket* indexes = getConstIndexes();
-      if ( indexes )
-        return colorMap( (size_t) *indexes );
+      PixelInfo packet;
+      MagickCore::GetPixelInfoPixel(constImage(),pixel,&packet);
+      return Color( packet );
     }
 
   return Color(); // invalid
@@ -3461,12 +3610,15 @@ void Magick::Image::profile( const std::string name_,
                              const Magick::Blob &profile_ )
 {
   modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   ssize_t result = ProfileImage( image(), name_.c_str(),
                              (unsigned char *)profile_.data(),
-                             profile_.length(), MagickTrue);
+                             profile_.length(), &exceptionInfo);
+  (void) result;
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 
-  if( !result )
-    throwImageException();
 }
 
 // Retrieve a named profile from the image.
@@ -3578,14 +3730,19 @@ std::string Magick::Image::signature ( const bool force_ ) const
   Lock( &_imgRef->_mutexLock );
 
   // Re-calculate image signature if necessary
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   if ( force_ ||
-       !GetImageProperty(constImage(), "Signature") ||
+       !GetImageProperty(constImage(), "Signature", &exceptionInfo) ||
        constImage()->taint )
     {
-      SignatureImage( const_cast<MagickCore::Image *>(constImage()) );
+      SignatureImage( const_cast<MagickCore::Image *>(constImage()), &exceptionInfo );
     }
 
-  const char *property = GetImageProperty(constImage(), "Signature");
+  const char *property = GetImageProperty(constImage(), "Signature",
+    &exceptionInfo);
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 
   return std::string( property );
 }
@@ -3618,7 +3775,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,
@@ -3626,40 +3783,58 @@ void Magick::Image::statistics ( ImageStatistics *statistics ) const
 
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  (void) GetImageChannelRange(constImage(),RedChannel,&minimum,&maximum,
-    &exceptionInfo);
+
+  ChannelType channel_mask = SetImageChannelMask( 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) SetPixelChannelMask( image(), channel_mask );
+
+  channel_mask = SetImageChannelMask( 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) SetPixelChannelMask( image(), channel_mask );
+
+  channel_mask = SetImageChannelMask( 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) SetPixelChannelMask( image(), channel_mask );
+
+  channel_mask = SetImageChannelMask( 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) SetPixelChannelMask( image(), channel_mask );
+
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
+// Strip strips an image of all profiles and comments.
+void Magick::Image::strip ( void )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  StripImage( image(), &exceptionInfo );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
@@ -3779,7 +3954,7 @@ Magick::Image  Magick::Image::strokePattern ( void  ) const
                     MagickTrue, // orphan
                     &exceptionInfo);
       throwException( exceptionInfo );
-  (void) DestroyExceptionInfo( &exceptionInfo );
+      (void) DestroyExceptionInfo( &exceptionInfo );
       texture.replaceImage( image );
     }
   return texture;
@@ -3827,16 +4002,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;
@@ -3904,9 +4069,13 @@ Magick::ImageType Magick::Image::type ( void ) const
 }
 void Magick::Image::type ( const Magick::ImageType type_)
 {
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
   modifyImage();
   options()->type( type_ );
-  SetImageType( image(), type_ );
+  SetImageType( image(), type_, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 void Magick::Image::verbose ( const bool verboseFlag_ )
@@ -3933,8 +4102,11 @@ std::string Magick::Image::view ( void ) const
 void Magick::Image::virtualPixelMethod ( const VirtualPixelMethod virtual_pixel_method_ )
 {
   modifyImage();
-  SetImageVirtualPixelMethod( image(), virtual_pixel_method_ );
-  options()->virtualPixelMethod( virtual_pixel_method_ );
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  SetImageVirtualPixelMethod( image(), virtual_pixel_method_, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod ( void ) const
 {
@@ -3953,11 +4125,11 @@ std::string Magick::Image::x11Display ( void ) const
 
 double Magick::Image::xResolution ( void ) const
 {
-  return constImage()->x_resolution;
+  return constImage()->resolution.x;
 }
 double Magick::Image::yResolution ( void ) const
 {
-  return constImage()->y_resolution;
+  return constImage()->resolution.y;
 }
 
 // Copy Constructor
@@ -4012,14 +4184,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 );
@@ -4028,10 +4200,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();
@@ -4039,10 +4211,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();
@@ -4053,14 +4225,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 );
@@ -4072,14 +4244,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 );
@@ -4202,7 +4374,13 @@ MagickCore::Image * Magick::Image::replaceImage
   if( replacement_ )
     image = replacement_;
   else
-    image = AcquireImage(constImageInfo());
+    {
+      ExceptionInfo exceptionInfo;
+      GetExceptionInfo( &exceptionInfo );
+      image = AcquireImage(constImageInfo(), &exceptionInfo);
+      throwException( exceptionInfo );
+      (void) DestroyExceptionInfo( &exceptionInfo );
+    }
 
   {
     Lock( &_imgRef->_mutexLock );
@@ -4260,7 +4438,6 @@ void Magick::Image::modifyImage( void )
 void Magick::Image::throwImageException( void ) const
 {
   // Throw C++ exception while resetting Image exception to default state
-  throwException( const_cast<MagickCore::Image*>(constImage())->exception );
 }
 
 // Register image with image registry or obtain registration id
@@ -4308,7 +4485,7 @@ void Magick::MagickPlusPlusDestroyMagick(void)
 }
 
 // C library initialization routine
-void MagickDLLDecl Magick::InitializeMagick(const char *path_)
+void MagickPPExport Magick::InitializeMagick(const char *path_)
 {
   MagickCore::MagickCoreGenesis(path_,MagickFalse);
   if (!magick_initialized)