Pixbuf->get_from_drawable in Xvfb ccontext?



I'm running an Ubuntu server as a headless virtual machine and I'm getting the following strange behavior using Pixbufs to take screen snapshots.  I start an Xvfb using the following command

Xvfb :1 -screen 0 640x480x24 -nolisten tcp -audit 4 -auth X1.cfg & export DISPLAY=:1

When I run the following code,

=============
#!/usr/bin/perl -w
use strict;
use Gtk2 '-init';

my $window = Gtk2::Window->new;
my $label = Gtk2::Label->new ('Hello World!');
$window->add ($label);
$window->show_all;

&snapshot;

Gtk2->main;

sub snapshot {

  my $s = Gtk2::Gdk::Screen->get_default;
  my $w = $s->get_root_window;
  my $p = Gtk2::Gdk::Pixbuf->get_from_drawable (
            $w, undef, 0, 0, 0, 0, $s->get_width, $s->get_height);
  $p->save ("screenshot.png", "png");

}
============

and I do an 

xwd -display :1 -root -out image.xwd ; xwdtopnm <image.xwd | pnmtopng >image.png

I get the expected result, a 640x480 image that is mostly the X-windows screen background, with "Hello World" in a small grey box in the upper left-hand corner. However, when I look at screenshot.png I see a 640x480 image that is mostly X-windows screen background with a small grey box in the upper let, but no text.  I've incluced links the the resulting images to illustrate.  Do I need to call snapshot in the event loop in order to get the screen to render?  and if so, what event should I look for to guarantee that the event is triggered in the Xvfb environment (no mouseclicks).


and



I've read many of the related posts here, and they all give essentially the same behavior.   (note that when I start the X-server as 640x480x8 the "Hello World" text does not render properly, I get a black square where the text should be (following an xwd capture) ).


Any guidance (or alternative approaches) would be greatly appreciated.

Thanks 1,000,000

Scott



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