From 2e31c01a0cb9f51fea850149f462c43093f97adb Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Thu, 6 Dec 2018 19:19:40 +0100 Subject: [PATCH] babl: make babl_format_with_space not crash with palette based formats Now, both palettes referred to by their string name and palettes passed directly in with a cast get passed through without modification, for correct behavior their palette entries should also be re-created (the only way to read out the palette is currently to do an exhaustive buffer conversion.) --- babl/babl-format.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/babl/babl-format.c b/babl/babl-format.c index e532417..019744a 100644 --- a/babl/babl-format.c +++ b/babl/babl-format.c @@ -727,13 +727,6 @@ babl_format_with_space (const char *encoding, const Babl *space) if (BABL_IS_BABL (example_format)) { - if (babl_format_is_palette (example_format)) - { - /* XXX we should allocate a new palette name, and - duplicate the path data, converted for new space - */ - return example_format; - } encoding = babl_get_name (example_format); if (babl_format_get_space (example_format) != babl_space ("sRGB")) { @@ -756,10 +749,20 @@ babl_format_with_space (const char *encoding, const Babl *space) { return NULL; } + example_format = babl_format (encoding); + if (space == babl_space("sRGB")) - return babl_format (encoding); + return example_format; + + if (babl_format_is_palette (example_format)) + { + /* XXX we should allocate a new palette name, and + duplicate the path data, converted for new space + */ + return example_format; + } - return format_new_from_format_with_space (babl_format (encoding), space); + return format_new_from_format_with_space (example_format, space); } int -- 2.30.2