TuttleOFX  1
channel.hpp
Go to the documentation of this file.
00001 #ifndef _TERRY_CHANNEL_HPP_
00002 #define _TERRY_CHANNEL_HPP_
00003 
00004 #include <boost/gil/channel.hpp>
00005 #include <boost/gil/color_base_algorithm.hpp>
00006 
00007 namespace terry {
00008 
00009 template <typename ChannelValue>
00010 struct channel_base_type
00011 {
00012         typedef ChannelValue type;
00013 };
00014 
00015 template <typename ChannelValue, typename MinV, typename MaxV>
00016 struct channel_base_type<boost::gil::scoped_channel_value<ChannelValue, MinV, MaxV> >
00017 {
00018         typedef ChannelValue type;
00019 };
00020 
00021 template <typename ChannelValue>
00022 struct is_scoped_channel
00023 {
00024         typedef boost::mpl::false_ type;
00025 };
00026 
00027 template <typename ChannelValue, typename MinV, typename MaxV>
00028 struct is_scoped_channel<boost::gil::scoped_channel_value<ChannelValue, MinV, MaxV> >
00029 {
00030         typedef boost::mpl::true_ type;
00031 };
00032 
00033 
00034 
00035 template< class Pixel, class Channel, class HasChannel = typename boost::gil::contains_color<Pixel,Channel>::type >
00036 struct assign_channel_if_exists_t
00037 {
00038         void operator()( const Pixel& src, const Pixel& dst ) const;
00039 };
00040 
00041 // no alpha, nothing to do...
00042 template<class Pixel, class Channel>
00043 struct assign_channel_if_exists_t<Pixel, Channel, boost::mpl::false_>
00044 {
00045         void operator()( const Pixel& src, Pixel& dst ) const
00046         {
00047         }
00048 };
00049 
00050 template<class Pixel, class Channel>
00051 struct assign_channel_if_exists_t<Pixel, Channel, boost::mpl::true_>
00052 {
00053         void operator()( const Pixel& src, Pixel& dst ) const
00054         {
00055                 using namespace boost::gil;
00056                 get_color( dst, Channel() ) = get_color( src, Channel() );
00057         }
00058 };
00059 
00060 
00061 }
00062 
00063 #endif
00064