如何使用C的GTK4来获取屏幕的像素?
如果GTK4没有API,如何从Xlib获取屏幕像素?
发布于 2021-09-17 21:14:07
我不知道GTK4的情况,但在X11中:
示例
//open display and get the root window of the default screen
//note: there could be more than one screen
Display *dpy = XOpenDisplay(NULL);
Window root = RootWindow(dpy, DefaultScreen(dpy));
//get the window attributes of the root window
XWindowAttributes attr;
XGetWindowAttributes(dpy, root, &attr);
//get the image of the root window
XImage* image = XGetImage(
dpy,
root,
0, 0, //attr.x, attr.y
attr.width, attr.height,
AllPlanes,
ZPixmap
);提示:包含X11/Xlib.h并使用-lX11进行编译
https://stackoverflow.com/questions/69226200
复制相似问题