TuttleOFX  1
invert.hpp
Go to the documentation of this file.
00001 #ifndef _TERRY_COLOR_INVERT_HPP_
00002 #define _TERRY_COLOR_INVERT_HPP_
00003 
00004 #include <terry/channel.hpp>
00005 
00006 namespace terry {
00007 namespace color {
00008 
00009 template< typename Channel>
00010 struct channel_invert_t
00011 {
00012         void operator()( const Channel& src, Channel& dst ) const
00013         {
00014                 dst = boost::gil::channel_invert( src );
00015         }
00016 };
00017 
00018 /**
00019  * @brief Invert colored channel values. So invert all channel values except alpha channel.
00020  */
00021 struct pixel_invert_colors_t
00022 {
00023         template<class Pixel>
00024         Pixel operator()( const Pixel& src ) const
00025         {
00026                 typedef typename boost::gil::channel_type<Pixel>::type Channel;
00027                 Pixel res;
00028                 boost::gil::static_for_each( src, res, channel_invert_t<Channel>() );
00029                 terry::assign_channel_if_exists_t< Pixel, boost::gil::alpha_t >()( src, res );
00030                 return res;
00031         }
00032 };
00033 
00034 /**
00035  * @brief Invert channel values
00036  */
00037 struct pixel_invert_t
00038 {
00039         template<class Pixel>
00040         Pixel operator()( const Pixel& src ) const
00041         {
00042                 typedef typename boost::gil::channel_type<Pixel>::type Channel;
00043                 Pixel res;
00044                 boost::gil::static_for_each( src, res, channel_invert_t<Channel>() );
00045                 return res;
00046         }
00047 };
00048 
00049 
00050 }
00051 }
00052 
00053 #endif