Re: making a screen shot



Uwe Voelker wrote:

Hello,

how do I make a screen shot from a Gtk2 window? It's Gtk2::MozEmbed if
that matters.

I want to make it within the application, no external tools.


I haven't tested this code in a while but it should still work (or at
least get you closer)

This assumes $width and $height are the dimensions of the image you want
to save.

# create blank pixbuf to hold the image
my $gdkpixbuf = Gtk2::Gdk::Pixbuf->new ('rgb',
        0,
        8,
        $width,
        $height);

$gdkpixbuf->get_from_drawable
    ($embed->window, undef, 0, 0, 0, 0, $width, $height);

$gdkpixbuf->save ($file, "jpeg");


Hope this helps,

-- 
Adam M. Israel
adam battleaxe net

Attachment: signature.asc
Description: OpenPGP digital signature



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