Capturing a widget bitmap

From: Date: Fri, 02 May 2008 15:21:22 +0000
Subject: Capturing a widget bitmap
Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-8250@lists.php.net to get a copy of this message
Hello, I want to capture a widget bitmap and save it to disk, I can do it without any problem if the widget is shown on screen, but I would like to do it without being shown, so I can build it on the background. This code do the job, but on Vista, not in XP, that is, it creates a window off screen and captures the bitmap, but the same code on XP it creates a black bitmap: <?php if (!class_exists('gtk')) { die("Please load the php-gtk2 module in your php.ini\r\n"); } $btnLogin = new GtkCalendar(); $wnd = new GtkWindow(); $wnd->set_decorated(false); $wnd->set_skip_taskbar_hint(false); $wnd->move(-1000,-1000); $wnd->add($btnLogin); $wnd->show_all(); savewidgetbitmap($btnLogin, 't.bmp'); function savewidgetbitmap($widget, $filename) { $widget->show(); while (Gtk::events_pending()) { Gtk::main_iteration(); } $window= $widget->window; list($width, $height)=$window->get_size(); $pixbuf = new GdkPixbuf(Gdk::COLORSPACE_RGB, TRUE, 8, $width, $height); $pixbuf->get_from_drawable ($widget->window, $widget->window->get_colormap(), 0, 0, 0, 0, $width, $height); $pixbuf->save($filename,'bmp'); } ?> Any other method that works on Vista and XP? Thanks in advance. Regards

« previous php.gtk.general (#8250) next »