我开始编写自己的窗口管理器,想知道如何使用Xorg api从原始图像数据(如libpng提供的数据)转换为xorg Pixmap或Xorg可绘制的内容?
发布于 2008-12-06 16:14:17
XCreatePixmapFromBitmapData应该做到这一点。请记住,您需要输入与xserver使用的位深度相同的数据。
发布于 2010-09-09 08:58:37
你可能在2008年的某个时候就发现了这一点,但为了让未来的读者受益……
XCreatePixmapFromBitmapData()将文字位图(即1位黑白)数据加载到像素图中。如果目标是从PNG加载,这很可能不是您想要的。
一种较新的方法是使用Cairo或GdkPixbuf。老式的Xlib,如XCreatePixmapFromBitmapData()和XDrawWhatever()几乎都被弃用了(并不是说它们永远都不会被删除,但它们已经过时了,并且与现代应用程序的工作方式不同步)。
这些天人们通常建议做的事情是:
您可以使用cairo_image_surface_create_from_png()来实现简单的目的,或者如果您需要支持更多的格式,则可以使用GdkPixbuf。
发布于 2011-07-21 14:16:13
你还得和XCreateImage,XCreatePixmap和XCopyArea跳个舞。它有点像这样:
struct Image img = get_pixels_and_geometry_from_libpng("filename.png");
XImage *img = XCreateImage(/*5000 paremeters*/);
Pixmap pixmap = XCreatePixmap(dpy, img.width, img.height, 24);
XPutImage(dpy, pixmap, gc, 0, 0, img.width, img.height);
XCopyArea(dpy, pixmap, window, 0, 0, img.width, img.height, x, y);https://stackoverflow.com/questions/346323
复制相似问题