Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // screen-capture-ubuntu.c
- // gcc screen-capture-ubuntu.c -o screen-capture-ubuntu `pkg-config --libs --cflags gtk+-2.0`
- // http://www.bravegnu.org/gtktext/x498.html
- // http://www.cs.dartmouth.edu/~campbell/cs50/project/gtk.html
- // http://stackoverflow.com/questions/3124229/taking-a-screenshot-with-c-gtk
- // http://stackoverflow.com/questions/11963561/screen-capture-in-haskell?lq=1
- // http://askubuntu.com/questions/5847/how-to-resolve-gdk-pixbuf-gdk-pixbuf-h-no-such-file-or-directory
- // https://developer.gnome.org/gdk-pixbuf/unstable/gdk-pixbuf-The-GdkPixbuf-Structure.html
- // https://developer.gnome.org/gdk3/stable/gdk3-Windows.html#GdkWindow-struct
- // http://stackoverflow.com/questions/126141/how-do-you-find-out-which-version-of-gtk-is-installed-on-ubuntu
- // http://ubuntuforums.org/showthread.php?t=536115
- // sudo apt-get install libgdk-pixbuf2.0-dev
- // sudo apt-get install libgtk2.0-dev
- // pkg-config --cflags gdk-pixbuf-2.0
- // pkg-config --cflags gtk+-2.0
- // dpkg --list | grep gdk
- #include <gtk/gtk.h>
- #include <gdk-pixbuf/gdk-pixbuf.h>
- GdkPixbuf * get_screenshot(){
- GdkPixbuf *screenshot;
- GdkWindow *root_window;
- gint x_orig, y_orig;
- gint width, height;
- root_window = gdk_get_default_root_window ();
- gdk_drawable_get_size (root_window, &width, &height);
- gdk_window_get_origin (root_window, &x_orig, &y_orig);
- screenshot = gdk_pixbuf_get_from_drawable (NULL,root_window,NULL,x_orig,y_orig,0,0,width,height);
- return screenshot;
- }
- void addScreenCapture(GtkWidget *window) {
- GtkWidget *image;
- GdkPixbuf *pixbuf;
- pixbuf = get_screenshot();
- image = gtk_image_new_from_pixbuf(pixbuf);
- gtk_container_add (GTK_CONTAINER (window),image);
- }
- int main (int argc, char *argv[]) {
- GtkWidget *window;
- /* Initialize the GTK+ and all of its supporting libraries. */
- gtk_init (&argc, &argv);
- /* Create a new window, give it a title and display it to the user. */
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title (GTK_WINDOW (window), "Hello World");
- //gtk_widget_show (window);
- addScreenCapture(window);
- gtk_widget_show_all (window);
- /* Hand control over to the main loop. */
- gtk_main ();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement