Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-01-20 16:34:00 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-01-20 16:34:00 +0400
commitc8037fb56ae31f4edfdb4a0b1832a299e411e133 (patch)
tree4186b7de996464946792e9ce9dfabe0659c5ebf8 /source/blender/blenlib
parentc5adacff83e9d1c4a849ec80d05e7e988436df69 (diff)
parentf0fc8c22bb9f8fa4cab232fd88b9aed27ca6637f (diff)
svn merge ^/trunk/blender -r43530:43554
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_math_color.h3
-rw-r--r--source/blender/blenlib/intern/math_color.c22
-rw-r--r--source/blender/blenlib/intern/math_color_inline.c26
3 files changed, 12 insertions, 39 deletions
diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h
index 453f1258272..f4d6882b5d8 100644
--- a/source/blender/blenlib/BLI_math_color.h
+++ b/source/blender/blenlib/BLI_math_color.h
@@ -91,6 +91,9 @@ MINLINE void linearrgb_to_srgb_v4(float srgb[4], const float linear[4]);
MINLINE void srgb_to_linearrgb_predivide_v4(float linear[4], const float srgb[4]);
MINLINE void linearrgb_to_srgb_predivide_v4(float srgb[4], const float linear[4]);
+MINLINE void linearrgb_to_srgb_uchar3(unsigned char srgb[3], const float linear[3]);
+MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[4]);
+
void BLI_init_srgb_conversion(void);
/************************** Other *************************/
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index 94dbdf9fe58..ca2aeca8f36 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -354,30 +354,12 @@ void rgba_uchar_to_float(float col_r[4], const unsigned char col_ub[4])
void rgb_float_to_uchar(unsigned char col_r[3], const float col_f[3])
{
- int r, g, b;
-
- r= (int)(col_f[0] * 255.0f);
- g= (int)(col_f[1] * 255.0f);
- b= (int)(col_f[2] * 255.0f);
-
- 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);
+ F3TOCHAR3(col_f, col_r);
}
void rgba_float_to_uchar(unsigned char col_r[4], const float col_f[4])
{
- int r, g, b, a;
-
- r= (int)(col_f[0] * 255.0f);
- g= (int)(col_f[1] * 255.0f);
- b= (int)(col_f[2] * 255.0f);
- a= (int)(col_f[3] * 255.0f);
-
- 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);
- col_r[3]= (char)((a <= 0)? 0 : (a >= 255)? 255 : a);
+ F4TOCHAR4(col_f, col_r);
}
/* ********************************* color transforms ********************************* */
diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c
index 2c7b13b86a2..386452ed592 100644
--- a/source/blender/blenlib/intern/math_color_inline.c
+++ b/source/blender/blenlib/intern/math_color_inline.c
@@ -62,32 +62,20 @@ MINLINE void linearrgb_to_srgb_v4(float srgb[4], const float linear[4])
srgb[3] = linear[3];
}
-MINLINE void linearrgb_to_srgb_uchar3(unsigned char srgb[4], const float linear[4])
+MINLINE void linearrgb_to_srgb_uchar3(unsigned char srgb[3], const float linear[3])
{
- int r, g, b;
+ float srgb_f[3];
- 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);
- srgb[2] = FTOCHAR(b);
+ linearrgb_to_srgb_v3_v3(srgb_f, linear);
+ F3TOCHAR3(srgb_f, srgb);
}
MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[4])
{
- int r, g, b, a;
-
- 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];
+ float srgb_f[4];
- srgb[0] = FTOCHAR(r);
- srgb[1] = FTOCHAR(g);
- srgb[2] = FTOCHAR(b);
- srgb[3] = FTOCHAR(a);
+ linearrgb_to_srgb_v4(srgb_f, linear);
+ F4TOCHAR4(srgb_f, srgb);
}
/* predivide versions to work on associated/premultipled alpha. if this should