diff options
author | Nathan Letwory <nathan@letworyinteractive.com> | 2010-09-15 15:58:19 +0400 |
---|---|---|
committer | Nathan Letwory <nathan@letworyinteractive.com> | 2010-09-15 15:58:19 +0400 |
commit | d97d727d09c488e2267ea191ee69f97cd335db9e (patch) | |
tree | 9738f05d0e5a86e2237ef83daf3e18e6665080f6 /source/blender/blenlib/intern/math_color.c | |
parent | 8a25c33fca7f63ccaaaaddfdfcc9537ef0e3222d (diff) |
Apply patch [#23755] Sequencer: small code cleanup using existing color math functions
By Luca Bonavita (mindrones)
From detailed description: This patch doesnt change functionality, but uses the existing color math functions from math_color.c into
sequencer_draw.c.
Diffstat (limited to 'source/blender/blenlib/intern/math_color.c')
-rw-r--r-- | source/blender/blenlib/intern/math_color.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 693fd885b50..787e126a42b 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -464,3 +464,28 @@ void lift_gamma_gain_to_asc_cdl(float *lift, float *gamma, float *gain, float *o } } +/* ******************************************** other ************************************************* */ + +/* Applies an hue offset to a float rgb color */ +void rgb_float_set_hue_float_offset(float rgb[3], float hue_offset) +{ + float hsv[3]; + + rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2); + + hsv[0]+= hue_offset; + if(hsv[0]>1.0) hsv[0]-=1.0; + else if(hsv[0]<0.0) hsv[0]+= 1.0; + + hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2); +} + +/* Applies an hue offset to a byte rgb color */ +void rgb_byte_set_hue_float_offset(char rgb[3], float hue_offset) +{ + float rgb_float[3]; + + rgb_byte_to_float(rgb, rgb_float); + rgb_float_set_hue_float_offset(rgb_float, hue_offset); + rgb_float_to_byte(rgb_float, rgb); +} |