Taking a screenshot with C\GTK

后端 未结 2 606
有刺的猬
有刺的猬 2020-12-28 11:05

I\'m trying to take a screenshot of the entire screen with C and GTK. I don\'t want to make a call to an external application for speed reasons. I\'ve found Python code for

2条回答
  •  生来不讨喜
    2020-12-28 11:17

    9 years passed and as mentioned above API is removed.

    As far as I understand, currently the bare minimum to do this at Linux is:

    GdkWindow * root;
    GdkPixbuf * screenshot;
    gint x, y, width, height;
    
    root = gdk_get_default_root_window ();
    gdk_window_get_geometry (root, &x, &y, &width, &height);
    screenshot = gdk_pixbuf_get_from_window (root, x, y, width, height);
    // gdk_pixbuf_save...
    

    This is very slightly tested and may fail. Further reading is in gnome-screenshooter repo

提交回复
热议问题