Estoy intentando crear un mapa de puntos RGBA del lado del servidor desde el búfer del lado del cliente. CreatePixmap trabajo & CreateImage bien para 32 y 24 bits, pero XPutImage resultado de un error de ajuste devueltos por el servidorCómo cargar imágenes de 32 bits en el mapa de puntos del lado del servidor
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
servidor hace de soporte de 32 bits mapas de píxeles (xdpyinfo de salida: https://gist.github.com/2582961). Mismo comportamiento en ubuntu 12.04 (versión X.Org: 1.11.3) y OSX con X.app (versión X.Org: 1.10.3)
¿Por qué falla el siguiente código?
#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);
}
}
Actualización: Parece respuesta como finalmente conseguí: el uso de GC asociado con mapa de píxeles en lugar de DefaultGC (que tiene una profundidad de ventana raíz)
#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);
}
}
Ahora tengo un problema con el huevo y la gallina. Necesito 32 g de gc para crear un mapa de bits de 32 bits y un dibujo de 32 para crear 32 g de gc. ¿Tiene 32 bits de profundidad para el visual predeterminado? –
Te responderé la próxima semana cuando vuelva a trabajar, porque ahora estoy de vacaciones. Voy a buscar eso está bien? – filipehd
Gracias! Eso de ninguna manera es urgente –