diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-10-13 17:53:49 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-10-13 17:53:49 +0400 |
commit | 843d8859a718c1f9a8c0f7109b2cdf9bbeb46fa3 (patch) | |
tree | 84832487219a9d9b7b495ade9efb4e7b925cd917 /source/blender/blenlib | |
parent | 62f4d613d06fad1bad95b4ec5e5199425a23d684 (diff) |
bugfix [#23355] Square Color picker moving by itself and locking up
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_math_color.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_color.c | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h index 2f40520e59a..2095c40b5aa 100644 --- a/source/blender/blenlib/BLI_math_color.h +++ b/source/blender/blenlib/BLI_math_color.h @@ -61,6 +61,7 @@ void cpack_to_rgb(unsigned int col, float *r, float *g, float *b); void rgb_to_yuv(float r, float g, float b, float *ly, float *lu, float *lv); void rgb_to_ycc(float r, float g, float b, float *ly, float *lcb, float *lcr, int colorspace); void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv); +void rgb_to_hsv_compat(float r, float g, float b, float *lh, float *ls, float *lv); unsigned int rgb_to_cpack(float r, float g, float b); unsigned int hsv_to_cpack(float h, float s, float v); diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index f0ef8b2c93d..09a6b5992db 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -232,6 +232,26 @@ void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv) *lv = v; } +void rgb_to_hsv_compat(float r, float g, float b, float *lh, float *ls, float *lv) +{ + float orig_h= *lh; + float orig_s= *ls; + + rgb_to_hsv(r, g, b, lh, ls, lv); + + if(*lv <= 0.0f) { + *lh= orig_h; + *ls= orig_s; + } + else if (*ls <= 0.0f) { + *lh= orig_h; + } + + if(*lh==0.0f && orig_h >= 1.0f) { + *lh= 1.0f; + } +} + /*http://brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html */ void xyz_to_rgb(float xc, float yc, float zc, float *r, float *g, float *b, int colorspace) |