Как загрузить 32-битное изображение на сервер -растровое изображение

Я пытаюсь создать пиксельную карту RGBA на стороне сервера -из буфера на стороне клиента -. CreatePixmap и CreateImage работают нормально для 32 и 24 бит, но XPutImage приводит к ошибке соответствия, возвращаемой сервером

X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  72 (X_PutImage)
  Serial number of failed request:  8
  Current serial number in output stream:  8

сервер поддерживает 32-битные пиксельные карты (вывод xdpyinfo:https://gist.github.com/2582961). Такое же поведение в Ubuntu 12.04 (Версия X.Org :1.11.3 )и OSX с X.app (Версия X.Org :1.10.3)

Почему следующий код не работает?

#include     
#include     

int main(int argc, char **argv)
{
    int width = 100;
    int height = 100;
    int depth = 32; // works fine with depth = 24
    int bitmap_pad = 32; // 32 for 24 and 32 bpp, 16, for 15&16
    int bytes_per_line = 0; // number of bytes in the client image between the start of one scanline and the start of the next
    Display *display=XOpenDisplay(0);
    unsigned char *image32=(unsigned char *)malloc(width*height*4);
    XImage *img = XCreateImage(display, CopyFromParent, depth, ZPixmap, 0, image32, width, height, bitmap_pad, bytes_per_line);
    Pixmap p = XCreatePixmap(display, XDefaultRootWindow(display), width, height, depth);
    XPutImage(display, p, DefaultGC(display, 0), img, 0, 0, 0, 0, width, height); // 0, 0, 0, 0 are src x,y and dst x,y
    XEvent ev;
    while (1) {
       XNextEvent(display, &ev);
    }
}

Обновление:Похоже, я наконец-то получил ответ :использовать GC, связанный с растровым изображением, вместо DefaultGC (, который имеет глубину корневого окна)

#include     
#include     

int main(int argc, char **argv)
{
    int width = 100;
    int height = 100;
    int depth = 32; // works fine with depth = 24
    int bitmap_pad = 32; // 32 for 24 and 32 bpp, 16, for 15&16
    int bytes_per_line = 0; // number of bytes in the client image between the start of one scanline and the start of the next
    Display *display=XOpenDisplay(0);
    unsigned char *image32=(unsigned char *)malloc(width*height*4);
    XImage *img = XCreateImage(display, CopyFromParent, depth, ZPixmap, 0, image32, width, height, bitmap_pad, bytes_per_line);
    Pixmap p = XCreatePixmap(display, XDefaultRootWindow(display), width, height, depth);
    XGCValues gcvalues;
    GC gc = XCreateGC(display, p, 0, &gcvalues);
    XPutImage(display, p, gc, img, 0, 0, 0, 0, width, height); // 0, 0, 0, 0 are src x,y and dst x,y
    XEvent ev;
    while (1) {
       XNextEvent(display, &ev);
    }
}

14
задан Andrey Sidorov 30 January 2014 в 01:31
поделиться