1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include "pixman.h"
5 #include "gtk-utils.h"
6
7 int
main(int argc,char ** argv)8 main (int argc, char **argv)
9 {
10 #define WIDTH 200
11 #define HEIGHT 200
12
13 pixman_image_t *src_img;
14 pixman_image_t *mask_img;
15 pixman_image_t *dest_img;
16 pixman_trap_t trap;
17 pixman_color_t white = { 0x0000, 0xffff, 0x0000, 0xffff };
18 uint32_t *bits = malloc (WIDTH * HEIGHT * 4);
19 uint32_t *mbits = malloc (WIDTH * HEIGHT);
20
21 memset (mbits, 0, WIDTH * HEIGHT);
22 memset (bits, 0xff, WIDTH * HEIGHT * 4);
23
24 trap.top.l = pixman_int_to_fixed (50) + 0x8000;
25 trap.top.r = pixman_int_to_fixed (150) + 0x8000;
26 trap.top.y = pixman_int_to_fixed (30);
27
28 trap.bot.l = pixman_int_to_fixed (50) + 0x8000;
29 trap.bot.r = pixman_int_to_fixed (150) + 0x8000;
30 trap.bot.y = pixman_int_to_fixed (150);
31
32 mask_img = pixman_image_create_bits (PIXMAN_a8, WIDTH, HEIGHT, mbits, WIDTH);
33 src_img = pixman_image_create_solid_fill (&white);
34 dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8, WIDTH, HEIGHT, bits, WIDTH * 4);
35
36 pixman_add_traps (mask_img, 0, 0, 1, &trap);
37
38 pixman_image_composite (PIXMAN_OP_OVER,
39 src_img, mask_img, dest_img,
40 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
41
42 show_image (dest_img);
43
44 pixman_image_unref (src_img);
45 pixman_image_unref (dest_img);
46 free (bits);
47
48 return 0;
49 }
50