From 0c26cd442acc587dbc83a73a2cf8f3673db0cfe2 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Tue, 5 Mar 2024 18:30:53 +0000 Subject: [PATCH] operations: Port semi-flatten to GeglColor After the color space invasion, the Semi-Flatten GUI was broken since it still used GimpRGB as its color property. This patch fixes this by porting to GeglColor. The GimpRGB conversion was also removed from the PDB interface since the GeglColor comes directly from GimpContext. --- app/operations/gimpoperationsemiflatten.c | 23 ++++++++++++++--------- app/operations/gimpoperationsemiflatten.h | 2 +- app/pdb/plug-in-compat-cmds.c | 4 +--- pdb/groups/plug_in_compat.pdb | 16 +++++++--------- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/app/operations/gimpoperationsemiflatten.c b/app/operations/gimpoperationsemiflatten.c index 1352f02bb2..b7dc8b94ec 100644 --- a/app/operations/gimpoperationsemiflatten.c +++ b/app/operations/gimpoperationsemiflatten.c @@ -73,7 +73,7 @@ gimp_operation_semi_flatten_class_init (GimpOperationSemiFlattenClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass); GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass); - GimpRGB white; + GeglColor *color; object_class->set_property = gimp_operation_semi_flatten_set_property; object_class->get_property = gimp_operation_semi_flatten_get_property; @@ -88,13 +88,13 @@ gimp_operation_semi_flatten_class_init (GimpOperationSemiFlattenClass *klass) point_class->process = gimp_operation_semi_flatten_process; - gimp_rgba_set (&white, 1.0, 1.0, 1.0, 1.0); + color = gegl_color_new ("white"); g_object_class_install_property (object_class, PROP_COLOR, - gimp_param_spec_rgb ("color", + gegl_param_spec_color ("color", _("Color"), _("The color"), - FALSE, &white, + /*FALSE,*/ color, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); } @@ -115,7 +115,7 @@ gimp_operation_semi_flatten_get_property (GObject *object, switch (property_id) { case PROP_COLOR: - gimp_value_set_rgb (value, &self->color); + g_value_set_object (value, self->color); break; default: @@ -135,7 +135,7 @@ gimp_operation_semi_flatten_set_property (GObject *object, switch (property_id) { case PROP_COLOR: - gimp_value_get_rgb (value, &self->color); + g_set_object (&self->color, g_value_get_object (value)); break; default: @@ -177,9 +177,14 @@ gimp_operation_semi_flatten_process (GeglOperation *operation, } else { - dest[RED] = src[RED] * alpha + self->color.r * (1.0 - alpha); - dest[GREEN] = src[GREEN] * alpha + self->color.g * (1.0 - alpha); - dest[BLUE] = src[BLUE] * alpha + self->color.b * (1.0 - alpha); + gdouble rgba[4]; + + gegl_color_get_rgba_with_space (self->color, &rgba[0], &rgba[1], + &rgba[2], &rgba[3], NULL); + + dest[RED] = src[RED] * alpha + rgba[0] * (1.0 - alpha); + dest[GREEN] = src[GREEN] * alpha + rgba[1] * (1.0 - alpha); + dest[BLUE] = src[BLUE] * alpha + rgba[2] * (1.0 - alpha); dest[ALPHA] = 1.0; } diff --git a/app/operations/gimpoperationsemiflatten.h b/app/operations/gimpoperationsemiflatten.h index be6311e630..7e537caf45 100644 --- a/app/operations/gimpoperationsemiflatten.h +++ b/app/operations/gimpoperationsemiflatten.h @@ -40,7 +40,7 @@ struct _GimpOperationSemiFlatten { GeglOperationPointFilter parent_instance; - GimpRGB color; + GeglColor *color; }; struct _GimpOperationSemiFlattenClass diff --git a/app/pdb/plug-in-compat-cmds.c b/app/pdb/plug-in-compat-cmds.c index 20721d7169..d65bf85717 100644 --- a/app/pdb/plug-in-compat-cmds.c +++ b/app/pdb/plug-in-compat-cmds.c @@ -3947,15 +3947,13 @@ plug_in_semiflatten_invoker (GimpProcedure *procedure, { GeglNode *node; GeglColor *color; - GimpRGB rgb; color = gimp_context_get_background (context); - gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL); node = gegl_node_new_child (NULL, "operation", "gimp:semi-flatten", - "color", &rgb, + "color", color, NULL); gimp_drawable_apply_operation (drawable, progress, diff --git a/pdb/groups/plug_in_compat.pdb b/pdb/groups/plug_in_compat.pdb index 368f319ca1..b2b519c835 100644 --- a/pdb/groups/plug_in_compat.pdb +++ b/pdb/groups/plug_in_compat.pdb @@ -2090,10 +2090,10 @@ sub plug_in_laplace { $help = <<'HELP'; This plug-in creates one-pixel wide edges from the -image, with the value proportional to the gradient. -It uses the Laplace operator (a 3x3 kernel with -8 -in the middle). The image has to be laplacered to -get useful results, a gauss_iir with 1.5 - 5.0 +image, with the value proportional to the gradient. +It uses the Laplace operator (a 3x3 kernel with -8 +in the middle). The image has to be laplacered to +get useful results, a gauss_iir with 1.5 - 5.0 depending on the noise in the image is best. HELP @@ -2195,7 +2195,7 @@ HELP g_object_unref (color); node = wrap_in_selection_bounds (node, drawable); - + gimp_drawable_apply_operation (drawable, progress, C_("undo-type", "Lens Distortion"), node); @@ -2424,7 +2424,7 @@ sub plug_in_mblur_inward { $blurb = 'Simulate movement using directional blur'; $help = <<'HELP'; -This procedure is equivalent to plug-in-mblur but +This procedure is equivalent to plug-in-mblur but performs the zoom blur inward instead of outward. HELP @@ -4058,15 +4058,13 @@ HELP { GeglNode *node; GeglColor *color; - GimpRGB rgb; color = gimp_context_get_background (context); - gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL); node = gegl_node_new_child (NULL, "operation", "gimp:semi-flatten", - "color", &rgb, + "color", color, NULL); gimp_drawable_apply_operation (drawable, progress,