我如何使用C的GTK4来获得屏幕的像素?



如何使用C的GTK4来获得屏幕的像素?

如果GTK4没有API,我如何从Xlib获得屏幕的像素?

我不知道GTK4,但在X11:

  • XGetImage
  • XGetWindowAttributes

示例:

//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编译

最新更新