Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » GTK+
  • » Using gdk_pixbuf_xlib_get_from_drawable() [RSS Feed]

#1 Oct. 18, 2008 01:56:15

Димитров В.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Using gdk_pixbuf_xlib_get_from_drawable()


Hi.
In old mail list (2007 year), I saw this problem:Hello,I have a problem using the function from the subject. I think I'm
just missing something about how the function works. Here is the
code (it's just a short program to test the function):### BEGIN CODE ####include <gdk-pixbuf-xlib/gdk-pixbuf-xlib.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>static void
screenshot (GtkWidget *widget)
{
GdkPixbuf *image;
XWindowAttributes wa;
Window win;win = GDK_WINDOW_XID (widget->window);
XGetWindowAttributes (GDK_DISPLAY(), win, &wa);image = gdk_pixbuf_xlib_get_from_drawable (NULL,win, 0, NULL,0, 0, 0, 0,
wa.width, wa.height);gdk_pixbuf_save (image, "test.png", "png", NULL, NULL);
}intmain (int argc, char *argv)
{
GtkWidget *window, *button;
gtk_init (&argc, &argv);window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
button = gtk_button_new_with_label ("Hello");g_signal_connect (G_OBJECT (button), "clicked",G_CALLBACK (screenshot), NULL);gtk_container_add (GTK_CONTAINER (window), button);
gtk_widget_show_all (window);gtk_main ();
return 0;
}### END CODE ###It is crashing in the .._from_drawable() function as you can
see here:Program received signal SIGSEGV, Segmentation fault.
0x004943dd in XGetWindowAttributes () from /usr/lib/libX11.so.6
(gdb) where
#0 0x004943dd in XGetWindowAttributes () from /usr/lib/libX11.so.6
#1 0x004651d9 in gdk_pixbuf_xlib_get_from_drawable ()
from /usr/lib/libgdk_pixbuf_xlib-2.0.so.0
#2 0x080488ab in screenshot (widget=0x9caed68) at test.c:36I am compiling with:
gcc -Wall -g test.c -o exe `pkg-config --cflags --libs gtk+-2.0
gdk-pixbuf-xlib-2.0`Thank you for any help you can give me! - AndrewA work code is representing so:

static void
screenshot (GtkWidget *widget)
{
GdkPixbuf *image;
XWindowAttributes wa;
Window win;

/*Must init display.*/
gdk_pixbuf_xlib_init(GDK_DISPLAY(), 0);

win = GDK_WINDOW_XID (widget->window);
XGetWindowAttributes (GDK_DISPLAY(), win, &wa);

image = gdk_pixbuf_xlib_get_from_drawable (NULL,
win, 0, NULL,
0, 0, 0, 0,
wa.width, wa.height);

gdk_pixbuf_save (image, "test.png", "png", NULL, NULL);
}


With regards Dimitrov Vyacheslav.
_______________________________________________
gtk-list mailing list
gtk-list@gnome.orghttp://mail.gnome.org/mailman/listinfo/gtk-list

Offline

#2 May 17, 2017 20:32:17

Arrentam
Registered: 2017-05-15
Posts: 2
Reputation: +  0  -
Profile   Send e-mail  

Using gdk_pixbuf_xlib_get_from_drawable()

This post is being moderated

Offline

  • Root
  • » GTK+
  • » Using gdk_pixbuf_xlib_get_from_drawable() [RSS Feed]

Board footer

Moderator control

Enjoy the 20th of September
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support