--- ray/src/px/x11raster.c 1992/05/27 14:28:54 2.5 +++ ray/src/px/x11raster.c 1993/07/19 15:18:10 2.8 @@ -14,9 +14,12 @@ static char SCCSid[] = "$SunId$ LBL"; #include #include +#include "color.h" #include "x11raster.h" +extern char *malloc(), *realloc(), *calloc(); + XRASTER * make_raster(disp, vis, npixbits, data, width, height, bm_pad) Display *disp; @@ -41,6 +44,7 @@ int bm_pad; xr->image = XCreateImage(disp,vis->visual,vis->depth, ZPixmap,0,data,width,height,bm_pad,0); xr->image->bitmap_bit_order = MSBFirst; + xr->image->bitmap_unit = bm_pad; xr->image->byte_order = *(char *)&swaptest ? LSBFirst : MSBFirst; if (vis->depth >= 24 && (xr->image->red_mask != 0xff || xr->image->green_mask != 0xff00 || @@ -58,14 +62,14 @@ int bm_pad; int -init_rcolors(xr, rmap, gmap, bmap) /* initialize colors */ +init_rcolors(xr, cmap) /* initialize colors */ register XRASTER *xr; -int rmap[256], gmap[256], bmap[256]; +BYTE cmap[][3]; { register unsigned char *p; register int i; - if (xr->image->depth != 8 || xr->ncolors != 0) + if (xr->image->depth > 8 | xr->ncolors != 0) return(xr->ncolors); xr->pmap = (short *)malloc(256*sizeof(short)); if (xr->pmap == NULL) @@ -79,9 +83,9 @@ int rmap[256], gmap[256], bmap[256]; i = xr->image->width*xr->image->height; i--; p++) if (xr->pmap[*p] == -1) { - xr->cdefs[xr->ncolors].red = rmap[*p] << 8; - xr->cdefs[xr->ncolors].green = gmap[*p] << 8; - xr->cdefs[xr->ncolors].blue = bmap[*p] << 8; + xr->cdefs[xr->ncolors].red = cmap[*p][RED] << 8; + xr->cdefs[xr->ncolors].green = cmap[*p][GRN] << 8; + xr->cdefs[xr->ncolors].blue = cmap[*p][BLU] << 8; xr->cdefs[xr->ncolors].pixel = *p; xr->cdefs[xr->ncolors].flags = DoRed|DoGreen|DoBlue; xr->pmap[*p] = xr->ncolors++; @@ -146,7 +150,7 @@ Window w; register int i; register unsigned char *p; - if (xr->ncolors == 0 || xr->image->depth != 8) + if (xr->ncolors == 0 || xr->image->depth > 8) return(NULL); if (xr->pixels != NULL) return(xr->pixels); @@ -189,17 +193,19 @@ Window w; Pixmap -make_rpixmap(xr, d) /* make pixmap for raster */ +make_rpixmap(xr, w) /* make pixmap for raster */ register XRASTER *xr; -Drawable d; +Window w; { + XWindowAttributes xwattr; Pixmap pm; if (xr->pm != 0) return(xr->pm); - pm = XCreatePixmap(xr->disp, d, + XGetWindowAttributes(xr->disp, w, &xwattr); + pm = XCreatePixmap(xr->disp, w, xr->image->width, xr->image->height, - xr->image->depth); + xwattr.depth); if (pm == 0) return(0); put_raster(pm, 0, 0, xr);