Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C Xlib-仅在窗口上绘制位图的设置位_C_Linux_X11_Xlib - Fatal编程技术网

C Xlib-仅在窗口上绘制位图的设置位

C Xlib-仅在窗口上绘制位图的设置位,c,linux,x11,xlib,C,Linux,X11,Xlib,我正试图在窗口上绘制位图。我只需要画位图中1位对应的像素;对应于0位的应保持完整。我使用的代码如下: XImage*图像; uint8_t位图[8192];/*256 x 256/8*/ memset(位图,0xaa,sizeof(位图)); XSetForeground(g_显示,g_gc,0x000000ff); XSetBackground(g_显示,g_gc,0x00000000); image=XCreateImage(g_显示,g_可视,1,XY位图, 0,(字符*)位图,256,2

我正试图在窗口上绘制位图。我只需要画位图中1位对应的像素;对应于0位的应保持完整。我使用的代码如下:

XImage*图像;
uint8_t位图[8192];/*256 x 256/8*/
memset(位图,0xaa,sizeof(位图));
XSetForeground(g_显示,g_gc,0x000000ff);
XSetBackground(g_显示,g_gc,0x00000000);
image=XCreateImage(g_显示,g_可视,1,XY位图,
0,(字符*)位图,256,256,32,0);
XPutImage(g_显示、g_wnd、g_gc、图像、0、0、10、10、255、255);
XFree(图像);
(是的,我知道像我这样直接指定颜色是错误的,但现在对我来说还可以)


显然,位图的0位是用背景色(即黑色)绘制的。我不希望他们被画出来。实现这一点的最佳方法是什么?有没有办法指定掩码或其他东西?

首先,对于非透明位图,您不需要从位图数据创建全深度图像。创建一位pixmap并使用
XCopyPlane

对于透明位图,您需要操纵GC的剪辑掩码

Pixmap bitmap;
...; /* create 1-bit-deep pixmap */
XSetClipMask(display, gc, bitmap);
XSetClipOrigin(display, gc, x, y);
/* 1-bits of the bitmap are filled with the foreground color,
   and 0-bits are left intact */
XFillRectangle(display, window, gc, x, y, width, heiht);

我想把一张1bpp图像复制到我的显示器上,而没有任何文档规范地指向
XCopyPlane
的方向。我现在有一些
0x55
(垂直线)显示在我的窗口中:)