利用gtk函数 linux桌面截图 保存成图片
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
啥也不说,直接上代码,
终端键入:gcc -o main gtk.c `pkg-config --cflags --libs gtk+-2.0`
以上是编译命令;运行之后会截图保存
#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>
int main(int argc,char **argv)
{
GtkWidget *window;
gtk_init(&argc,&argv);
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title((GtkWindow*)window,"gtk-test 2.0");
g_signal_connect(G_OBJECT((GtkWindow*)window),"delete_event", G_CALLBACK(gtk_main_quit),NULL);
gtk_widget_show(window);
//gtk_window_fullscreen(window);
GdkScreen *screen = gdk_screen_get_default();
GdkWindow * root_window = gdk_get_default_root_window ();
if (!root_window )
{
return TRUE;
}
int w = gdk_screen_get_width(screen);
int h = gdk_screen_get_height(screen);
GdkPixbuf * pixbuf = gdk_pixbuf_get_from_drawable(NULL, root_window, NULL,0, 0, 0, 0, w, h); // 抓图
gdk_pixbuf_save(pixbuf, "screen.jpg", "jpeg", NULL, "quality", "100",NULL);
gtk_main();
return FALSE;
}
效果如下:
GitHub 加速计划 / li / linux-dash
6
1
下载
A beautiful web dashboard for Linux
最近提交(Master分支:4 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献2条内容
所有评论(0)