gpt4 book ai didi

c - 使用 libx11 截图

转载 作者:太空狗 更新时间:2023-10-29 15:39:16 26 4
gpt4 key购买 nike

我目前正在尝试使用 libx11 截屏

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stdio.h>

int main(void) {
XImage* pic;
Display* dpl;
unsigned int buffer_size;

dpl = XOpenDisplay("127.0.0.1:0.0");

pic = XGetImage(dpl, RootWindow(dpl, DefaultScreen(dpl)), 10, 10, 201, 201,
AllPlanes, ZPixmap);
}

如果我使用 -lX11 编译代码并运行它,我会不断收到段错误。有什么想法吗?

提前致谢!

最佳答案

X11 服务器通常不监听 TCP/IP 本地主机,而是监听 Unix 套接字。无论如何,您不应该硬编码 X11 服务器的地址。试试这个:

dpl = XOpenDisplay(NULL);
assert(dpl);

关于c - 使用 libx11 截图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10284858/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com