diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-25 19:56:17 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-25 19:56:17 +0400 |
commit | 3f56ee3da7ca0d9500529e970e836fb2ff97068c (patch) | |
tree | a55ea48b916c1c13b581a9abb3ea3cedbfb24552 /source/blender/blenlib/intern/math_color.c | |
parent | fffe342d87548bc94f9258a1c8a2f7473b4bd8b2 (diff) |
style cleanup: issues missed last commit
Diffstat (limited to 'source/blender/blenlib/intern/math_color.c')
-rw-r--r-- | source/blender/blenlib/intern/math_color.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 7103ef6106d..abd9c1ea5b8 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -17,7 +17,7 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - + * * The Original Code is: some of this file. * * ***** END GPL LICENSE BLOCK ***** @@ -129,18 +129,18 @@ void rgb_to_ycc(float r, float g, float b, float *ly, float *lcb, float *lcr, in switch (colorspace) { case BLI_YCC_ITU_BT601: y = (0.257f * sr) + (0.504f * sg) + (0.098f * sb) + 16.0f; - cb = (-0.148f * sr)-(0.291f * sg) + (0.439f * sb) + 128.0f; - cr = (0.439f * sr)-(0.368f * sg)-(0.071f * sb) + 128.0f; + cb = (-0.148f * sr) - (0.291f * sg) + (0.439f * sb) + 128.0f; + cr = (0.439f * sr) - (0.368f * sg) - (0.071f * sb) + 128.0f; break; case BLI_YCC_ITU_BT709: y = (0.183f * sr) + (0.614f * sg) + (0.062f * sb) + 16.0f; - cb = (-0.101f * sr)-(0.338f * sg) + (0.439f * sb) + 128.0f; - cr = (0.439f * sr)-(0.399f * sg)-(0.040f * sb) + 128.0f; + cb = (-0.101f * sr) - (0.338f * sg) + (0.439f * sb) + 128.0f; + cr = (0.439f * sr) - (0.399f * sg) - (0.040f * sb) + 128.0f; break; case BLI_YCC_JFIF_0_255: y = (0.299f * sr) + (0.587f * sg) + (0.114f * sb); - cb = (-0.16874f * sr)-(0.33126f * sg) + (0.5f * sb) + 128.0f; - cr = (0.5f * sr)-(0.41869f * sg)-(0.08131f * sb) + 128.0f; + cb = (-0.16874f * sr) - (0.33126f * sg) + (0.5f * sb) + 128.0f; + cr = (0.5f * sr) - (0.41869f * sg) - (0.08131f * sb) + 128.0f; break; default: assert(!"invalid colorspace"); @@ -230,13 +230,17 @@ void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv) rc = (cmax - r) / cdelta; gc = (cmax - g) / cdelta; bc = (cmax - b) / cdelta; - if (r == cmax) + + if (r == cmax) { h = bc - gc; - else - if (g == cmax) - h = 2.0f + rc - bc; - else - h = 4.0f + gc - rc; + } + else if (g == cmax) { + h = 2.0f + rc - bc; + } + else { + h = 4.0f + gc - rc; + } + h = h * 60.0f; if (h < 0.0f) h += 360.0f; @@ -331,13 +335,13 @@ unsigned int rgb_to_cpack(float r, float g, float b) void cpack_to_rgb(unsigned int col, float *r, float *g, float *b) { - *r = (float)((col)&0xFF); + *r = (float)((col) & 0xFF); *r /= 255.0f; - *g = (float)(((col) >> 8)&0xFF); + *g = (float)(((col) >> 8) & 0xFF); *g /= 255.0f; - *b = (float)(((col) >> 16)&0xFF); + *b = (float)(((col) >> 16) & 0xFF); *b /= 255.0f; } |