app: special-case achromatic pixels in hue-saturation

Issue #10756, without this grayscale pixels are affected by
the red part of the manipulation configuration, after this
change pixels with original saturation == 0.0 are only
changed by the master adjustment.
This commit is contained in:
Øyvind Kolås 2024-02-15 23:00:54 +01:00 committed by Øyvind "pippin" Kolås
parent 96e7673348
commit 5a0a3a1263
1 changed files with 21 additions and 3 deletions

View File

@ -162,6 +162,17 @@ map_lightness (GimpHueSaturationConfig *config,
return value + (v * (1.0 - value)); return value + (v * (1.0 - value));
} }
static inline gdouble
map_lightness_achromatic (GimpHueSaturationConfig *config, gdouble value)
{
gdouble v = config->lightness[GIMP_HUE_RANGE_ALL];
if (v < 0)
return value * (v + 1.0);
else
return value + (v * (1.0 - value));
}
static gboolean static gboolean
gimp_operation_hue_saturation_process (GeglOperation *operation, gimp_operation_hue_saturation_process (GeglOperation *operation,
void *in_buf, void *in_buf,
@ -258,9 +269,16 @@ gimp_operation_hue_saturation_process (GeglOperation *operation,
} }
else else
{ {
hsl.h = map_hue (config, hue, hsl.h); if (hsl.s <= 0.0)
hsl.s = map_saturation (config, hue, hsl.s); {
hsl.l = map_lightness (config, hue, hsl.l); hsl.l = map_lightness_achromatic (config, hsl.l);
}
else
{
hsl.h = map_hue (config, hue, hsl.h);
hsl.l = map_lightness (config, hue, hsl.l);
hsl.s = map_saturation (config, hue, hsl.s);
}
} }
gimp_hsl_to_rgb (&hsl, &rgb); gimp_hsl_to_rgb (&hsl, &rgb);