Próbuję utworzyć piksel po stronie serwera po stronie klienta z bufora po stronie klienta. CreatePixmap & createImage praca ok 32 i 24 bit, ale wynik XPutImage w błąd Meczu zwrócony przez serwerJak przesłać obraz 32-bitowy do pixmapy po stronie serwera
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
serwer obsługuje 32-bitowe pixmapy (xdpyinfo wyjścia: https://gist.github.com/2582961). To samo zachowanie na Ubuntu 12.04 (X.Org wersja: 1.11.3) i OSX z X.app (X.Org wersja: 1.10.3)
Dlaczego następujący kod się nie powiódł?
#include <stdlib.h>
#include <X11/Xlib.h>
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);
}
}
Aktualizacja: Wygląda na to, że w końcu dostał odpowiedź: używaj GC związanego z pixmapę zamiast DefaultGC (który ma głębokość oknie głównym)
#include <stdlib.h>
#include <X11/Xlib.h>
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);
}
}
Teraz mam problem z kurczakiem i jajkiem - potrzebuję 32-bitowego gc do utworzenia 32-bitowej pixmapy i 32-bitowego losowania do stworzenia 32-bitowego gc. Czy masz 32-bitową głębię dla domyślnego obrazu? –
Odpowiem ci w przyszłym tygodniu, kiedy wrócę do pracy, bo teraz jestem na wakacjach. Będę szukać tego w porządku? – filipehd
Dzięki! To wcale nie jest pilne. –