Commit 65ee44c6 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

changed the hue_saturation() function as suggested by Martin Weber in bug

2003-03-07  Sven Neumann  <sven@gimp.org>

	* app/base/hue-saturation.[ch]: changed the hue_saturation()
	function as suggested by Martin Weber in bug #94067.  Changed the
	function signature to use a typed instead of a void pointer.

	* app/tools/gimphuesaturationtool.c (gimp_hue_saturation_tool_map):
	cast the hue_saturation() function pointer to a GimpImageMapApplyFunc
	here.
parent 4f76aed6
2003-03-07 Sven Neumann <sven@gimp.org>
* app/base/hue-saturation.[ch]: changed the hue_saturation()
function as suggested by Martin Weber in bug #94067. Changed the
function signature to use a typed instead of a void pointer.
* app/tools/gimphuesaturationtool.c (gimp_hue_saturation_tool_map):
cast the hue_saturation() function pointer to a GimpImageMapApplyFunc
here.
2003-03-07 Sven Neumann <sven@gimp.org>
 
* tools/pdbgen/pdb/guides.pdb: allow to add guides with an offset
......@@ -75,10 +75,11 @@ hue_saturation_calculate_transfers (HueSaturation *hs)
/* Lightness */
value = (hs->lightness[0] + hs->lightness[hue + 1]) * 127.0 / 100.0;
value = CLAMP (value, -255, 255);
if (value < 0)
hs->lightness_transfer[hue][i] = (unsigned char) ((i * (255 + value)) / 255);
hs->lightness_transfer[hue][i] = (guchar) ((i * (255 + value)) / 255);
else
hs->lightness_transfer[hue][i] = (unsigned char) (i + ((255 - i) * value) / 255);
hs->lightness_transfer[hue][i] = (guchar) (i + ((255 - i) * value) / 255);
/* Saturation */
value = (hs->saturation[0] + hs->saturation[hue + 1]) * 255.0 / 100.0;
......@@ -91,25 +92,22 @@ hue_saturation_calculate_transfers (HueSaturation *hs)
colors more or less evenly. For enhancing the color in photos,
the new behavior is exactly what you want. It's hard for me
to imagine a case in which the old behavior is better.
*/
*/
hs->saturation_transfer[hue][i] = CLAMP ((i * (255 + value)) / 255, 0, 255);
}
}
void
hue_saturation (PixelRegion *srcPR,
PixelRegion *destPR,
gpointer data)
hue_saturation (PixelRegion *srcPR,
PixelRegion *destPR,
HueSaturation *hs)
{
HueSaturation *hs;
guchar *src, *s;
guchar *dest, *d;
gint alpha;
gint w, h;
gint r, g, b;
gint hue;
hs = (HueSaturation *) data;
guchar *src, *s;
guchar *dest, *d;
gint alpha;
gint w, h;
gint r, g, b;
gint hue;
/* Set the transfer arrays (for speed) */
h = srcPR->h;
......@@ -122,6 +120,7 @@ hue_saturation (PixelRegion *srcPR,
w = srcPR->w;
s = src;
d = dest;
while (w--)
{
r = s[RED_PIX];
......@@ -130,18 +129,22 @@ hue_saturation (PixelRegion *srcPR,
gimp_rgb_to_hls_int (&r, &g, &b);
if (r < 43)
hue = (r + (128 / 6)) / 6;
if (r < 21)
hue = 0;
else if (r < 85)
else if (r < 64)
hue = 1;
else if (r < 128)
else if (r < 106)
hue = 2;
else if (r < 171)
else if (r < 149)
hue = 3;
else if (r < 213)
else if (r < 192)
hue = 4;
else
else if (r < 234)
hue = 5;
else
hue = 0;
r = hs->hue_transfer[hue][r];
g = hs->lightness_transfer[hue][g];
......
......@@ -38,7 +38,7 @@ void hue_saturation_partition_reset (HueSaturation *hs,
void hue_saturation_calculate_transfers (HueSaturation *hs);
void hue_saturation (PixelRegion *srcPR,
PixelRegion *destPR,
gpointer data);
HueSaturation *hs);
#endif /* __HUE_SATURATION_H__ */
......@@ -228,7 +228,7 @@ gimp_hue_saturation_tool_map (GimpImageMapTool *image_map_tool)
hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool);
gimp_image_map_apply (image_map_tool->image_map,
hue_saturation,
(GimpImageMapApplyFunc) hue_saturation,
hs_tool->hue_saturation);
}
......
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