diff options
Diffstat (limited to 'source/blender/blenlib/intern/math_color.c')
-rw-r--r-- | source/blender/blenlib/intern/math_color.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 2f2e8d6fc61..85636d23f6f 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -25,6 +25,11 @@ * ***** END GPL LICENSE BLOCK ***** * */ +/** \file blender/blenlib/intern/math_color.c + * \ingroup bli + */ + + #include <assert.h> #include "BLI_math.h" @@ -40,9 +45,9 @@ void hsv_to_rgb(float h, float s, float v, float *r, float *g, float *b) *b = v; } else { - h= (h - floor(h))*6.0f; + h= (h - floorf(h))*6.0f; - i = (int)floor(h); + i = (int)floorf(h); f = h - i; p = v*(1.0f-s); q = v*(1.0f-(s*f)); @@ -303,11 +308,11 @@ unsigned int rgb_to_cpack(float r, float g, float b) { int ir, ig, ib; - ir= (int)floor(255.0*r); + ir= (int)floor(255.0f*r); if(ir<0) ir= 0; else if(ir>255) ir= 255; - ig= (int)floor(255.0*g); + ig= (int)floor(255.0f*g); if(ig<0) ig= 0; else if(ig>255) ig= 255; - ib= (int)floor(255.0*b); + ib= (int)floor(255.0f*b); if(ib<0) ib= 0; else if(ib>255) ib= 255; return (ir+ (ig*256) + (ib*256*256)); @@ -337,9 +342,9 @@ void rgb_float_to_byte(const float *in, unsigned char *out) { int r, g, b; - r= (int)(in[0] * 255.0); - g= (int)(in[1] * 255.0); - b= (int)(in[2] * 255.0); + r= (int)(in[0] * 255.0f); + g= (int)(in[1] * 255.0f); + b= (int)(in[2] * 255.0f); out[0]= (char)((r <= 0)? 0 : (r >= 255)? 255 : r); out[1]= (char)((g <= 0)? 0 : (g >= 255)? 255 : g); @@ -504,8 +509,8 @@ void rgb_float_set_hue_float_offset(float rgb[3], float hue_offset) 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; + if(hsv[0] > 1.0f) hsv[0] -= 1.0f; + else if(hsv[0] < 0.0f) hsv[0] += 1.0f; hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2); } |