diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2011-01-18 19:16:39 -0500 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2011-02-15 09:25:17 -0500 |
commit | 7dfe845786920d50c6f93165ef6f539e6f4d1b53 (patch) | |
tree | 48d7bd4ee4c896b6182e07225e65542e26db6a4a /demos/convolution-test.c | |
parent | 8e4100260bbdb827abc45a2a5e352a53246fe614 (diff) |
Move all the GTK+ based test programs to a new subdir, "demos"
This separates the test suite from the random gtk+ using test
programs. "demos" is somewhat misleading because the programs there
are not particularly exciting (with the possible exception of
composite-test which shows off all the compositing operators).
Diffstat (limited to 'demos/convolution-test.c')
-rw-r--r-- | demos/convolution-test.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/demos/convolution-test.c b/demos/convolution-test.c new file mode 100644 index 0000000..da284af --- /dev/null +++ b/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; +} |