[gegl] geglcolor: add api to set and get based on pixel in given bablformat



commit 3fc3a037afb006e2dc32c584d898c64fc97dd2d5
Author: Ãyvind KolÃs <pippin gimp org>
Date:   Thu Mar 15 22:02:36 2012 +0000

    geglcolor: add api to set and get based on pixel in given bablformat

 gegl/property-types/gegl-color.c |   27 ++++++++++++++++++++++++++-
 gegl/property-types/gegl-color.h |   24 ++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 1 deletions(-)
---
diff --git a/gegl/property-types/gegl-color.c b/gegl/property-types/gegl-color.c
index 679f62c..be8aee9 100644
--- a/gegl/property-types/gegl-color.c
+++ b/gegl/property-types/gegl-color.c
@@ -258,12 +258,37 @@ gegl_color_float4 (GeglColor *self)
 }
 #endif
 
+void         gegl_color_set_pixel              (GeglColor   *color,
+                                                Babl        *format,
+                                                const void  *pixel)
+{
+  g_return_if_fail (GEGL_IS_COLOR (color));
+  g_return_if_fail (format);
+  g_return_if_fail (pixel);
+
+  babl_process (
+      babl_fish (babl_format ("RGBA float"), format),
+      pixel, color->priv->rgba_color, 1);
+}
+
+void         gegl_color_get_pixel              (GeglColor   *color,
+                                                Babl        *format,
+                                                void        *pixel)
+{
+  g_return_if_fail (GEGL_IS_COLOR (color));
+  g_return_if_fail (format);
+  g_return_if_fail (pixel);
+
+  babl_process (
+      babl_fish (format, babl_format ("RGBA float")),
+      color->priv->rgba_color, pixel, 1);
+}
+
 void
 gegl_color_get_rgba4f (GeglColor   *color,
                        gfloat      *rgba)
 {
   gint i;
-
   g_return_if_fail (GEGL_IS_COLOR (color));
 
   for (i=0; i< 4; i++)
diff --git a/gegl/property-types/gegl-color.h b/gegl/property-types/gegl-color.h
index 155a857..adaf1ae 100644
--- a/gegl/property-types/gegl-color.h
+++ b/gegl/property-types/gegl-color.h
@@ -108,6 +108,30 @@ void         gegl_color_set_rgba               (GeglColor   *color,
                                                 gdouble      green,
                                                 gdouble      blue,
                                                 gdouble      alpha);
+/**
+ * gegl_color_set_pixel:
+ * @color: a #GeglColor
+ * @format: a babl pixel format
+ * @pixelx: pointer to a pixel
+ *
+ * Set a GeglColor from a pointer to a pixel and it's babl format.
+ */
+void         gegl_color_set_pixel              (GeglColor   *color,
+                                                Babl        *format,
+                                                const void  *pixel);
+/**
+ * gegl_color_get_pixel:
+ * @color: a #GeglColor
+ * @red: red value
+ * @green: green value
+ * @blue: blue value
+ * @alpha: alpha value
+ *
+ * Store the color in a pixel in the given format.
+ */
+void         gegl_color_get_pixel              (GeglColor   *color,
+                                                Babl        *format,
+                                                void        *pixel);
 
 /***
  */



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