mirror of https://github.com/GNOME/gimp.git
app: use GEGL/babl to convert to HSL in gimp_operation_hue_saturation_map().
This commit is contained in:
parent
fc0d21b91c
commit
77420957d8
|
@ -282,21 +282,22 @@ gimp_operation_hue_saturation_process (GeglOperation *operation,
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_operation_hue_saturation_map (GimpHueSaturationConfig *config,
|
gimp_operation_hue_saturation_map (GimpHueSaturationConfig *config,
|
||||||
const GimpRGB *color,
|
GeglColor *color,
|
||||||
GimpHueRange range,
|
GimpHueRange range)
|
||||||
GimpRGB *result)
|
|
||||||
{
|
{
|
||||||
GimpHSL hsl;
|
const Babl *format;
|
||||||
|
gdouble hsl[4];
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_HUE_SATURATION_CONFIG (config));
|
g_return_if_fail (GIMP_IS_HUE_SATURATION_CONFIG (config));
|
||||||
g_return_if_fail (color != NULL);
|
g_return_if_fail (GEGL_IS_COLOR (color));
|
||||||
g_return_if_fail (result != NULL);
|
|
||||||
|
|
||||||
gimp_rgb_to_hsl (color, &hsl);
|
format = gegl_color_get_format (color);
|
||||||
|
format = babl_format_with_space ("HSLA double", format);
|
||||||
|
gegl_color_get_pixel (color, format, hsl);
|
||||||
|
|
||||||
hsl.h = map_hue (config, range, hsl.h);
|
hsl[0] = map_hue (config, range, hsl[0]);
|
||||||
hsl.s = map_saturation (config, range, hsl.s);
|
hsl[1] = map_saturation (config, range, hsl[1]);
|
||||||
hsl.l = map_lightness (config, range, hsl.l);
|
hsl[2] = map_lightness (config, range, hsl[2]);
|
||||||
|
|
||||||
gimp_hsl_to_rgb (&hsl, result);
|
gegl_color_set_pixel (color, format, hsl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,9 +50,8 @@ struct _GimpOperationHueSaturationClass
|
||||||
GType gimp_operation_hue_saturation_get_type (void) G_GNUC_CONST;
|
GType gimp_operation_hue_saturation_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
void gimp_operation_hue_saturation_map (GimpHueSaturationConfig *config,
|
void gimp_operation_hue_saturation_map (GimpHueSaturationConfig *config,
|
||||||
const GimpRGB *color,
|
GeglColor *color,
|
||||||
GimpHueRange range,
|
GimpHueRange range);
|
||||||
GimpRGB *result);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_OPERATION_HUE_SATURATION_H__ */
|
#endif /* __GIMP_OPERATION_HUE_SATURATION_H__ */
|
||||||
|
|
|
@ -49,30 +49,26 @@ hue_saturation_config_notify (GObject *object,
|
||||||
GtkWidget *color_area)
|
GtkWidget *color_area)
|
||||||
{
|
{
|
||||||
GimpHueSaturationConfig *config = GIMP_HUE_SATURATION_CONFIG (object);
|
GimpHueSaturationConfig *config = GIMP_HUE_SATURATION_CONFIG (object);
|
||||||
GimpHueRange range;
|
|
||||||
GeglColor *color;
|
GeglColor *color;
|
||||||
GimpRGB rgb;
|
GimpHueRange range;
|
||||||
|
|
||||||
static const GimpRGB default_colors[7] =
|
static const gchar *default_colors[7] =
|
||||||
{
|
{
|
||||||
{ 0, 0, 0, },
|
"black", /* (0, 0, 0) */
|
||||||
{ 1.0, 0, 0, },
|
"red", /* (1, 0, 0) */
|
||||||
{ 1.0, 1.0, 0, },
|
"yellow", /* (1, 1, 0) */
|
||||||
{ 0, 1.0, 0, },
|
"lime", /* (0, 1, 0) */
|
||||||
{ 0, 1.0, 1.0, },
|
"aqua", /* (0, 1, 1) */
|
||||||
{ 0, 0, 1.0, },
|
"blue", /* (0, 0, 1) */
|
||||||
{ 1.0, 0, 1.0, }
|
"fuchsia", /* (1, 0, 1) */
|
||||||
};
|
};
|
||||||
|
|
||||||
range = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (color_area),
|
range = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (color_area), "hue-range"));
|
||||||
"hue-range"));
|
color = gegl_color_new (default_colors[range]);
|
||||||
rgb = default_colors[range];
|
|
||||||
|
|
||||||
gimp_operation_hue_saturation_map (config, &rgb, range, &rgb);
|
gimp_operation_hue_saturation_map (config, color, range);
|
||||||
|
|
||||||
color = gegl_color_new (NULL);
|
|
||||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
|
||||||
gimp_color_area_set_color (GIMP_COLOR_AREA (color_area), color);
|
gimp_color_area_set_color (GIMP_COLOR_AREA (color_area), color);
|
||||||
|
|
||||||
g_object_unref (color);
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue