首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用C的GTK4来获取屏幕的像素?

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

Stack Overflow用户
提问于 2021-09-17 15:46:26
回答 1查看 98关注 0票数 1

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

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-09-17 21:14:07

我不知道GTK4的情况,但在X11中:

示例

代码语言:javascript
复制
//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进行编译

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69226200

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档