diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-01-19 13:09:00 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-01-19 13:09:00 +0400 |
commit | 879c13bbfc79d997ce9148d24c26704fbe6e3b50 (patch) | |
tree | c63d74cd192ce04073d59f196f5525afa80b48d1 /source/blender/blenlib | |
parent | 4786541285f6f190922ec9857753d620c528f181 (diff) |
rename rgb_float_to_byte, rgb_byte_to_float to rgb_float_to_uchar, rgb_uchar_to_float and swap args (math functions mostly have dest arg first like strcpy).
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_math_color.h | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_color.c | 26 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_color_inline.c | 12 |
3 files changed, 21 insertions, 21 deletions
diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h index 6d37aabd6ab..1b8cc08abf7 100644 --- a/source/blender/blenlib/BLI_math_color.h +++ b/source/blender/blenlib/BLI_math_color.h @@ -101,8 +101,8 @@ void minmax_rgb(short c[3]); void rgb_float_set_hue_float_offset(float * rgb, float hue_offset); void rgb_byte_set_hue_float_offset(unsigned char * rgb, float hue_offset); -void rgb_byte_to_float(const unsigned char in[3], float out[3]); -void rgb_float_to_byte(const float in[3], unsigned char out[3]); +void rgb_uchar_to_float(float col_r[3], const unsigned char col_ub[3]); +void rgb_float_to_uchar(unsigned char col_r[3], const float col_f[3]); /***************** lift/gamma/gain / ASC-CDL conversion *****************/ diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 20df893015d..31d69ba68b4 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -337,24 +337,24 @@ void cpack_to_rgb(unsigned int col, float *r, float *g, float *b) *b /= 255.0f; } -void rgb_byte_to_float(const unsigned char in[3], float out[3]) +void rgb_uchar_to_float(float col_r[3], const unsigned char col_ub[3]) { - out[0]= ((float)in[0]) / 255.0f; - out[1]= ((float)in[1]) / 255.0f; - out[2]= ((float)in[2]) / 255.0f; + col_r[0]= ((float)col_ub[0]) / 255.0f; + col_r[1]= ((float)col_ub[1]) / 255.0f; + col_r[2]= ((float)col_ub[2]) / 255.0f; } -void rgb_float_to_byte(const float in[3], unsigned char out[3]) +void rgb_float_to_uchar(unsigned char col_r[3], const float col_f[3]) { int r, g, b; - r= (int)(in[0] * 255.0f); - g= (int)(in[1] * 255.0f); - b= (int)(in[2] * 255.0f); + r= (int)(col_f[0] * 255.0f); + g= (int)(col_f[1] * 255.0f); + b= (int)(col_f[2] * 255.0f); - out[0]= (char)((r <= 0)? 0 : (r >= 255)? 255 : r); - out[1]= (char)((g <= 0)? 0 : (g >= 255)? 255 : g); - out[2]= (char)((b <= 0)? 0 : (b >= 255)? 255 : b); + col_r[0]= (char)((r <= 0)? 0 : (r >= 255)? 255 : r); + col_r[1]= (char)((g <= 0)? 0 : (g >= 255)? 255 : g); + col_r[2]= (char)((b <= 0)? 0 : (b >= 255)? 255 : b); } /* ********************************* color transforms ********************************* */ @@ -490,9 +490,9 @@ void rgb_byte_set_hue_float_offset(unsigned char rgb[3], float hue_offset) { float rgb_float[3]; - rgb_byte_to_float(rgb, rgb_float); + rgb_uchar_to_float(rgb_float, rgb); rgb_float_set_hue_float_offset(rgb_float, hue_offset); - rgb_float_to_byte(rgb_float, rgb); + rgb_float_to_uchar(rgb, rgb_float); } diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c index 18b0e9c6278..2c7b13b86a2 100644 --- a/source/blender/blenlib/intern/math_color_inline.c +++ b/source/blender/blenlib/intern/math_color_inline.c @@ -66,9 +66,9 @@ MINLINE void linearrgb_to_srgb_uchar3(unsigned char srgb[4], const float linear[ { int r, g, b; - r = 255 * linearrgb_to_srgb(linear[0]) * 255; - g = 255 * linearrgb_to_srgb(linear[1]) * 255; - b = 255 * linearrgb_to_srgb(linear[2]) * 255; + r = 255 * linearrgb_to_srgb(linear[0]); + g = 255 * linearrgb_to_srgb(linear[1]); + b = 255 * linearrgb_to_srgb(linear[2]); srgb[0] = FTOCHAR(r); srgb[1] = FTOCHAR(g); @@ -79,9 +79,9 @@ MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[ { int r, g, b, a; - r = 255 * linearrgb_to_srgb(linear[0]) * 255; - g = 255 * linearrgb_to_srgb(linear[1]) * 255; - b = 255 * linearrgb_to_srgb(linear[2]) * 255; + r = 255 * linearrgb_to_srgb(linear[0]); + g = 255 * linearrgb_to_srgb(linear[1]); + b = 255 * linearrgb_to_srgb(linear[2]); a = 255 * linear[3]; srgb[0] = FTOCHAR(r); |