3 #include "../test/utils.h"
7 pixbuf_from_argb32 (uint32_t *bits,
13 GdkPixbuf *pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE,
15 int p_stride = gdk_pixbuf_get_rowstride (pixbuf);
16 guint32 *p_bits = (guint32 *)gdk_pixbuf_get_pixels (pixbuf);
19 for (i = 0; i < height; ++i)
21 uint32_t *src_row = &bits[i * (stride / 4)];
22 uint32_t *dst_row = p_bits + i * (p_stride / 4);
24 a8r8g8b8_to_rgba_np (dst_row, src_row, width);
31 on_expose (GtkWidget *widget, GdkEventExpose *expose, gpointer data)
33 GdkPixbuf *pixbuf = data;
35 gdk_draw_pixbuf (widget->window, NULL,
37 gdk_pixbuf_get_width (pixbuf),
38 gdk_pixbuf_get_height (pixbuf),
46 show_image (pixman_image_t *image)
50 int width, height, stride;
53 char *arg0 = g_strdup ("pixman-test-program");
55 pixman_format_code_t format;
58 argv = (char **)&arg0;
60 gtk_init (&argc, &argv);
62 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
63 width = pixman_image_get_width (image);
64 height = pixman_image_get_height (image);
65 stride = pixman_image_get_stride (image);
67 gtk_window_set_default_size (GTK_WINDOW (window), width, height);
69 format = pixman_image_get_format (image);
71 if (format == PIXMAN_a8r8g8b8)
73 else if (format == PIXMAN_x8r8g8b8)
76 g_error ("Can't deal with this format: %x\n", format);
78 pixbuf = pixbuf_from_argb32 (pixman_image_get_data (image), has_alpha,
79 width, height, stride);
81 g_signal_connect (window, "expose_event", G_CALLBACK (on_expose), pixbuf);
82 g_signal_connect (window, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
84 gtk_widget_show (window);