I'm having some interesting outcomes from clutter_stage_read_pixels and
gdk_pixbuf_save

If I attempt to read the stage (which is embedded gtk) BEFORE the gtk widget
is shown, I can read it successfully and the screenshot is successful. If I
try to read it AFTER the clutter-gtk widget has been shown I get nothing but
black in the saved image. Look here for the example code shown below (taken
from http://github.com/bpeel/tractordodge/tree/master/tractordodge.c):

int width = clutter_actor_get_width (stage);
int height = clutter_actor_get_height (stage);

guchar *data = clutter_stage_read_pixels (CLUTTER_STAGE (stage),
             0, 0, width, height);

guchar *p;
GdkPixbuf *pb;

for (p = data + width * height * 4; p > data; p -= 3)
*(--p) = 255;

pb = gdk_pixbuf_new_from_data (data, GDK_COLORSPACE_RGB, TRUE,
         8, width, height, width * 4,
         (GdkPixbufDestroyNotify) g_free,
         NULL);

gdk_pixbuf_save (pb, "screenie.png", "png", NULL, NULL);

g_object_unref (pb);

Reply via email to