【发布时间】:2011-06-17 11:19:44
【问题描述】:
我已经创建了窗口类,我想插入一个图像作为该窗口的背景。文件格式需要是 png。我使用 magick++ 的 XImage 来加载图像。但不知道如何将其作为我窗口的背景。知道怎么做吗?
【问题讨论】:
标签: c++ imagemagick x11 xlib
我已经创建了窗口类,我想插入一个图像作为该窗口的背景。文件格式需要是 png。我使用 magick++ 的 XImage 来加载图像。但不知道如何将其作为我窗口的背景。知道怎么做吗?
【问题讨论】:
标签: c++ imagemagick x11 xlib
使用
创建像素图Pixmap XCreatePixmap(display, d, width, height, depth)
Display *display; // The display
Drawable d; // The Window for which to set the background
为像素图创建图形上下文
GC XCreateGC(display, d, valuemask, values)
将 XImage 绘制到像素图
XPutImage(display, pixmap, gc, image, src_x, src_y, dest_x, dest_y, width, height)
Drawable d; // The Pixmap
XImage *image; // your XImage
最后将像素图设置为窗口的背景
XSetWindowBackgroundPixmap(display, w, background_pixmap)
Display *display;
Window w;
Pixmap background_pixmap;
然后释放所有不再需要的资源。
【讨论】: