Desktop screenshot

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

 



Hi,

I am trying to get a screenshot of the desktop by using a transparent GtkWidget and then using gdk_pixbuf_get_from_drawable.   When I check the saved GdkPixbuf I am getting a valid image, but the image does not include the background of the desktop but just the GtkWidget itself.  Is there any way of working around this?

I am simply creating a GtkWidget and then controlling the paint events, the code for the paint and saving the image is below:

static gboolean on_window_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
  cairo_t *cr;

  cr = gdk_cairo_create(widget->window); // create cairo context

  cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.7);
  cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); 
  cairo_paint(cr); // paint source
  cairo_destroy(cr);
  static int >
  if ( 0 )
  {
 GdkPixbuf * pixbuf;
 pixbuf = gdk_pixbuf_get_from_drawable( NULL, widget->window, colormap, 0, 0, 0, 0, 300, 200 );

  if ( pixbuf != NULL )
 {
 GError * err = NULL;
 gdk_pixbuf_save( pixbuf, "image.png", "png", &err, NULL );
 }
 once++;
  }
  return FALSE;
}


Thanks, Andy.

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux