[gdk-pixbuf] Add a simple test for gdk_pixbuf_composite



commit 1011a0d68a985ec1cdc0d10a30a1c3619d133be0
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Mar 12 18:58:20 2015 -0400

    Add a simple test for gdk_pixbuf_composite

 tests/Makefile.am        |    7 +++++++
 tests/pixbuf-composite.c |   45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fc00d4e..cf5eb6d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -36,6 +36,7 @@ test_programs =                       \
        pixbuf-short-gif-write          \
        pixbuf-save                     \
        pixbuf-readonly-to-mutable      \
+       pixbuf-composite                \
        $(NULL)
 
 dist_installed_test_data =             \
@@ -108,6 +109,12 @@ pixbuf_readonly_to_mutable_SOURCES =       \
        test-common.h                   \
        $(NULL)
 
+pixbuf_composite_SOURCES =             \
+       pixbuf-composite.c              \
+       test-common.c                   \
+       test-common.h                   \
+       $(NULL)
+
 pixbuf_resource_SOURCES =              \
        pixbuf-resource.c               \
        test-common.c                   \
diff --git a/tests/pixbuf-composite.c b/tests/pixbuf-composite.c
new file mode 100644
index 0000000..ecc3f81
--- /dev/null
+++ b/tests/pixbuf-composite.c
@@ -0,0 +1,45 @@
+#include <gdk-pixbuf.h>
+#include "test-common.h"
+
+static void
+test_composite (void)
+{
+  GdkPixbuf *red, *green, *out, *ref, *sub;
+
+  red = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 24, 24);
+  gdk_pixbuf_fill (red, 0xff000000);
+
+  green = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 12, 12);
+  gdk_pixbuf_fill (green, 0x00ff0000);
+
+  out = gdk_pixbuf_copy (red);
+
+  gdk_pixbuf_composite (green, out,
+                        0, 0, 12, 12,
+                        0, 0, 1.0, 1.0,
+                        GDK_INTERP_NEAREST,
+                        255);
+
+  ref = gdk_pixbuf_copy (red);
+  sub = gdk_pixbuf_new_subpixbuf (ref, 0, 0, 12, 12);
+
+  gdk_pixbuf_fill (sub, 0x00ff0000);
+
+  g_assert (pixdata_equal (out, ref, NULL));
+
+  g_object_unref (red);
+  g_object_unref (green);
+  g_object_unref (out);
+  g_object_unref (ref);
+  g_object_unref (sub);
+}
+
+int
+main (int argc, char *argv[])
+{
+  g_test_init (&argc, &argv, NULL);
+
+  g_test_add_func ("/pixbuf/composite", test_composite);
+
+  return g_test_run ();
+}


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