1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| RGBQUAD CxImage::HSLtoRGB(RGBQUAD lHSLColor)
{
//<F. Livraghi> fixed implementation for HSL2RGB routine
float h,s,l;
float m1,m2;
BYTE r,g,b;
h = (float)lHSLColor.rgbRed * 360.0f/255.0f;
s = (float)lHSLColor.rgbGreen/255.0f;
l = (float)lHSLColor.rgbBlue/255.0f;
if (l <= 0.5) m2 = l * (1+s);
else m2 = l + s - l*s;
m1 = 2 * l - m2;
if (s == 0) {
r=g=b=(BYTE)(l*255.0f);
} else {
r = (BYTE)(HueToRGB(m1,m2,h+120) * 255.0f);
g = (BYTE)(HueToRGB(m1,m2,h) * 255.0f);
b = (BYTE)(HueToRGB(m1,m2,h-120) * 255.0f);
}
RGBQUAD rgb = {b,g,r,0};
return rgb;
} |
Partager