Re: Grab a pixmap of a window

On Thu, 2008-02-07 at 09:21 -0500, muppet wrote:

Daniel Kasak wrote:
Is there an easy way to grab a pixmap of an entire window's contents
( minus window manager decorations )? I know I can ask the window for
it's allocation details and grab a screenshot of the entire screen and
cut out the bit that I want. But is there a better way?

my $screenie = Gtk2::Gdk::Pixbuf->get_from_drawable ($toplevel->window);

Thanks muppet :) I got it working slightly differently:

my $alloc = $widget->allocation;

my $pixbuf = Gtk2::Gdk::Pixbuf->get_from_drawable(
    $alloc->x, $alloc->y,
    0, 0,
    $alloc->width, $alloc->height

$pixbuf->save( "/home/dan/test.png", "png" );

Now I have another question. The point of getting the image was to turn
it into a PDF. I'm using PDF::ReportWriter for this at the moment, but
I'm curious if I can do it with Cairo. I can't find any documentation on
creating a surface from a png ( to use with the PDF backend ). The only
thing I've found is the c function cairo_image_surface_create_from_png
( see the image demo at ). Is this
available from the Perl bindings? Anyway, no great worries as I have it
working currently.

Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: dkasak nusconsulting com au

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]