aboutsummaryrefslogtreecommitdiff
path: root/pixman/demos/convolution-test.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-02-16 17:16:41 +0000
committermarha <marha@users.sourceforge.net>2011-02-16 17:16:41 +0000
commit41723858b0effb450ce946297e5a606bc7348be2 (patch)
tree8831ace435ad11e06f196e62f0fb4d63fa740deb /pixman/demos/convolution-test.c
parent92fef6a3a6851ee123dd793788aac50c0831a964 (diff)
parent48d0dcbd5b7f80810ce259bc9ed6f57f99e27ca9 (diff)
downloadvcxsrv-41723858b0effb450ce946297e5a606bc7348be2.tar.gz
vcxsrv-41723858b0effb450ce946297e5a606bc7348be2.tar.bz2
vcxsrv-41723858b0effb450ce946297e5a606bc7348be2.zip
svn merge ^/branches/released .
Diffstat (limited to 'pixman/demos/convolution-test.c')
-rw-r--r--pixman/demos/convolution-test.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/pixman/demos/convolution-test.c b/pixman/demos/convolution-test.c
new file mode 100644
index 000000000..da284af7b
--- /dev/null
+++ b/pixman/demos/convolution-test.c
@@ -0,0 +1,47 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "pixman.h"
+#include "gtk-utils.h"
+
+int
+main (int argc, char **argv)
+{
+#define WIDTH 200
+#define HEIGHT 200
+
+#define d2f pixman_double_to_fixed
+
+ uint32_t *src = malloc (WIDTH * HEIGHT * 4);
+ uint32_t *mask = malloc (WIDTH * HEIGHT * 4);
+ uint32_t *dest = malloc (WIDTH * HEIGHT * 4);
+ pixman_fixed_t convolution[] =
+ {
+ d2f (3), d2f (3),
+ d2f (0.5), d2f (0.5), d2f (0.5),
+ d2f (0.5), d2f (0.5), d2f (0.5),
+ d2f (0.5), d2f (0.5), d2f (0.5),
+ };
+ pixman_image_t *simg, *mimg, *dimg;
+
+ int i;
+
+ for (i = 0; i < WIDTH * HEIGHT; ++i)
+ {
+ src[i] = 0x7f007f00;
+ mask[i] = (i % 256) * 0x01000000;
+ dest[i] = 0;
+ }
+
+ simg = pixman_image_create_bits (PIXMAN_a8r8g8b8, WIDTH, HEIGHT, src, WIDTH * 4);
+ mimg = pixman_image_create_bits (PIXMAN_a8r8g8b8, WIDTH, HEIGHT, mask, WIDTH * 4);
+ dimg = pixman_image_create_bits (PIXMAN_a8r8g8b8, WIDTH, HEIGHT, dest, WIDTH * 4);
+
+ pixman_image_set_filter (mimg, PIXMAN_FILTER_CONVOLUTION,
+ convolution, 11);
+
+ pixman_image_composite (PIXMAN_OP_OVER, simg, mimg, dimg, 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
+
+ show_image (dimg);
+
+ return 0;
+}