From e6e7fa8f8dc82edd0822f97ffc80417ecd423fab Mon Sep 17 00:00:00 2001 From: Jehan Date: Sun, 11 Feb 2024 17:05:11 +0100 Subject: [PATCH] libgimpcolor: work around babl_format_has_alpha() bug with some formats. With "HSVA" and a few others, the function was not returning the right value (it could not see it was encoding alpha channel. I had fixed it on babl directly with commit a28309c yet I had forgotten to push it! Let's just add some #ifdef and a comment. --- libgimpcolor/gimpcolor.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libgimpcolor/gimpcolor.c b/libgimpcolor/gimpcolor.c index 6f2ea7887f..a517ded47f 100644 --- a/libgimpcolor/gimpcolor.c +++ b/libgimpcolor/gimpcolor.c @@ -334,6 +334,18 @@ gimp_babl_format_get_with_alpha (const Babl *format) return format; model = babl_get_name (babl_format_get_model (format)); + + /* Special-cased because babl_format_has_alpha() doesn't see that these + * formats encode alpha. This has been fixed with commit a28309c. + * TODO: remove this test when babl 0.1.110 is released and we depend on it. + */ +#if BABL_MINOR_VERSION == 1 && BABL_MICRO_VERSION <= 108 + if (g_strcmp0 (model, "HCYA") == 0 || + g_strcmp0 (model, "HSLA") == 0 || + g_strcmp0 (model, "HSVA") == 0) + return format; +#endif + /* Assuming we use Babl formats with same type for all components. */ type = babl_get_name (babl_format_get_type (format, 0));