diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-01-19 12:22:23 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-01-19 12:22:23 +0400 |
commit | 4786541285f6f190922ec9857753d620c528f181 (patch) | |
tree | 4eb00a6e2fe307d1147e7cb1d0a6785915c0432f /source/blender/blenlib/intern/math_color_inline.c | |
parent | 65fca39f77981db5a649d942f308fa457d18cb41 (diff) |
add utility functions linearrgb_to_srgb_uchar4,
linearrgb_to_srgb_uchar3, was being done inline.
Diffstat (limited to 'source/blender/blenlib/intern/math_color_inline.c')
-rw-r--r-- | source/blender/blenlib/intern/math_color_inline.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c index 1247632cf79..18b0e9c6278 100644 --- a/source/blender/blenlib/intern/math_color_inline.c +++ b/source/blender/blenlib/intern/math_color_inline.c @@ -62,6 +62,34 @@ 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]) +{ + 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; + + srgb[0] = FTOCHAR(r); + srgb[1] = FTOCHAR(g); + srgb[2] = FTOCHAR(b); +} + +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]) * 255; + g = 255 * linearrgb_to_srgb(linear[1]) * 255; + b = 255 * linearrgb_to_srgb(linear[2]) * 255; + a = 255 * linear[3]; + + srgb[0] = FTOCHAR(r); + srgb[1] = FTOCHAR(g); + srgb[2] = FTOCHAR(b); + srgb[3] = FTOCHAR(a); +} + /* predivide versions to work on associated/premultipled alpha. if this should be done or not depends on the background the image will be composited over, ideally you would never do color space conversion on an image with alpha |