]> granicus.if.org Git - imagemagick/commitdiff
Added auto gamma/level/orient to Magick++.
authordirk <dirk@git.imagemagick.org>
Tue, 30 Jul 2013 20:12:01 +0000 (20:12 +0000)
committerdirk <dirk@git.imagemagick.org>
Tue, 30 Jul 2013 20:12:01 +0000 (20:12 +0000)
Magick++/lib/Image.cpp
Magick++/lib/Magick++/Image.h

index 249dad971eb07fcee1fd1c48eecb33650d59fdf8..198aac83a163861737414df46825302e870a7c28 100644 (file)
@@ -543,6 +543,65 @@ std::string Magick::Image::artifact ( const std::string &name_ )
   return std::string( );
 }
 
+void Magick::Image::autoGamma ( void )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  AutoGammaImage( image(), &exceptionInfo);
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
+void Magick::Image::autoGammaChannel ( const ChannelType channel_ )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
+  AutoGammaImage( image(), &exceptionInfo);
+  (void) SetPixelChannelMask( image(), channel_mask );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
+void Magick::Image::autoLevel ( void )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  AutoLevelImage( image(), &exceptionInfo);
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
+void Magick::Image::autoLevelChannel ( const ChannelType channel_ )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
+  AutoLevelImage( image(), &exceptionInfo);
+  (void) SetPixelChannelMask( image(), channel_mask );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
+void Magick::Image::autoOrient ( void )
+{
+  if (image()->orientation == UndefinedOrientation ||
+      image()->orientation == TopLeftOrientation)
+    return;
+
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  MagickCore::Image* newImage =
+    AutoOrientImage( constImage(), image()->orientation, &exceptionInfo);
+  replaceImage( newImage );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
 // Blur image
 void Magick::Image::blur( const double radius_, const double sigma_ )
 {
index 43a301fc927c4116e18437bdf3817fbc28542bad..537b952c7b81cbaa3ad6b95a9ad721d915ebd453 100644 (file)
@@ -185,7 +185,20 @@ namespace Magick
                                const std::string &value_ );
     // Returns the value of the artifact with the specified name.
     std::string     artifact ( const std::string &name_ );
-    
+
+    // Extracts the 'mean' from the image and adjust the image to try
+    // make set its gamma appropriatally.
+    void            autoGamma ( void );
+    void            autoGammaChannel ( const ChannelType channel_ );
+
+    // Adjusts the levels of a particular image channel by scaling the
+    // minimum and maximum values to the full quantum range.
+    void            autoLevel ( void );
+    void            autoLevelChannel ( const ChannelType channel_ );
+
+    // Adjusts an image so that its orientation is suitable for viewing.
+    void            autoOrient ( void );
+
     // 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