From c408d44e030c44639aeab28a9f25bb43444c5ab3 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Mon, 4 Nov 2024 02:05:57 +0000 Subject: [PATCH] plug-ins: Fix crash for bumpmaps without alpha channels 979a3c3c assumed that all bumpmaps in the Lighting Effects plug-in would have an alpha channel, which is not always the case. This patch adds a check via gimp_drawable_has_alpha (), and sets the babl format accordingly. --- plug-ins/lighting/lighting-image.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plug-ins/lighting/lighting-image.c b/plug-ins/lighting/lighting-image.c index 838fb5a076..d360f8853c 100644 --- a/plug-ins/lighting/lighting-image.c +++ b/plug-ins/lighting/lighting-image.c @@ -397,15 +397,19 @@ bumpmap_setup (GimpDrawable *bumpmap) { if (bumpmap) { + gboolean has_alpha = gimp_drawable_has_alpha (bumpmap); + if (! bump_buffer) { bump_buffer = gimp_drawable_get_buffer (bumpmap); } if (gimp_drawable_is_rgb (bumpmap)) - bump_format = babl_format ("R'aG'aB'aA u8"); + bump_format = has_alpha ? babl_format ("R'aG'aB'aA u8") : + babl_format ("R'G'B' u8"); else - bump_format = babl_format ("Y'aA u8"); /* FIXME */ + bump_format = has_alpha ? babl_format ("Y'aA u8") : /* FIXME */ + babl_format ("Y' u8"); } }