# converting colour formats

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

## 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 on other sites
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 on other sites
just as long as you're aware that the actual ordering of your final result is ARGB not RGBA.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633295
• Total Posts
3011245
• ### Who's Online (See full list)

There are no registered users currently online

×