Commit 48741d2c authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

avoid the ambiguity of returning different values for the same color and

2007-09-28  Sven Neumann  <sven@gimp.org>

	* libgimpcolor/gimpcolorspace.c (gimp_hsv_to_rgb_int): avoid the
	ambiguity of returning different values for the same color and
	limit the Hue output range to [0..359].

svn path=/trunk/; revision=23681
parent bba7d1e0
2007-09-28 Sven Neumann <sven@gimp.org>
* libgimpcolor/gimpcolorspace.c (gimp_hwb_to_rgb): avoid the
ambiguity of returning different values for the same color and
limit the Hue output range to [0..359].
2007-09-28 Sven Neumann <sven@gimp.org>
* plug-ins/common/tiff-load.c (load_rgba): use
......@@ -526,7 +526,7 @@ gimp_hwb_to_rgb (gdouble hue,
*
* The function changes the arguments to point to the HSV value
* corresponding, with the returned values in the following
* ranges: H [0, 360], S [0, 255], V [0, 255].
* ranges: H [0, 359], S [0, 255], V [0, 255].
**/
void
gimp_rgb_to_hsv_int (gint *red,
......@@ -561,7 +561,9 @@ gimp_rgb_to_hsv_int (gint *red,
s = delta / v;
if (s == 0.0)
h = 0.0;
{
h = 0.0;
}
else
{
if (r == v)
......@@ -573,6 +575,7 @@ gimp_rgb_to_hsv_int (gint *red,
if (h < 0.0)
h += 360.0;
if (h > 360.0)
h -= 360.0;
}
......@@ -580,6 +583,10 @@ gimp_rgb_to_hsv_int (gint *red,
*red = ROUND (h);
*green = ROUND (s * 255.0);
*blue = ROUND (v);
/* avoid the ambiguity of returning different values for the same color */
if (*red == 360)
*red = 0;
}
/**
......@@ -616,9 +623,9 @@ gimp_hsv_to_rgb_int (gint *hue,
v = *value / 255.0;
if (h == 360)
h_temp = 0;
h_temp = 0;
else
h_temp = h;
h_temp = h;
h_temp = h_temp / 60.0;
i = floor (h_temp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment