[babl] babl: make babl_format_with_space not crash with palette based formats
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] babl: make babl_format_with_space not crash with palette based formats
- Date: Thu, 6 Dec 2018 18:21:58 +0000 (UTC)
commit 2e31c01a0cb9f51fea850149f462c43093f97adb
Author: Øyvind Kolås <pippin gimp org>
Date: Thu Dec 6 19:19:40 2018 +0100
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]