• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  #include <stdio.h>
2  #include <stdlib.h>
3  #include "pixman.h"
4  #include "gtk-utils.h"
5  
6  int
main(int argc,char ** argv)7  main (int argc, char **argv)
8  {
9  #define WIDTH 400
10  #define HEIGHT 200
11  
12      uint32_t *dest = malloc (WIDTH * HEIGHT * 4);
13      pixman_image_t *src_img;
14      pixman_image_t *dest_img;
15      int i;
16      pixman_gradient_stop_t stops[2] =
17  	{
18  	    { pixman_int_to_fixed (0), { 0x0000, 0x0000, 0xffff, 0xffff } },
19  	    { pixman_int_to_fixed (1), { 0xffff, 0x1111, 0x1111, 0xffff } }
20  	};
21      pixman_point_fixed_t p1 = { pixman_double_to_fixed (50), 0 };
22      pixman_point_fixed_t p2 = { pixman_double_to_fixed (200), 0 };
23  #if 0
24      pixman_transform_t trans = {
25  	{ { pixman_double_to_fixed (2), pixman_double_to_fixed (0.5), pixman_double_to_fixed (-100), },
26  	  { pixman_double_to_fixed (0), pixman_double_to_fixed (3), pixman_double_to_fixed (0), },
27  	  { pixman_double_to_fixed (0), pixman_double_to_fixed (0.000), pixman_double_to_fixed (1.0) }
28  	}
29      };
30  #else
31      pixman_transform_t trans = {
32  	{ { pixman_fixed_1, 0, 0 },
33  	  { 0, pixman_fixed_1, 0 },
34  	  { 0, 0, pixman_fixed_1 } }
35      };
36  #endif
37  
38  #if 0
39      pixman_point_fixed_t c_inner;
40      pixman_point_fixed_t c_outer;
41      pixman_fixed_t r_inner;
42      pixman_fixed_t r_outer;
43  #endif
44  
45      for (i = 0; i < WIDTH * HEIGHT; ++i)
46  	dest[i] = 0xff00ff00;
47  
48      dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8,
49  					 WIDTH, HEIGHT,
50  					 dest,
51  					 WIDTH * 4);
52  
53  #if 0
54      c_inner.x = pixman_double_to_fixed (50.0);
55      c_inner.y = pixman_double_to_fixed (50.0);
56      c_outer.x = pixman_double_to_fixed (50.0);
57      c_outer.y = pixman_double_to_fixed (50.0);
58      r_inner = 0;
59      r_outer = pixman_double_to_fixed (50.0);
60  
61      src_img = pixman_image_create_conical_gradient (&c_inner, r_inner,
62  						    stops, 2);
63  #endif
64  #if 0
65      src_img = pixman_image_create_conical_gradient (&c_inner, r_inner,
66  						    stops, 2);
67      src_img = pixman_image_create_linear_gradient (&c_inner, &c_outer,
68  						   r_inner, r_outer,
69  						   stops, 2);
70  #endif
71  
72      src_img = pixman_image_create_linear_gradient  (&p1, &p2,
73  						    stops, 2);
74  
75      pixman_image_set_transform (src_img, &trans);
76      pixman_image_set_repeat (src_img, PIXMAN_REPEAT_NONE);
77  
78      pixman_image_composite (PIXMAN_OP_OVER, src_img, NULL, dest_img,
79  			    0, 0, 0, 0, 0, 0, 10 * WIDTH, HEIGHT);
80  
81      printf ("0, 0: %x\n", dest[0]);
82      printf ("10, 10: %x\n", dest[10 * 10 + 10]);
83      printf ("w, h: %x\n", dest[(HEIGHT - 1) * 100 + (WIDTH - 1)]);
84  
85      show_image (dest_img);
86  
87      pixman_image_unref (src_img);
88      pixman_image_unref (dest_img);
89      free (dest);
90  
91      return 0;
92  }
93