[gegl] introspection: add gegl_format helper



commit 12375fe31d146990e2dc741e21739f5a7355d5b1
Author: Daniel Sabo <DanielSabo gmail com>
Date:   Fri Sep 20 10:19:37 2013 -0700

    introspection: add gegl_format helper
    
    Functions to convert to/from a GValue object containing a Babl*.

 gegl/gegl-introspection-support.c |   26 ++++++++++++++++++++++++++
 gegl/gegl-introspection-support.h |   23 +++++++++++++++++++++++
 2 files changed, 49 insertions(+), 0 deletions(-)
---
diff --git a/gegl/gegl-introspection-support.c b/gegl/gegl-introspection-support.c
index 818e2f9..2176a0d 100644
--- a/gegl/gegl-introspection-support.c
+++ b/gegl/gegl-introspection-support.c
@@ -34,6 +34,32 @@
 #include "graph/gegl-node.h"
 #include "gegl-introspection-support.h"
 
+GValue *
+gegl_format (const char *format_name)
+{
+  GValue *result = g_new0 (GValue, 1);
+
+  g_value_init (result, G_TYPE_POINTER);
+  g_value_set_pointer (result, (gpointer) babl_format (format_name));
+
+  return result;
+}
+
+const gchar *
+gegl_format_get_name (GValue *value)
+{
+  Babl *format;
+
+  if (!(G_TYPE_POINTER == G_VALUE_TYPE(value)))
+    return NULL;
+  format = g_value_get_pointer (value);
+
+  if (!format)
+    return NULL;
+
+  return babl_get_name (format);
+}
+
 GeglRectangle *
 gegl_node_introspectable_get_bounding_box (GeglNode *node)
 {
diff --git a/gegl/gegl-introspection-support.h b/gegl/gegl-introspection-support.h
index 5303ce1..e26ed38 100644
--- a/gegl/gegl-introspection-support.h
+++ b/gegl/gegl-introspection-support.h
@@ -30,6 +30,29 @@
 #include <gegl-types.h>
 
  /**
+ * gegl_format:
+ * @format_name: A Babl format name, e.g. "RGBA float"
+ *
+ * Returns a value sutable to pass to the GeglBuffer constructor
+ * or any other property that expects a Babl format.
+ *
+ * Return value: (transfer full) (allow-none): the format pointer
+ */
+
+GValue *
+gegl_format (const char *format_name);
+
+ /**
+ * gegl_format_get_name:
+ * @format: A Babl pointer
+ *
+ * Return value: (transfer none) (allow-none): the format name
+ */
+
+const gchar *
+gegl_format_get_name (GValue *format);
+
+ /**
  * gegl_node_introspectable_get_bounding_box:
  * @node: a #GeglNode
  *


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