3
#include "pixman-private.h" /* For image->bits.format
4
* FIXME: there should probably be public API for this
9
pixbuf_from_argb32 (uint32_t *bits,
15
GdkPixbuf *pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE,
17
int p_stride = gdk_pixbuf_get_rowstride (pixbuf);
18
guint32 *p_bits = (guint32 *)gdk_pixbuf_get_pixels (pixbuf);
21
for (h = 0; h < height; ++h)
23
for (w = 0; w < width; ++w)
25
uint32_t argb = bits[h * (stride / 4) + w];
27
char *pb = (char *)p_bits;
29
pb += h * p_stride + w * 4;
31
r = (argb & 0x00ff0000) >> 16;
32
g = (argb & 0x0000ff00) >> 8;
33
b = (argb & 0x000000ff) >> 0;
34
a = has_alpha? (argb & 0xff000000) >> 24 : 0xff;
59
on_expose (GtkWidget *widget, GdkEventExpose *expose, gpointer data)
61
GdkPixbuf *pixbuf = data;
63
gdk_draw_pixbuf (widget->window, NULL,
65
gdk_pixbuf_get_width (pixbuf),
66
gdk_pixbuf_get_height (pixbuf),
74
show_image (pixman_image_t *image)
78
int width, height, stride;
81
char *arg0 = g_strdup ("pixman-test-program");
83
pixman_format_code_t format;
86
argv = (char **)&arg0;
88
gtk_init (&argc, &argv);
90
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
91
width = pixman_image_get_width (image);
92
height = pixman_image_get_height (image);
93
stride = pixman_image_get_stride (image);
95
format = image->bits.format;
97
if (format == PIXMAN_a8r8g8b8)
99
else if (format == PIXMAN_x8r8g8b8)
102
g_error ("Can't deal with this format: %x\n", format);
104
pixbuf = pixbuf_from_argb32 (pixman_image_get_data (image), has_alpha,
105
width, height, stride);
107
g_signal_connect (window, "expose_event", G_CALLBACK (on_expose), pixbuf);
108
g_signal_connect (window, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
110
gtk_widget_show (window);