[gegl] tests: add a hgrad helper function to generate horizontal gradients



commit f9a8f24a4f8e86869be8ea4c40d7fde0f5955234
Author: Téo Mazars <teomazars gmail com>
Date:   Thu Nov 21 14:10:12 2013 +0100

    tests: add a hgrad helper function to generate horizontal gradients

 tests/buffer/buffer-test.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/tests/buffer/buffer-test.c b/tests/buffer/buffer-test.c
index a0c6c85..9fa1407 100644
--- a/tests/buffer/buffer-test.c
+++ b/tests/buffer/buffer-test.c
@@ -61,6 +61,7 @@ static void fill                  (GeglBuffer *buffer,
                                    gfloat      value);
 
 static void vgrad                 (GeglBuffer *buffer);
+static void hgrad                 (GeglBuffer *buffer);
 
 static void rectangle             (GeglBuffer *buffer,
                                    gint        x,
@@ -258,6 +259,33 @@ static void vgrad (GeglBuffer *buffer)
   g_free (buf);
 }
 
+static void hgrad (GeglBuffer *buffer)
+{
+  gfloat *buf;
+  gint x,y;
+  gint i;
+  gint width, height, x0, y0;
+  g_object_get (buffer, "x", &x0,
+                        "y", &y0,
+                        "width", &width,
+                        "height", &height,
+                        NULL);
+  buf = g_malloc (width*height*sizeof(gfloat));
+  gegl_buffer_get (buffer, NULL, 1.0, babl_format ("Y float"), buf, 0,
+                   GEGL_ABYSS_NONE);
+
+  i=0;
+  for (y=0;y<height;y++)
+    {
+      for (x=0;x<width;x++)
+        {
+          buf[i++]= (1.0*x)/width;
+        }
+    }
+  gegl_buffer_set (buffer, NULL, 0, babl_format ("Y float"), buf, GEGL_AUTO_ROWSTRIDE);
+  g_free (buf);
+}
+
 static void fill_rect (GeglBuffer          *buffer,
                        const GeglRectangle *roi,
                        gfloat               value


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