Convert a GTK python script to C -


The following script will take a screenshot on a gnome desktop.

gtk.gdk w = gtk.gdk.get_default_root_window () SZ = w.get_size () Punjab = gtk.gdk.Pixbuf (gtk.gdk.COLORSPACE_RGB, false, 8, SZ [ 0], SZ [1]) Punjab = pb.get_from_drawable (w, w.get_colormap (), 0, 0, 0, 0, SZ [0], SZ [1]) if (PB = none): pb. Save ("screenshot.png", "png") Print "screenshot saved on screenshot." Else: Print "Unable to get screenshot."

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

"itemprop =" text ">

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 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; }  

You will compile like this: (You consider it saving as a screenshot)

  gcc -std = gnu99 `pkg-config - Libs --cflags gdk-2.0` screenshot.c -o 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 (pb, "screenshot.png" , "Png", NULL, NULL);  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -