[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32463] trunk/blender/source/blender/ blenlib/intern/math_color.c: hex color input wasnt clamped.
Campbell Barton
ideasman42 at gmail.com
Thu Oct 14 10:15:11 CEST 2010
Revision: 32463
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32463
Author: campbellbarton
Date: 2010-10-14 10:15:10 +0200 (Thu, 14 Oct 2010)
Log Message:
-----------
hex color input wasnt clamped.
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/intern/math_color.c
Modified: trunk/blender/source/blender/blenlib/intern/math_color.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_color.c 2010-10-14 06:29:17 UTC (rev 32462)
+++ trunk/blender/source/blender/blenlib/intern/math_color.c 2010-10-14 08:15:10 UTC (rev 32463)
@@ -177,13 +177,16 @@
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);
}
}
More information about the Bf-blender-cvs
mailing list