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-19 14:04:51 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-01-19 14:04:51 +0400
commita87c5eb52cd4951b138f518bf12d498bc5e5eb8a (patch)
tree7b023285cb2ff41924d9e390f3d6a25715284d14 /source/blender/blenlib/intern/math_color.c
parent47514a0d7129ba49cd9ad039a886c52909ea565d (diff)
use color conversions functions in more places.
also add rgba_float_to_uchar, rgba_uchar_to_float
Diffstat (limited to 'source/blender/blenlib/intern/math_color.c')
-rw-r--r--source/blender/blenlib/intern/math_color.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index 31d69ba68b4..94dbdf9fe58 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -344,6 +344,14 @@ void rgb_uchar_to_float(float col_r[3], const unsigned char col_ub[3])
col_r[2]= ((float)col_ub[2]) / 255.0f;
}
+void rgba_uchar_to_float(float col_r[4], const unsigned char col_ub[4])
+{
+ 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;
+ col_r[3]= ((float)col_ub[3]) / 255.0f;
+}
+
void rgb_float_to_uchar(unsigned char col_r[3], const float col_f[3])
{
int r, g, b;
@@ -357,6 +365,21 @@ void rgb_float_to_uchar(unsigned char col_r[3], const float col_f[3])
col_r[2]= (char)((b <= 0)? 0 : (b >= 255)? 255 : b);
}
+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);
+}
+
/* ********************************* color transforms ********************************* */