Removed mergeLayers for a single image in Magick++.
authordirk <dirk@git.imagemagick.org>
Sun, 4 Aug 2013 09:57:23 +0000 (09:57 +0000)
committerdirk <dirk@git.imagemagick.org>
Sun, 4 Aug 2013 09:57:23 +0000 (09:57 +0000)
Added linearStretch, liquidRescale, perceptible, polaroid, posterize to Magick++.
Code cleanup.

Magick++/lib/Image.cpp
Magick++/lib/Magick++/Image.h
Magick++/lib/Magick++/Include.h
Magick++/lib/STL.cpp

index 28befbbf1d86cb2f3510a6b3bcd42f245ff4edd6..80ca70a09fdb8448664857d13280ef5b6956f27e 100644 (file)
@@ -418,6 +418,22 @@ void Magick::Image::affineTransform ( const DrawableAffine &affine_ )
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
+// 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::alpha ( const unsigned int alpha_ )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  SetImageAlpha( image(), alpha_, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
 // Annotate using specified text, and placement location
 void Magick::Image::annotate ( const std::string &text_,
                                const Geometry &location_ )
@@ -1618,29 +1634,29 @@ void Magick::Image::inverseFourierTransform ( const Image &phase_,
 // 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::level ( const double black_point_,
-                            const double white_point_,
+void Magick::Image::level ( const double blackPoint_,
+                            const double whitePoint_,
                             const double gamma_ )
 {
   modifyImage();
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  (void) LevelImage( image(), black_point_, white_point_, gamma_,
+  (void) LevelImage( image(), blackPoint_, whitePoint_, gamma_,
                      &exceptionInfo );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 void Magick::Image::levelChannel ( const ChannelType channel_,
-                                   const double black_point_,
-                                   const double white_point_,
+                                   const double blackPoint_,
+                                   const double whitePoint_,
                                    const double gamma_ )
 {
   modifyImage();
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
-  (void) LevelImage( image(), black_point_, white_point_, gamma_,
+  (void) LevelImage( image(), blackPoint_, whitePoint_, gamma_,
                      &exceptionInfo );
   SetPixelChannelMask( image(), channel_mask );
   throwException( exceptionInfo );
@@ -1710,7 +1726,36 @@ void Magick::Image::levelColorsChannel ( const ChannelType channel_,
   SetPixelChannelMask( image(), channel_mask );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
+}
 
+void Magick::Image::linearStretch ( const double blackPoint_,
+                                    const double whitePoint_ )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  LinearStretchImage( image(), blackPoint_, whitePoint_, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
+void Magick::Image::liquidRescale ( const Geometry &geometry_ )
+{
+  ssize_t x = 0;
+  ssize_t y = 0;
+  size_t width = columns();
+  size_t height = rows();
+
+  ParseMetaGeometry( static_cast<std::string>(geometry_).c_str(),
+                     &x, &y,
+                     &width, &height );
+
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  LiquidRescaleImage( image(), width, height, x, y, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Magnify image by integral size
@@ -1737,11 +1782,12 @@ void Magick::Image::map ( const Image &mapImage_ , const bool dither_ )
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
+
 // Floodfill designated area with replacement alpha value
 void Magick::Image::matteFloodfill ( const Color &target_ ,
-                                    const unsigned int alpha_,
-                                    const ssize_t x_, const ssize_t y_,
-                                    const Magick::PaintMethod method_ )
+                                     const unsigned int alpha_,
+                                     const ssize_t x_, const ssize_t y_,
+                                     const Magick::PaintMethod method_ )
 {
   modifyImage();
   PixelInfo target;
@@ -1767,22 +1813,8 @@ void Magick::Image::medianFilter ( const double radius_ )
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    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 );
+    StatisticImage ( image(), MedianStatistic, (size_t) radius_,
+                    (size_t) radius_, &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -1802,12 +1834,12 @@ void Magick::Image::minify ( void )
 
 // Modulate percent hue, saturation, and brightness of an image
 void Magick::Image::modulate ( const double brightness_,
-                              const double saturation_,
-                              const double hue_ )
+                               const double saturation_,
+                               const double hue_ )
 {
   char modulate[MaxTextExtent + 1];
   FormatLocaleString( modulate, MaxTextExtent, "%3.6f,%3.6f,%3.6f",
-               brightness_, saturation_, hue_);
+                      brightness_, saturation_, hue_);
 
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
@@ -1823,9 +1855,9 @@ void Magick::Image::modulate ( const double brightness_,
 // specifies the standard deviation of the Laplacian, in pixels.
 // The angle_ parameter specifies the angle the object appears
 // to be comming from (zero degrees is from the right).
-void            Magick::Image::motionBlur ( const double radius_,
-                                            const double sigma_,
-                                            const double angle_ )
+void Magick::Image::motionBlur ( const double radius_,
+                                 const double sigma_,
+                                 const double angle_ )
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
@@ -1843,8 +1875,8 @@ void Magick::Image::negate ( const bool grayscale_ )
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   modifyImage();
-  NegateImage ( image(), grayscale_ == true ? MagickTrue : MagickFalse, 
-    &exceptionInfo );
+  NegateImage ( image(), grayscale_ == true ? MagickTrue : MagickFalse,
+                &exceptionInfo );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
@@ -1872,36 +1904,15 @@ void Magick::Image::oilPaint ( const double radius_, const double sigma_ )
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
-// 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::alpha ( const unsigned int alpha_ )
-{
-  modifyImage();
-  ExceptionInfo exceptionInfo;
-  GetExceptionInfo( &exceptionInfo );
-  SetImageAlpha( image(), alpha_, &exceptionInfo );
-  throwException( exceptionInfo );
-  (void) DestroyExceptionInfo( &exceptionInfo );
-}
-
 // Change the color of an opaque pixel to the pen color.
 void Magick::Image::opaque ( const Color &opaqueColor_,
-                            const Color &penColor_ )
+                             const Color &penColor_ )
 {
   if ( !opaqueColor_.isValid() )
-  {
-    throwExceptionExplicit( OptionError,
-                           "Opaque color argument is invalid" );
-  }
+    throwExceptionExplicit( OptionError, "Opaque color argument is invalid" );
+
   if ( !penColor_.isValid() )
-  {
-    throwExceptionExplicit( OptionError,
-                           "Pen color argument is invalid" );
-  }
+    throwExceptionExplicit( OptionError, "Pen color argument is invalid" );
 
   modifyImage();
   std::string opaqueColor = opaqueColor_;
@@ -1911,15 +1922,25 @@ void Magick::Image::opaque ( const Color &opaqueColor_,
   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);
+  (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 );
 }
 
+void Magick::Image::perceptible ( const double epsilon_ )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  PerceptibleImage( image(), epsilon_, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
 // Ping is similar to read except only enough of the image is read to
 // determine the image columns, rows, and filesize.  Access the
 // columns(), rows(), and fileSize() attributes after invoking ping.
@@ -1951,11 +1972,38 @@ void Magick::Image::ping ( const Blob& blob_ )
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
+void Magick::Image::polaroid ( const std::string &caption_,
+                               const double angle_,
+                               const PixelInterpolateMethod method_ )
+{
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  MagickCore::Image* image =
+    PolaroidImage( constImage(), options()->drawInfo(), caption_.c_str(),
+                   angle_, method_, &exceptionInfo );
+  replaceImage( image );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
+void Magick::Image::posterize ( const size_t levels_,
+                                const DitherMethod method_ )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  PosterizeImage( image(), levels_, method_, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
 // Execute a named process module using an argc/argv syntax similar to
 // that accepted by a C 'main' routine. An exception is thrown if the
 // requested process module doesn't exist, fails to load, or fails during
 // execution.
-void Magick::Image::process( std::string name_, const ssize_t argc, const char **argv )
+void Magick::Image::process( std::string name_,
+                             const ssize_t argc,
+                             const char **argv )
 {
   modifyImage();
 
index f7c75d0931b01963b0ad33d5db8aa248547c88d8..0a0b4250db11a4578846ab5c6beb78b6aa95a5b5 100644 (file)
@@ -145,6 +145,15 @@ namespace Magick
     // Transform image by specified affine (or free transform) matrix.
     void            affineTransform ( const DrawableAffine &affine );
 
+    // Set or attenuate the alpha channel in the image. 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            alpha ( const unsigned int alpha_ );
+
     //
     // Annotate image (draw text on image)
     //
@@ -503,8 +512,8 @@ namespace Magick
     // white point are set to the maximum quantum value. The black and
     // white point have the valid range 0 to QuantumRange while mid (gamma)
     // has a useful range of 0 to ten.
-    void            level ( const double black_point_,
-                            const double white_point_,
+    void            level ( const double blackPoint_,
+                            const double whitePoint_,
                             const double gamma_=1.0 );
 
     // Level image channel. Adjust the levels of the image channel by
@@ -519,8 +528,8 @@ namespace Magick
     // quantum value. The black and white point have the valid range 0
     // to QuantumRange while mid (gamma) has a useful range of 0 to ten.
     void            levelChannel ( const ChannelType channel_,
-                                   const double black_point_,
-                                   const double white_point_,
+                                   const double blackPoint_,
+                                   const double whitePoint_,
                                    const double gamma_=1.0 );
 
     // Maps the given color to "black" and "white" values, linearly spreading
@@ -535,31 +544,39 @@ namespace Magick
                                          const Color &blackColor_,
                                          const bool invert_ = false );
 
+    // Discards any pixels below the black point and above the white point and
+    // levels the remaining pixels.
+    void            linearStretch ( const double blackPoint_,
+                                    const double whitePoint_ );
+
+    // Rescales image with seam carving.
+    void            liquidRescale ( const Geometry &geometry_ );
+
     // Magnify image by integral size
     void            magnify ( void );
-    
+
     // Remap image colors with closest color from reference image
     void            map ( const Image &mapImage_ ,
                           const bool dither_ = false );
-    
+
     // Floodfill designated area with replacement alpha value
     void            matteFloodfill ( const Color &target_ ,
-             const unsigned int alpha_,
-             const ::ssize_t x_, const ::ssize_t y_,
-             const PaintMethod method_ );
+                                     const unsigned int alpha_,
+                                     const ::ssize_t x_, const ::ssize_t y_,
+                                     const PaintMethod method_ );
 
     // Filter image by replacing each pixel component with the median
     // color in a circular neighborhood
     void            medianFilter ( const double radius_ = 0.0 );
-    
+
     // Reduce image by integral size
     void            minify ( void );
-    
+
     // Modulate percent hue, saturation, and brightness of an image
     void            modulate ( const double brightness_,
-             const double saturation_,
-             const double hue_ );
-    
+                               const double saturation_,
+                               const double hue_ );
+
     // Motion blur image with specified blur factor
     // The radius_ parameter specifies the radius of the Gaussian, in
     // pixels, not counting the center pixel.  The sigma_ parameter
@@ -569,43 +586,57 @@ namespace Magick
     void            motionBlur ( const double radius_,
                                  const double sigma_,
                                  const double angle_ );
-    
+
     // Negate colors in image.  Set grayscale to only negate grayscale
     // values in image.
     void            negate ( const bool grayscale_ = false );
-    
+
     // Normalize image (increase contrast by normalizing the pixel
     // values to span the full range of color values)
     void            normalize ( void );
-    
-    // Oilpaint image (image looks like oil painting)
-    void            oilPaint ( const double radius_ = 0.0, const double sigma = 1.0 );
 
-    // Set or attenuate the alpha channel in the image. 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            alpha ( const unsigned int alpha_ );
+    // Oilpaint image (image looks like oil painting)
+    void            oilPaint ( const double radius_ = 0.0,
+                               const double sigma = 1.0 );
 
     // Change color of opaque pixel to specified pen color.
     void            opaque ( const Color &opaqueColor_,
-           const Color &penColor_ );
+                             const Color &penColor_ );
+
+    // Set each pixel whose value is less than epsilon to epsilon or
+    // -epsilon (whichever is closer) otherwise the pixel value remains
+    // unchanged.
+    void            perceptible ( const double epsilon_ );
 
     // Ping is similar to read except only enough of the image is read
     // to determine the image columns, rows, and filesize.  Access the
     // columns(), rows(), and fileSize() attributes after invoking
     // ping.  The image data is not valid after calling ping.
     void            ping ( const std::string &imageSpec_ );
-    
+
     // Ping is similar to read except only enough of the image is read
     // to determine the image columns, rows, and filesize.  Access the
     // columns(), rows(), and fileSize() attributes after invoking
     // ping.  The image data is not valid after calling ping.
     void            ping ( const Blob &blob_ );
 
+    // Simulates a Polaroid picture.
+    void            polaroid ( const std::string &caption_,
+                               const double angle_,
+                               const PixelInterpolateMethod method_ );
+
+    // Reduces the image to a limited number of colors for a "poster" effect.
+    void            posterize ( const size_t levels_,
+                                const DitherMethod method_ );
+
+    // Execute a named process module using an argc/argv syntax similar to
+    // that accepted by a C 'main' routine. An exception is thrown if the
+    // requested process module doesn't exist, fails to load, or fails during
+    // execution.
+    void            process ( std::string name_,
+                              const ::ssize_t argc_,
+                              const char **argv_ );
+
     // Quantize image (reduce number of colors)
     void            quantize ( const bool measureError_ = false );
 
@@ -620,14 +651,6 @@ namespace Magick
                                       const MagickEvaluateOperator operator_,
                                       const double rvalue_);
 
-    // Execute a named process module using an argc/argv syntax similar to
-    // that accepted by a C 'main' routine. An exception is thrown if the
-    // requested process module doesn't exist, fails to load, or fails during
-    // execution.
-    void            process ( std::string name_,
-                              const ::ssize_t argc_,
-                              const char **argv_ );
-
     // Raise image (lighten or darken the edges of an image to give a
     // 3-D raised or lowered effect)
     void            raise ( const Geometry &geometry_ = raiseGeometryDefault,
@@ -1161,9 +1184,6 @@ typedef struct _ImageStatistics
     void            matteColor ( const Color &matteColor_ );
     Color           matteColor ( void ) const;
 
-    // Merge image layers
-    void            mergeLayers ( const LayerMethod layerType_ );
-    
     // The mean error per pixel computed when an image is color reduced
     double          meanErrorPerPixel ( void ) const;
 
index 34359f243a45e5ef8855cc929fa8dc00c477b203..69c1d24b0c7008c9516198a4a1c3b2c29ced5cd2 100644 (file)
@@ -254,7 +254,6 @@ namespace Magick
   
   // Color-space types
   using MagickCore::ColorspaceType;
-
   using MagickCore::UndefinedColorspace;
   using MagickCore::CMYColorspace;
   using MagickCore::CMYKColorspace;
@@ -292,12 +291,12 @@ namespace Magick
   using MagickCore::AllCompliance;
 
   // Composition operations
+  using MagickCore::CompositeOperator;
   using MagickCore::AtopCompositeOp;
   using MagickCore::BlendCompositeOp;
   using MagickCore::BumpmapCompositeOp;
   using MagickCore::ClearCompositeOp;
   using MagickCore::ColorizeCompositeOp;
-  using MagickCore::CompositeOperator;
   using MagickCore::CopyBlueCompositeOp;
   using MagickCore::CopyCompositeOp;
   using MagickCore::CopyCyanCompositeOp;
@@ -371,6 +370,7 @@ namespace Magick
   using MagickCore::SentinelDistortion;
 
   // Dither methods
+  using MagickCore::DitherMethod;
   using MagickCore::UndefinedDitherMethod;
   using MagickCore::NoDitherMethod;
   using MagickCore::RiemersmaDitherMethod;
@@ -383,6 +383,7 @@ namespace Magick
   using MagickCore::MSBEndian;
 
   // Evaluate options
+  using MagickCore::MagickEvaluateOperator;
   using MagickCore::UndefinedEvaluateOperator;
   using MagickCore::AddEvaluateOperator;
   using MagickCore::AndEvaluateOperator;
@@ -396,7 +397,6 @@ namespace Magick
   using MagickCore::SetEvaluateOperator;
   using MagickCore::SubtractEvaluateOperator;
   using MagickCore::XorEvaluateOperator;
-  using MagickCore::MagickEvaluateOperator;
 
   // Fill rules
   using MagickCore::FillRule;
index ecf681b1cdb47a8f5b0873e37a6d4f49c28d4968..4a9a315a4877f5e9e31f5669b3443f5689d75ba4 100644 (file)
@@ -688,17 +688,6 @@ void Magick::medianConvolveImage::operator()( Magick::Image &image_ ) const
   image_.medianFilter( _radius );
 }
 
-// Merge image layers
-Magick::mergeLayersImage::mergeLayersImage( 
-  Magick::LayerMethod layerMethod_ )
-  : _layerMethod( layerMethod_ )
-{
-}
-void Magick::mergeLayersImage::operator()( Magick::Image &image_ ) const
-{
-  image_.mergeLayers( _layerMethod );
-}
-
 // Reduce image by integral size
 Magick::minifyImage::minifyImage( void )
 {