[babl] babl: add a new symbol babl_format_get_encoding



commit a9234712f4c7b986502a83954021ecb57b73e7f7
Author: Øyvind Kolås <pippin gimp org>
Date:   Fri Jul 20 16:14:18 2018 +0200

    babl: add a new symbol babl_format_get_encoding
    
    This returns the string passed in to babl_format_new - without the space
    suffix that babl_get_name does for non-sRGB formats.

 babl/babl-format.c | 17 +++++++++++++++++
 babl/babl.h        |  6 ++++++
 export-symbols     |  1 +
 3 files changed, 24 insertions(+)
---
diff --git a/babl/babl-format.c b/babl/babl-format.c
index d295165..51e5458 100644
--- a/babl/babl-format.c
+++ b/babl/babl-format.c
@@ -710,6 +710,23 @@ const Babl * babl_format_get_space      (const Babl *format)
 
 BABL_CLASS_IMPLEMENT (format)
 
+const char *
+babl_format_get_encoding (const Babl *babl)
+{
+  static char ret[256];
+  const char *name = babl_get_name (babl);
+  strcpy (&ret[0], name);
+  if (babl_format_get_space (babl) != babl_space ("sRGB"))
+    {
+
+      if (strstr (ret, "-space"))
+        *strstr (ret, "-space") = '\0';
+
+      name = &ret[0];
+    }
+  return name;
+}
+
 const Babl *
 babl_format_with_space (const char *name, const Babl *space)
 {
diff --git a/babl/babl.h b/babl/babl.h
index 6d58aac..12b09c1 100644
--- a/babl/babl.h
+++ b/babl/babl.h
@@ -570,6 +570,12 @@ babl_space_from_rgbxyz_matrix (const char *name,
                                const Babl *trc_green,
                                const Babl *trc_blue);
 
+/**
+ * babl_format_get_encoding:
+ *
+ * Returns the components and data type, without space suffix.
+ */
+const char * babl_format_get_encoding (const Babl *babl);
 
 #ifdef __cplusplus
 }
diff --git a/export-symbols b/export-symbols
index d246e3d..476238e 100644
--- a/export-symbols
+++ b/export-symbols
@@ -14,6 +14,7 @@ babl_format_get_model
 babl_format_get_n_components
 babl_format_get_space
 babl_format_get_type
+babl_format_get_encoding
 babl_format_has_alpha
 babl_format_is_format_n
 babl_format_is_palette


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]