1 #ifndef color_xyz_convert_xyy 2 #define color_xyz_convert_xyy 3 4 #include "../../_internal/convert.hpp" 5 6 #include "../category.hpp" 7 8 9 #include "../../xyy/xyy.hpp" 10 #include "../../rgb/rgb.hpp" 11 12 #include "../../_internal/normalize.hpp" 13 #include "../../_internal/diverse.hpp" 14 15 16 namespace color 17 { 18 namespace _internal 19 { 20 21 template< typename xyz_tag_name, typename xyy_tag_name > 22 struct convert 23 < 24 ::color::category::xyz< xyz_tag_name > 25 ,::color::category::xyy< xyy_tag_name > 26 > 27 { 28 public: 29 typedef ::color::category::xyz< xyz_tag_name > xyz_category_type, category_left_type; 30 typedef ::color::category::xyy< xyy_tag_name > xyy_category_type, category_right_type; 31 32 typedef typename ::color::trait::scalar<category_left_type>::instance_type scalar_type; 33 34 typedef ::color::category::xyz< scalar_type > xyzSCALAR_category_type; 35 typedef ::color::category::xyy< scalar_type > xyySCALAR_category_type; 36 37 typedef ::color::model< xyz_category_type > xyz_model_type; 38 typedef ::color::model< xyy_category_type > xyy_model_type; 39 40 typedef ::color::trait::container<category_left_type> container_left_trait_type; 41 typedef ::color::trait::container<category_right_type> container_right_trait_type; 42 43 typedef typename container_left_trait_type::input_type container_left_input_type; 44 typedef typename container_right_trait_type::model_type container_right_const_input_type; 45 46 typedef ::color::_internal::reformat< xyySCALAR_category_type, xyy_category_type > reformatXYY_type; 47 typedef ::color::_internal::reformat< xyz_category_type, xyzSCALAR_category_type > reformatXYZ_type; 48 49 typedef ::color::constant::xyz::illuminant::point< scalar_type, ::color::constant::xyz::illuminant::D65_entity, ::color::constant::xyz::illuminant::two_entity > white_point_type; 50 processcolor::_internal::convert51 static void process 52 ( 53 container_left_input_type left 54 ,container_right_const_input_type right 55 ) 56 { 57 scalar_type small_x = reformatXYY_type::template process< 0, 0>( container_right_trait_type::template get<0>( right ) ); 58 scalar_type small_y = reformatXYY_type::template process< 1, 1>( container_right_trait_type::template get<1>( right ) ); 59 scalar_type big_y = reformatXYY_type::template process< 2, 2>( container_right_trait_type::template get<2>( right ) ); 60 61 scalar_type x = 0; 62 scalar_type y = big_y; 63 scalar_type z = 0; 64 65 if( 0 != small_y ) 66 { 67 x = small_x * big_y / small_y; 68 z = (1 - small_x - small_y) * big_y / small_y; 69 } 70 71 container_left_trait_type::template set<0>( left, reformatXYZ_type::template process< 0, 0 >( x ) ); 72 container_left_trait_type::template set<1>( left, reformatXYZ_type::template process< 1, 1 >( y ) ); 73 container_left_trait_type::template set<2>( left, reformatXYZ_type::template process< 2, 2 >( z ) ); 74 } 75 }; 76 77 } 78 } 79 80 #endif 81