mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-05 01:34:48 +00:00
Changed: Don't try to convert string to CRGBA if less than 3 integers
This commit is contained in:
parent
9a9dda21ad
commit
f76acd744f
1 changed files with 16 additions and 10 deletions
|
@ -734,17 +734,23 @@ void CRGBA::buildFromHLS(float h, float l, float s)
|
||||||
|
|
||||||
CRGBA CRGBA::stringToRGBA( const char *ptr )
|
CRGBA CRGBA::stringToRGBA( const char *ptr )
|
||||||
{
|
{
|
||||||
if (!ptr)
|
if (ptr)
|
||||||
return NLMISC::CRGBA::White;
|
{
|
||||||
|
int r = 255, g = 255, b = 255, a = 255;
|
||||||
|
|
||||||
|
// we need at least 3 integer values to consider string is valid
|
||||||
|
if (sscanf( ptr, "%d %d %d %d", &r, &g, &b, &a ) >= 3)
|
||||||
|
{
|
||||||
|
clamp( r, 0, 255 );
|
||||||
|
clamp( g, 0, 255 );
|
||||||
|
clamp( b, 0, 255 );
|
||||||
|
clamp( a, 0, 255 );
|
||||||
|
|
||||||
int r = 255, g = 255, b = 255, a = 255;
|
return CRGBA( r,g,b,a );
|
||||||
sscanf( ptr, "%d %d %d %d", &r, &g, &b, &a );
|
}
|
||||||
clamp( r, 0, 255 );
|
}
|
||||||
clamp( g, 0, 255 );
|
|
||||||
clamp( b, 0, 255 );
|
return NLMISC::CRGBA::White;
|
||||||
clamp( a, 0, 255 );
|
|
||||||
|
|
||||||
return CRGBA( r,g,b,a );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CRGBA::toString() const
|
std::string CRGBA::toString() const
|
||||||
|
|
Loading…
Reference in a new issue