Issue #3015: Space invasion: Using Levels Pick white point for all…

… channels doesn't work.
This commit is contained in:
Jehan 2024-10-29 00:07:42 +01:00
parent 366ba98efe
commit 496c799e2e
4 changed files with 21 additions and 14 deletions

View file

@ -603,15 +603,15 @@ gimp_levels_config_stretch_channel (GimpLevelsConfig *config,
static gdouble
gimp_levels_config_input_from_color (GimpLevelsConfig *config,
GimpHistogramChannel channel,
const Babl *target_space,
GeglColor *color)
{
gdouble rgba[4];
/* TODO: should I get colors within a specific space? */
if (config->trc == GIMP_TRC_LINEAR)
gegl_color_get_pixel (color, babl_format ("RGBA double"), rgba);
gegl_color_get_pixel (color, babl_format_with_space ("RGBA double", target_space), rgba);
else
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), rgba);
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", target_space), rgba);
switch (channel)
{
@ -643,6 +643,7 @@ gimp_levels_config_input_from_color (GimpLevelsConfig *config,
void
gimp_levels_config_adjust_by_colors (GimpLevelsConfig *config,
GimpHistogramChannel channel,
const Babl *target_space,
GeglColor *black,
GeglColor *gray,
GeglColor *white)
@ -653,14 +654,14 @@ gimp_levels_config_adjust_by_colors (GimpLevelsConfig *config,
if (black)
{
config->low_input[channel] = gimp_levels_config_input_from_color (config, channel, black);
config->low_input[channel] = gimp_levels_config_input_from_color (config, channel, target_space, black);
g_object_notify (G_OBJECT (config), "low-input");
}
if (white)
{
config->high_input[channel] = gimp_levels_config_input_from_color (config, channel, white);
config->high_input[channel] = gimp_levels_config_input_from_color (config, channel, target_space, white);
g_object_notify (G_OBJECT (config), "high-input");
}
@ -677,7 +678,7 @@ gimp_levels_config_adjust_by_colors (GimpLevelsConfig *config,
gegl_color_get_pixel (gray, babl_format ("RGBA double"), rgba);
lightness = GIMP_RGB_LUMINANCE (rgba[0], rgba[1], rgba[2]);
input = gimp_levels_config_input_from_color (config, channel, gray);
input = gimp_levels_config_input_from_color (config, channel, target_space, gray);
range = config->high_input[channel] - config->low_input[channel];
if (range <= 0)

View file

@ -74,6 +74,7 @@ void gimp_levels_config_stretch_channel (GimpLevelsConfig *config,
GimpHistogramChannel channel);
void gimp_levels_config_adjust_by_colors (GimpLevelsConfig *config,
GimpHistogramChannel channel,
const Babl *target_space,
GeglColor *black,
GeglColor *gray,
GeglColor *white);

View file

@ -248,6 +248,7 @@ white_graypoint_in_red_levels (GimpTestFixture *fixture,
gimp_levels_config_adjust_by_colors (config,
channel,
NULL,
black,
gray,
white);

View file

@ -776,18 +776,19 @@ static void
levels_input_adjust_by_color (GimpLevelsConfig *config,
guint value,
GimpHistogramChannel channel,
const Babl *target_space,
GeglColor *color)
{
switch (value & 0xF)
{
case PICK_LOW_INPUT:
gimp_levels_config_adjust_by_colors (config, channel, color, NULL, NULL);
gimp_levels_config_adjust_by_colors (config, channel, target_space, color, NULL, NULL);
break;
case PICK_GAMMA:
gimp_levels_config_adjust_by_colors (config, channel, NULL, color, NULL);
gimp_levels_config_adjust_by_colors (config, channel, target_space, NULL, color, NULL);
break;
case PICK_HIGH_INPUT:
gimp_levels_config_adjust_by_colors (config, channel, NULL, NULL, color);
gimp_levels_config_adjust_by_colors (config, channel, target_space, NULL, NULL, color);
break;
default:
break;
@ -802,9 +803,12 @@ gimp_levels_tool_color_picked (GimpFilterTool *color_tool,
const Babl *sample_format,
GeglColor *color)
{
GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (color_tool);
GimpLevelsConfig *config = GIMP_LEVELS_CONFIG (filter_tool->config);
guint value = GPOINTER_TO_UINT (identifier);
GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (color_tool);
GimpLevelsConfig *config = GIMP_LEVELS_CONFIG (filter_tool->config);
guint value = GPOINTER_TO_UINT (identifier);
const Babl *target_space = NULL;
target_space = gimp_drawable_get_space (GIMP_TOOL (filter_tool)->drawables->data);
if (value & PICK_ALL_CHANNELS &&
gimp_babl_format_get_base_type (sample_format) == GIMP_RGB)
@ -832,12 +836,12 @@ gimp_levels_tool_color_picked (GimpFilterTool *color_tool,
channel <= GIMP_HISTOGRAM_BLUE;
channel++)
{
levels_input_adjust_by_color (config, value, channel, color);
levels_input_adjust_by_color (config, value, channel, target_space, color);
}
}
else
{
levels_input_adjust_by_color (config, value, config->channel, color);
levels_input_adjust_by_color (config, value, config->channel, target_space, color);
}
}