X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscreen%2Fcolors.hxx;h=aa0d414555f390235ddffcec8c6c6a893c502666;hb=5665a629389d61ef9f1a261f671e8c9b14668641;hp=13c6ef3ff0e550d0a20e93d965c54b1d0e54d8ed;hpb=42b4ec310f8070a7fe9e4ef97b09e6284340e6f5;p=simgear.git diff --git a/simgear/screen/colors.hxx b/simgear/screen/colors.hxx index 13c6ef3f..aa0d4145 100644 --- a/simgear/screen/colors.hxx +++ b/simgear/screen/colors.hxx @@ -36,15 +36,49 @@ const float system_gamma = 1.7; const float system_gamma = 2.5; #endif - // simple architecture independant gamma correction function. -inline void gamma_correct(float *color, - float reff = 2.5, float system = system_gamma) +inline void gamma_correct_rgb(float *color, + float reff = 2.5, float system = system_gamma) +{ + if (reff == system) + return; + + float tmp = reff/system; + color[0] = pow(color[0], tmp); + color[1] = pow(color[1], tmp); + color[2] = pow(color[2], tmp); +}; + +inline void gamma_correct_c(float *color, + float reff = 2.5, float system = system_gamma) { - color[0] = pow(color[0], reff/system); - color[1] = pow(color[1], reff/system); - color[2] = pow(color[2], reff/system); + if (reff == system) + return; + + *color = pow(*color, reff/system); }; +inline void gamma_restore_rgb(float *color, + float reff = 2.5, float system = system_gamma) +{ + if (reff == system) + return; + + float tmp = system/reff; + color[0] = pow(color[0], tmp); + color[1] = pow(color[1], tmp); + color[2] = pow(color[2], tmp); +}; + +inline void gamma_restore_c(float *color, + float reff = 2.5, float system = system_gamma) +{ + if (reff == system) + return; + + *color = pow(*color, system/reff); +}; + + #endif // _SG_COLORS_HXX