Load image onto a window using xlib

隐身守侯 提交于 2019-12-03 16:18:40

Create an Pixmap using

Pixmap XCreatePixmap(display, d, width, height, depth)
      Display *display; // The display
      Drawable d;       // The Window for which to set the background

Create a Graphics Context for the Pixmap

GC XCreateGC(display, d, valuemask, values)

Draw the XImage to the Pixmap

XPutImage(display, pixmap, gc, image, src_x, src_y, dest_x, dest_y, width, height)
        Drawable d; // The Pixmap
        XImage *image; // your XImage

Finally set the Pixmap as the window's background

XSetWindowBackgroundPixmap(display, w, background_pixmap)
      Display *display;
      Window w;
      Pixmap background_pixmap;

Then free all resources no longer needed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!