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
main (int argc, char **argv)
75
uint32_t *dest = malloc (WIDTH * HEIGHT * 4);
76
pixman_image_t *src_img;
77
pixman_image_t *dest_img;
79
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 } }
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) };
87
pixman_transform_t trans = {
88
{ { 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) }
94
pixman_transform_t id = {
95
{ { pixman_fixed_1, 0, 0 },
96
{ 0, pixman_fixed_1, 0 },
97
{ 0, 0, pixman_fixed_1 } }
100
pixman_point_fixed_t c_inner;
101
pixman_point_fixed_t c_outer;
102
pixman_fixed_t r_inner;
103
pixman_fixed_t r_outer;
105
gtk_init (&argc, &argv);
107
for (i = 0; i < WIDTH * HEIGHT; ++i)
108
dest[i] = 0x3f0000ff; /* pale blue */
110
dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8,
115
c_inner.x = pixman_double_to_fixed (50.0);
116
c_inner.y = pixman_double_to_fixed (50.0);
117
c_outer.x = pixman_double_to_fixed (50.0);
118
c_outer.y = pixman_double_to_fixed (50.0);
120
r_outer = pixman_double_to_fixed (50.0);
122
src_img = pixman_image_create_radial_gradient (&c_inner, &c_outer,
127
src_img = pixman_image_create_linear_gradient (&p1, &p2,
131
pixman_image_set_transform (src_img, &trans);
133
pixman_image_composite (PIXMAN_OP_OVER, src_img, NULL, dest_img,
134
0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
136
printf ("0, 0: %x\n", dest[0]);
137
printf ("10, 10: %x\n", dest[10 * 10 + 10]);
138
printf ("w, h: %x\n", dest[(HEIGHT - 1) * 100 + (WIDTH - 1)]);
140
show_window (dest, WIDTH, HEIGHT, WIDTH);
142
pixman_image_unref (src_img);
143
pixman_image_unref (dest_img);