这是我的代码:
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;
}
Run Code Online (Sandbox Code Playgroud)
但窗口很清楚.我不明白为什么它不起作用.我哪里弄错了?
通常,您可以创建自己的加载器,以便从您需要的任何图像格式中获取像素.
然后,使用XCreateImage作出的XImage,这你放,使用XPutImage,对您产生的屏幕外像素映射XCreatePixmap.获得像素图后,将其绘制到窗口中XCopyArea.您必须在任何公开事件上重新复制图像.
| 归档时间: |
|
| 查看次数: |
6856 次 |
| 最近记录: |