Convert a GTK python script to C -
The following script will take a screenshot on a gnome desktop.
Now, I'm trying to convert it and I'm using one of those apps that I'm writing but I've been unsuccessful yet. Is there anybody to do in C (on Linux)?
Thank you! Jess
I have tested this and it works, but be an easy way to go from GdkPixbuf Could this be the first one I found to a png. (There is no You will compile like this: (You consider it saving as a screenshot) Edit: can also be seen to save the stuff done: (note I did not try this out , But this is only one line ...) Thanks to kaizer.se for pointing to my failure in reading the doctor: p gdk_pixbuf_save ()
)
#include & lt; Unistd.h & gt; # Include & lt; Stdio.h & gt; # Include & lt; Gdk / gdk.h & gt; # Include & lt; Cairo.h & gt; Int main (matrix argc, char ** argv) {gdk_init (and argc, and argv); GdkWindow * w = gdk_get_default_root_window (); Gantt width, height; Gdk_drawable_get_size (GDK_DRAWABLE (w), & amp; width, and height); GdkPixbuf * PB = gdk_pixbuf_get_from_drawable (zero, GDK_DRAWABLE (w), zero, 0,0,0,0, width, height); If (pb! = NULL) {cairo_surface_t * surf = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, height); CARO_TT * crux = CROOK (surf); Gdk_cairo_set_source_pixbuf (cr, pb, 0, 0); Cairo_paint (cr); Cairo_surface_write_to_png (surf, "screenshot.png"); G_print ("Screenshot saved in screenshot. \ N"); } And {g_print ("Unable to get the screenshot. \ N"); } Return 0; }
gcc -std = gnu99 `pkg-config - Libs --cflags gdk-2.0` screenshot.c -o screenshot
gdk_pixbuf_save (pb, "screenshot.png" , "Png", NULL, NULL);
Comments
Post a Comment