这是我的代码:
int main()
{
Display *d = XOpenDisplay(0);
unsigned int bitmap_width, bitmap_height;
int x, y;
Pixmap bitmap;
if ( d )
{
Window w = XCreateWindow(d, DefaultRootWindow(d), 0, 0, 400,
400, 0, CopyFromParent, CopyFromParent,CopyFromParent, 0, 0);
GC gc = XCreateGC ( d, w, 0 , NULL );
int rc = XReadBitmapFile(d, w,
"1.bmp",
&bitmap_width, &bitmap_height,
&bitmap,
&x, &y);
XCopyPlane(d, bitmap, w, gc,0, 0, bitmap_width, bitmap_height,0, 0, 1);
XMapWindow(d, w);
XFlush(d);
sleep(10);
}
return 0;
}
但是窗口是透明的。我不明白为什么它不起作用。我哪里出错了?
XFlush
强制显示窗口(X 协议是异步的),等待 10 秒钟,然后(粗暴地)销毁窗口并通过简单退出(在return 0
处)拆除与 X 服务器的连接。 - mctylr