From 54c46ea175aa21d846631ec964351e0525a1bbeb Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Tue, 26 Nov 2024 21:50:20 +0000 Subject: [PATCH] app/xcf: Don't override channel opacity on XCF load When loading channels, the alpha value is stored separately from the RGB value as "opacity". After the switch to GeglColor, we were overriding the opacity values by always using "R'G'B" format, so the loaded opacity was always reset to 100%. This patch pulls the opacity value before setting the color, then restores the opacity afterwards. --- app/xcf/xcf-load.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c index 3b1bcc872a..a6b49e2c79 100644 --- a/app/xcf/xcf-load.c +++ b/app/xcf/xcf-load.c @@ -2324,22 +2324,34 @@ xcf_load_channel_props (XcfInfo *info, case PROP_COLOR: { - guchar col[3]; + guchar col[3]; + gdouble opacity; + + /* Load existing opacity */ + opacity = gimp_channel_get_opacity (*channel); xcf_read_int8 (info, (guint8 *) col, 3); gegl_color_set_pixel ((*channel)->color, babl_format ("R'G'B' u8"), col); + + gimp_channel_set_opacity (*channel, opacity, FALSE); } break; case PROP_FLOAT_COLOR: { - gfloat col[3]; + gfloat col[3]; + gdouble opacity; + + /* Load existing opacity */ + opacity = gimp_channel_get_opacity (*channel); xcf_read_float (info, col, 3); /* TODO: is the channel color in sRGB or in the image's color space? */ gegl_color_set_pixel ((*channel)->color, babl_format ("R'G'B' float"), col); + + gimp_channel_set_opacity (*channel, opacity, FALSE); } break;