• Advertisement
Sign in to follow this  

converting colour formats

This topic is 4341 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does any1 have smart suggestions on how to convert a format of RGBA(floats) to an unsigned int? The colours work like opengl with 1.0f being 255(full entensity) and 0.0f being no intensity. So i have R = 0.5f; G = 0.5f; B = 0.5f; A = 0.5f; And then if i convert this i should get R G B A 0x3F3F3F3F So i need a function like unsigned int color = GetColor(0.5f,0.5f,0.5f,0.5f); Thanks

Share this post


Link to post
Share on other sites
Advertisement
Nevermind i got a solution, i dont know how fast or efficient it is but here:

unsigned int GetColor()
{
return ((unsigned int(255.0f*a)) << 24) + ((unsigned int(255.0f*r))<< 16) + ((unsigned int(255.0f*g))<< 8) +(unsigned int(255.0f*b));
};

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement