From 2b629762605aa483b8bafa16a90c5df08e3c7a66 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Tue, 19 Mar 2024 14:32:14 +0000 Subject: [PATCH] propgui: Port Color-To-Alpha GUI to GeglColor The two threshold color pick buttons needed to have a GeglColor parameter for their GimpPickerCallback rather than a const GimpRGB. This also fixes a crash caused by trying to free the GeglColor rather than unreferencing it. --- app/propgui/gimppropgui-color-to-alpha.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/propgui/gimppropgui-color-to-alpha.c b/app/propgui/gimppropgui-color-to-alpha.c index 88e1532751..e8634351f5 100644 --- a/app/propgui/gimppropgui-color-to-alpha.c +++ b/app/propgui/gimppropgui-color-to-alpha.c @@ -43,24 +43,30 @@ threshold_picked (GObject *config, gdouble x, gdouble y, const Babl *sample_format, - const GimpRGB *picked_color) + GeglColor *picked_color) { - GimpRGB *color; - gdouble threshold = 0.0; + GeglColor *color; + gdouble threshold = 0.0; + gdouble rgb[3]; + gdouble picked_rgb[3]; g_object_get (config, "color", &color, NULL); - threshold = MAX (threshold, fabs (picked_color->r - color->r)); - threshold = MAX (threshold, fabs (picked_color->g - color->g)); - threshold = MAX (threshold, fabs (picked_color->b - color->b)); + gegl_color_get_pixel (color, babl_format ("R'G'B' double"), rgb); + gegl_color_get_pixel (picked_color, babl_format ("R'G'B' double"), + picked_rgb); + + threshold = MAX (threshold, fabs (picked_rgb[0] - rgb[0])); + threshold = MAX (threshold, fabs (picked_rgb[1] - rgb[1])); + threshold = MAX (threshold, fabs (picked_rgb[2] - rgb[2])); g_object_set (config, identifier, threshold, NULL); - g_free (color); + g_object_unref (color); } GtkWidget *