From: Øyvind Kolås Date: Thu, 6 Dec 2018 18:19:40 +0000 (+0100) Subject: babl: make babl_format_with_space not crash with palette based formats X-Git-Tag: archive/raspbian/1%0.1.106-3+rpi1^2~15^2~12^2~14 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=2e31c01a0cb9f51fea850149f462c43093f97adb;p=babl.git 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.) --- 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