Changed: Allow to parse HTML color format in CRGBA::stringToRGBA

--HG--
branch : develop
This commit is contained in:
kervala 2017-01-02 09:48:40 +01:00
parent dde8fd723a
commit 88d345e857

View file

@ -748,6 +748,17 @@ CRGBA CRGBA::stringToRGBA( const char *ptr )
return CRGBA( r,g,b,a ); return CRGBA( r,g,b,a );
} }
// we need at least 3 hexadecimal values to consider string is valid
if (sscanf(ptr, "#%02x%02x%02x%02x", &r, &g, &b, &a) >= 3)
{
clamp(r, 0, 255);
clamp(g, 0, 255);
clamp(b, 0, 255);
clamp(a, 0, 255);
return CRGBA(r, g, b, a);
}
} }
return NLMISC::CRGBA::White; return NLMISC::CRGBA::White;