Domsodi Gergely said:
Is there an easier way to obtain a GdkPixbuf from a Gtk2::Gdk::Window? I want to make a screenshot of a window, and save it to a file. Or am I
heading to a very bad direction? :-) no, it's the right direction, there are just some issues. gdk_pixbuf_get_from_drawable() uses gdk_drawable_get_image() internally (since that's the basic way to get pixels back from the X server) and converts it to a Pixbuf for you. this is very handy because GdkPixbuf is a lot easier to use and even has methods to write image files in common formats. http://developer.gnome.org/doc/API/2.0/gdk/gdk-Pixbufs.html#gdk-pixbuf-get-from-drawable http://developer.gnome.org/doc/API/2.0/gdk-pixbuf/gdk-pixbuf-file-saving.html however, in another turn that surprises me, neither get_from_drawable nor get_from_image are implemented in gtk2-perl! in fact, several functions from gdk's header that defines pixbuf-related utilities never made it into the initial revision of GdkPixbuf.xs, probably because of bugs in the genfirstpass.pl script used to turn the headers into xs files. the attached patch adds the functions. i haven't tested them, but the bindings are trivial and i really don't see where there should be any problems. again, it will be in cvs by the time you read this. -- muppet <scott at asofyet dot org>
Attachment:
gdk-pixbuf-utils.patch
Description: Binary data