+
+void clg_gdk_pixbuf_swap_rgb (GdkPixbuf *pixbuf)
+{
+
+ int n_channels = gdk_pixbuf_get_n_channels (pixbuf);
+ guchar *p, *pixels = gdk_pixbuf_get_pixels (pixbuf);
+ int width = gdk_pixbuf_get_width (pixbuf);
+ int height = gdk_pixbuf_get_height (pixbuf);
+ int rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+ int x, y;
+
+ g_assert (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8);
+ g_assert (gdk_pixbuf_get_has_alpha (pixbuf));
+ g_assert (n_channels == 4);
+
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ p = pixels + y * rowstride + x * n_channels;
+ guint tmp = p[0];
+ p[0] = p[2];
+ p[2] = tmp;
+ }
+ }
+}
+