TuttleOFX
1
|
00001 #ifndef _TERRY_COPY_HPP_ 00002 #define _TERRY_COPY_HPP_ 00003 00004 #include <boost/gil/color_base_algorithm.hpp> 00005 #include <terry/channel_view.hpp> 00006 00007 namespace terry { 00008 00009 namespace detail_copy_channel { 00010 00011 template<class Channel, class View> 00012 void copy_channel_if_exist( const View& src, const View& dst, const boost::mpl::true_ ) 00013 { 00014 using namespace boost::gil; 00015 copy_pixels( channel_view<Channel>(src), channel_view<Channel>(dst) ); 00016 } 00017 template<class Channel, class View> 00018 void copy_channel_if_exist( const View& src, const View& dst, const boost::mpl::false_ ) 00019 { 00020 } 00021 00022 template<class Channel, class Pixel> 00023 void copy_pixel_channel_if_exist( const Pixel& src, const Pixel& dst, const boost::mpl::true_ ) 00024 { 00025 using namespace boost::gil; 00026 get_color( dst, Channel() ) = get_color( src, Channel() ); 00027 } 00028 template<class Channel, class Pixel> 00029 void copy_pixel_channel_if_exist( const Pixel& src, const Pixel& dst, const boost::mpl::false_ ) 00030 { 00031 } 00032 00033 } 00034 00035 template<class Channel, class View> 00036 void copy_channel_if_exist( const View& src, const View& dst ) 00037 { 00038 using namespace boost::gil; 00039 typedef typename contains_color<typename View::value_type, Channel>::type hasChannel; 00040 detail_copy_channel::copy_channel_if_exist<Channel, View>( src, dst, hasChannel() ); 00041 } 00042 00043 template<class Channel, class Pixel> 00044 void copy_pixel_channel_if_exist( const Pixel& src, const Pixel& dst ) 00045 { 00046 using namespace boost::gil; 00047 typedef typename contains_color<Pixel, Channel>::type hasChannel; 00048 detail_copy_channel::copy_pixel_channel_if_exist<Channel, Pixel>( src, dst, hasChannel() ); 00049 } 00050 00051 00052 00053 } 00054 00055 #endif 00056