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>2010-10-14 12:15:10 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-10-14 12:15:10 +0400
commit3d73a37b64774ce246c0151f952b83a6fc78f2ac (patch)
tree257395bc481270ab2e0cfb4de010a57dffd09ce2 /source/blender/blenlib/intern/math_color.c
parentfbf208d63fe0ba9770cb225726eb94888aa0994d (diff)
hex color input wasnt clamped.
Diffstat (limited to 'source/blender/blenlib/intern/math_color.c')
-rw-r--r--source/blender/blenlib/intern/math_color.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index 09a6b5992db..c481744156a 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -177,13 +177,16 @@ void ycc_to_rgb(float y, float cb, float cr, float *lr, float *lg, float *lb, in
void hex_to_rgb(char *hexcol, float *r, float *g, float *b)
{
unsigned int ri, gi, bi;
-
+
if (hexcol[0] == '#') hexcol++;
-
- if (sscanf(hexcol, "%02x%02x%02x", &ri, &gi, &bi)) {
+
+ if (sscanf(hexcol, "%02x%02x%02x", &ri, &gi, &bi)==3) {
*r = ri / 255.0f;
*g = gi / 255.0f;
*b = bi / 255.0f;
+ CLAMP(*r, 0.0f, 1.0f);
+ CLAMP(*g, 0.0f, 1.0f);
+ CLAMP(*b, 0.0f, 1.0f);
}
}