
www.Usenet.com
| <-- __Chronological__ --> | <-- __Thread__ --> |
I'm trying to implement an algorithm to convert floating point colors in the range 0.0 to 1.0 to integer colors in the range 0x0-0xff. The first attempt was something like this (please ignore any typos, I'm paraphrasing...):
unsigned int R = G = B = A = 0; void SetColor(float r, float g, float b, float a) { R = (float)(r * 255.f); if(R > 255) R = 255; G = (float)(g * 255.f); if(G > 255) G = 255; B = (float)(b * 255.f); if(B > 255) B = 255; A = (float)(a * 255.f); if(A > 255) A = 255; }
| <-- __Chronological__ --> | <-- __Thread__ --> |