mirror of
https://github.com/brl/mutter.git
synced 2024-11-10 07:56:14 -05:00
[color] Fix HLS to RGB colorspace conversion
The HLS to RGB conversion in case the S value is zero is: R = G = B = luminance ClutterColor uses a byte (0 to 255) for the R, G and B channels encoding, while luminance is expressed using a floating point value in the closed interval [0, 1]; thus the case above becomes: R = G = B = (luminance * 255) The clutter_color_from_hls() code is missing the final step of de-normalizing the luminance value, and so it breaks the roundtrip colorspace conversion between RGB and HLS. Fixes bug: http://bugzilla.openedhand.com/show_bug.cgi?id=1695
This commit is contained in:
parent
db2fda9c43
commit
ad7dcc9896
@ -244,15 +244,10 @@ clutter_color_from_hls (ClutterColor *color,
|
|||||||
|
|
||||||
hue /= 360.0;
|
hue /= 360.0;
|
||||||
|
|
||||||
if (luminance == 0)
|
|
||||||
{
|
|
||||||
color->red = color->green = color->blue = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (saturation == 0)
|
if (saturation == 0)
|
||||||
{
|
{
|
||||||
color->red = color->green = color->blue = luminance;
|
color->red = color->green = color->blue = (luminance * 255);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,6 +266,7 @@ clutter_color_from_hls (ClutterColor *color,
|
|||||||
{
|
{
|
||||||
if (tmp3[i] < 0)
|
if (tmp3[i] < 0)
|
||||||
tmp3[i] += 1.0;
|
tmp3[i] += 1.0;
|
||||||
|
|
||||||
if (tmp3[i] > 1)
|
if (tmp3[i] > 1)
|
||||||
tmp3[i] -= 1.0;
|
tmp3[i] -= 1.0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user