1 #ifndef color_YPbPr_convert_rgb 2 #define color_YPbPr_convert_rgb 3 4 #include "../../_internal/convert.hpp" 5 #include "../../rgb/category.hpp" 6 #include "../../rgb/trait/container.hpp" 7 8 #include "../category.hpp" 9 #include "../constant.hpp" 10 11 #include "../../_internal/normalize.hpp" 12 #include "../../_internal/diverse.hpp" 13 14 namespace color 15 { 16 namespace _internal 17 { 18 19 template 20 < 21 typename YPbPr_tag_name, ::color::constant::YPbPr::reference_enum YPbPr_reference_number 22 ,typename rgb_tag_name 23 > 24 struct convert 25 < 26 ::color::category::YPbPr< YPbPr_tag_name, YPbPr_reference_number > 27 ,::color::category::rgb< rgb_tag_name > 28 > 29 { 30 public: 31 typedef ::color::category::YPbPr< YPbPr_tag_name, YPbPr_reference_number > category_left_type; 32 typedef ::color::category::rgb< rgb_tag_name > category_right_type; 33 typedef typename ::color::trait::scalar<category_left_type>::instance_type scalar_type; 34 35 typedef ::color::trait::container<category_left_type> container_left_trait_type; 36 typedef ::color::trait::container<category_right_type> container_right_trait_type; 37 38 typedef typename container_left_trait_type::input_type container_left_input_type; 39 typedef typename container_right_trait_type::model_type container_right_const_input_type; 40 41 typedef ::color::_internal::diverse< category_left_type > diverse_type; 42 typedef ::color::_internal::normalize< category_right_type > normalize_type; 43 44 typedef ::color::constant::YPbPr::parameter< YPbPr_tag_name, YPbPr_reference_number > YPbPr_parameter_type; 45 46 enum 47 { 48 red_p = ::color::place::_internal::red<category_right_type>::position_enum 49 ,green_p = ::color::place::_internal::green<category_right_type>::position_enum 50 ,blue_p = ::color::place::_internal::blue<category_right_type>::position_enum 51 }; 52 processcolor::_internal::convert53 static void process 54 ( 55 container_left_input_type left 56 ,container_right_const_input_type right 57 ) 58 { 59 scalar_type r = normalize_type::template process<red_p >( container_right_trait_type::template get<red_p >( right ) ); 60 scalar_type g = normalize_type::template process<green_p>( container_right_trait_type::template get<green_p>( right ) ); 61 scalar_type b = normalize_type::template process<blue_p >( container_right_trait_type::template get<blue_p >( right ) ); 62 63 scalar_type Y = YPbPr_parameter_type::b11() * r + YPbPr_parameter_type::b12() * g + YPbPr_parameter_type::b13() * b; 64 scalar_type Pb = YPbPr_parameter_type::b21() * r + YPbPr_parameter_type::b22() * g + YPbPr_parameter_type::b23() * b; 65 scalar_type Pr = YPbPr_parameter_type::b31() * r + YPbPr_parameter_type::b32() * g + YPbPr_parameter_type::b33() * b; 66 67 Pb = YPbPr_parameter_type::Pb_normalize( Pb ); 68 Pr = YPbPr_parameter_type::Pr_normalize( Pr ); 69 70 container_left_trait_type::template set<0>( left, diverse_type::template process<0>( Y ) ); 71 container_left_trait_type::template set<1>( left, diverse_type::template process<1>( Pb ) ); 72 container_left_trait_type::template set<2>( left, diverse_type::template process<2>( Pr ) ); 73 } 74 }; 75 76 } 77 } 78 79 #endif 80