Re: Gtk2::Gdk::Drawable problem



Domsodi Gergely said:

Sorry... I ment Pixbuf everywhere.. :-))

i figured as much.  i do that a lot -- i call them "brain-o"s.  ;-)


After reading the C API, I recognized that the first parameter should be
a Pixmap, and if it is null a new pixmap is created and returned. That's
okay, but if I put undef there, I get a Usage about the function.

So what is the correct use of get_from_drawable?

unfortunately, i misread the docs when creating the previous patch, because i
was in a hurry.  haste makes waste.  instead, here's another patch, which
includes doc comments.  (the new patch assumes you applied the previous patch,
since i'd committed that to cvs already.)

it allows you to use the function both ways, like this (code which actually
worked for me a few seconds ago):

 use Gtk2 -init;

 $root = Gtk2::Gdk->get_default_root_window;
 ($w, $h) = $root->get_size;

 # create a pixbuf for me
 $pixbuf = Gtk2::Gdk::Pixbuf->get_from_drawable ($root, undef, 0, 0, 0, 0, $w,
$h);

 # using an existing destination pixbuf...  also returns $pixbuf,
 # which you may or may not need.  here i ignore it.
 $pixbuf->get_from_drawable ($root, undef, 0, 0, 0, 0, $w, $h);

 # save it with the default params for png:
 $pixbuf->save ('screenshot.png', 'png');



and to answer your previous questions:  the only colorspace and depth
currently implemented in gtk-pixbuf is -bit rgb.  here's how you'd create a
pixbuf:

 $pixbuf = Gtk2::Gdk::Pixbuf->new ('rgb', 0, 8, $w, $h);


-- 
muppet <scott at asofyet dot org>

Attachment: pixbuf_stuff_fixed.patch
Description: Binary data



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