7
pixbuf_from_argb32 (uint32_t *bits,
12
GdkPixbuf *pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE,
14
int p_stride = gdk_pixbuf_get_rowstride (pixbuf);
15
guint32 *p_bits = (guint32 *)gdk_pixbuf_get_pixels (pixbuf);
18
for (h = 0; h < height; ++h)
20
for (w = 0; w < width; ++w)
22
uint32_t argb = bits[h * stride + w];
25
abgr = (argb & 0xff000000) |
28
(argb & 0xff0000) >> 16;
30
p_bits[h * (p_stride / 4) + w] = abgr;
38
on_expose (GtkWidget *widget, GdkEventExpose *expose, gpointer data)
40
GdkPixbuf *pixbuf = data;
42
gdk_draw_pixbuf (widget->window, NULL,
44
gdk_pixbuf_get_width (pixbuf),
45
gdk_pixbuf_get_height (pixbuf),
53
show_window (uint32_t *bits, int w, int h, int stride)
57
GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
59
pixbuf = pixbuf_from_argb32 (bits, w, h, stride);
61
g_signal_connect (window, "expose_event", G_CALLBACK (on_expose), pixbuf);
62
g_signal_connect (window, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
64
gtk_widget_show (window);
70
7
main (int argc, char **argv)
75
12
uint32_t *dest = malloc (WIDTH * HEIGHT * 4);
79
16
pixman_gradient_stop_t stops[2] =
81
{ pixman_int_to_fixed (0), { 0xffff, 0x0000, 0x0000, 0xffff } },
82
{ pixman_int_to_fixed (1), { 0xffff, 0xffff, 0x0000, 0xffff } }
18
{ pixman_int_to_fixed (0), { 0xffff, 0xeeee, 0xeeee, 0xeeee } },
19
{ pixman_int_to_fixed (1), { 0xffff, 0x1111, 0x1111, 0x1111 } }
84
pixman_point_fixed_t p1 = { 0, 0 };
85
pixman_point_fixed_t p2 = { pixman_int_to_fixed (WIDTH),
86
pixman_int_to_fixed (HEIGHT) };
21
pixman_point_fixed_t p1 = { pixman_double_to_fixed (0), 0 };
22
pixman_point_fixed_t p2 = { pixman_double_to_fixed (WIDTH / 8.),
23
pixman_int_to_fixed (0) };
87
24
pixman_transform_t trans = {
88
25
{ { pixman_double_to_fixed (2), pixman_double_to_fixed (0.5), pixman_double_to_fixed (-100), },
89
{ pixman_double_to_fixed (0), pixman_double_to_fixed (2), pixman_double_to_fixed (0), },
90
{ pixman_double_to_fixed (0), pixman_double_to_fixed (0.004990), pixman_double_to_fixed (1.0) }
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) }
102
39
pixman_fixed_t r_inner;
103
40
pixman_fixed_t r_outer;
105
gtk_init (&argc, &argv);
107
42
for (i = 0; i < WIDTH * HEIGHT; ++i)
108
dest[i] = 0x3f0000ff; /* pale blue */
43
dest[i] = 0x4f00004f; /* pale blue */
110
45
dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8,
120
55
r_outer = pixman_double_to_fixed (50.0);
122
src_img = pixman_image_create_radial_gradient (&c_inner, &c_outer,
57
src_img = pixman_image_create_conical_gradient (&c_inner, r_inner,
60
src_img = pixman_image_create_conical_gradient (&c_inner, r_inner,
62
src_img = pixman_image_create_linear_gradient (&c_inner, &c_outer,
127
67
src_img = pixman_image_create_linear_gradient (&p1, &p2,
131
pixman_image_set_transform (src_img, &trans);
70
pixman_image_set_transform (src_img, &id);
71
pixman_image_set_repeat (src_img, PIXMAN_REPEAT_PAD);
133
73
pixman_image_composite (PIXMAN_OP_OVER, src_img, NULL, dest_img,
134
0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
74
0, 0, 0, 0, 0, 0, 10 * WIDTH, HEIGHT);
136
76
printf ("0, 0: %x\n", dest[0]);
137
77
printf ("10, 10: %x\n", dest[10 * 10 + 10]);
138
78
printf ("w, h: %x\n", dest[(HEIGHT - 1) * 100 + (WIDTH - 1)]);
140
show_window (dest, WIDTH, HEIGHT, WIDTH);
80
show_image (dest_img);
142
82
pixman_image_unref (src_img);
143
83
pixman_image_unref (dest_img);