--- ray/src/px/x11raster.c 1992/10/12 14:52:19 2.7 +++ ray/src/px/x11raster.c 2003/04/23 00:52:34 2.11 @@ -1,9 +1,6 @@ -/* Copyright 1990 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: x11raster.c,v 2.11 2003/04/23 00:52:34 greg Exp $"; #endif - /* * x11raster.c - routines to handle images for X windows. * @@ -88,7 +85,7 @@ BYTE cmap[][3]; xr->cdefs[xr->ncolors].flags = DoRed|DoGreen|DoBlue; xr->pmap[*p] = xr->ncolors++; } - xr->cdefs = (XColor *)realloc((char *)xr->cdefs, + xr->cdefs = (XColor *)realloc((void *)xr->cdefs, xr->ncolors*sizeof(XColor)); if (xr->cdefs == NULL) return(0); @@ -97,10 +94,9 @@ BYTE cmap[][3]; Colormap -newcmap(disp, scrn, w, vis) /* get colormap and fix b & w */ +newcmap(disp, scrn, vis) /* get colormap and fix b & w */ Display *disp; int scrn; -Window w; Visual *vis; { XColor thiscolor; @@ -109,9 +105,9 @@ Visual *vis; int n; register int i, j; - cmap = XCreateColormap(disp, w, vis, AllocNone); - if (cmap == 0) - return(0); + cmap = XCreateColormap(disp, RootWindow(disp,scrn), vis, AllocNone); + if (cmap == 0 || vis->class != PseudoColor) + return(cmap); pixels=(unsigned long *)malloc(vis->map_entries*sizeof(unsigned long)); if (pixels == NULL) return(0); @@ -135,13 +131,13 @@ Visual *vis; i--; } XFreeColors(disp, cmap, pixels, n, 0); - free((char *)pixels); + free((void *)pixels); return(cmap); } unsigned long * -map_rcolors(xr, w) /* get and assign pixels */ +map_rcolors(xr, w) /* get and assign pixels */ register XRASTER *xr; Window w; { @@ -158,13 +154,13 @@ Window w; if (xr->visual == DefaultVisual(xr->disp, xr->screen)) xr->cmap = DefaultColormap(xr->disp, xr->screen); else - xr->cmap = newcmap(xr->disp, xr->screen, w, xr->visual); + xr->cmap = newcmap(xr->disp, xr->screen, xr->visual); while (XAllocColorCells(xr->disp, xr->cmap, 0, NULL, 0, xr->pixels, xr->ncolors) == 0) if (xr->cmap == DefaultColormap(xr->disp, xr->screen)) - xr->cmap = newcmap(xr->disp, xr->screen, w, xr->visual); + xr->cmap = newcmap(xr->disp, xr->screen, xr->visual); else { - free((char *)xr->pixels); + free((void *)xr->pixels); xr->pixels = NULL; return(NULL); } @@ -256,7 +252,7 @@ register XRASTER *xr; XFreeColors(xr->disp, xr->cmap, xr->pixels, xr->ncolors, 0); if (xr->cmap != DefaultColormap(xr->disp, xr->screen)) XFreeColormap(xr->disp, xr->cmap); - free((char *)xr->pixels); + free((void *)xr->pixels); xr->pixels = NULL; } @@ -277,11 +273,11 @@ register XRASTER *xr; free_rpixmap(xr); if (xr->ncolors > 0) { unmap_rcolors(xr); - free((char *)xr->pmap); - free((char *)xr->cdefs); + free((void *)xr->pmap); + free((void *)xr->cdefs); } XDestroyImage(xr->image); if (xr->gc != 0) XFreeGC(xr->disp, xr->gc); - free((char *)xr); + free((void *)xr); }