| 14 |
|
#include <X11/Xlib.h> |
| 15 |
|
#include <X11/Xutil.h> |
| 16 |
|
|
| 17 |
+ |
#include "color.h" |
| 18 |
|
#include "x11raster.h" |
| 19 |
|
|
| 20 |
+ |
extern char *malloc(), *realloc(), *calloc(); |
| 21 |
|
|
| 22 |
+ |
|
| 23 |
|
XRASTER * |
| 24 |
|
make_raster(disp, vis, npixbits, data, width, height, bm_pad) |
| 25 |
|
Display *disp; |
| 62 |
|
|
| 63 |
|
|
| 64 |
|
int |
| 65 |
< |
init_rcolors(xr, rmap, gmap, bmap) /* initialize colors */ |
| 65 |
> |
init_rcolors(xr, cmap) /* initialize colors */ |
| 66 |
|
register XRASTER *xr; |
| 67 |
< |
int rmap[256], gmap[256], bmap[256]; |
| 67 |
> |
BYTE cmap[][3]; |
| 68 |
|
{ |
| 69 |
|
register unsigned char *p; |
| 70 |
|
register int i; |
| 71 |
|
|
| 72 |
< |
if (xr->image->depth > 8 || xr->ncolors != 0) |
| 72 |
> |
if (xr->image->depth > 8 | xr->ncolors != 0) |
| 73 |
|
return(xr->ncolors); |
| 74 |
|
xr->pmap = (short *)malloc(256*sizeof(short)); |
| 75 |
|
if (xr->pmap == NULL) |
| 83 |
|
i = xr->image->width*xr->image->height; |
| 84 |
|
i--; p++) |
| 85 |
|
if (xr->pmap[*p] == -1) { |
| 86 |
< |
xr->cdefs[xr->ncolors].red = rmap[*p] << 8; |
| 87 |
< |
xr->cdefs[xr->ncolors].green = gmap[*p] << 8; |
| 88 |
< |
xr->cdefs[xr->ncolors].blue = bmap[*p] << 8; |
| 86 |
> |
xr->cdefs[xr->ncolors].red = cmap[*p][RED] << 8; |
| 87 |
> |
xr->cdefs[xr->ncolors].green = cmap[*p][GRN] << 8; |
| 88 |
> |
xr->cdefs[xr->ncolors].blue = cmap[*p][BLU] << 8; |
| 89 |
|
xr->cdefs[xr->ncolors].pixel = *p; |
| 90 |
|
xr->cdefs[xr->ncolors].flags = DoRed|DoGreen|DoBlue; |
| 91 |
|
xr->pmap[*p] = xr->ncolors++; |
| 99 |
|
|
| 100 |
|
|
| 101 |
|
Colormap |
| 102 |
< |
newcmap(disp, scrn, w, vis) /* get colormap and fix b & w */ |
| 102 |
> |
newcmap(disp, scrn, vis) /* get colormap and fix b & w */ |
| 103 |
|
Display *disp; |
| 104 |
|
int scrn; |
| 102 |
– |
Window w; |
| 105 |
|
Visual *vis; |
| 106 |
|
{ |
| 107 |
|
XColor thiscolor; |
| 110 |
|
int n; |
| 111 |
|
register int i, j; |
| 112 |
|
|
| 113 |
< |
cmap = XCreateColormap(disp, w, vis, AllocNone); |
| 114 |
< |
if (cmap == 0) |
| 115 |
< |
return(0); |
| 113 |
> |
cmap = XCreateColormap(disp, RootWindow(disp,scrn), vis, AllocNone); |
| 114 |
> |
if (cmap == 0 || vis->class != PseudoColor) |
| 115 |
> |
return(cmap); |
| 116 |
|
pixels=(unsigned long *)malloc(vis->map_entries*sizeof(unsigned long)); |
| 117 |
|
if (pixels == NULL) |
| 118 |
|
return(0); |
| 142 |
|
|
| 143 |
|
|
| 144 |
|
unsigned long * |
| 145 |
< |
map_rcolors(xr, w) /* get and assign pixels */ |
| 145 |
> |
map_rcolors(xr, w) /* get and assign pixels */ |
| 146 |
|
register XRASTER *xr; |
| 147 |
|
Window w; |
| 148 |
|
{ |
| 159 |
|
if (xr->visual == DefaultVisual(xr->disp, xr->screen)) |
| 160 |
|
xr->cmap = DefaultColormap(xr->disp, xr->screen); |
| 161 |
|
else |
| 162 |
< |
xr->cmap = newcmap(xr->disp, xr->screen, w, xr->visual); |
| 162 |
> |
xr->cmap = newcmap(xr->disp, xr->screen, xr->visual); |
| 163 |
|
while (XAllocColorCells(xr->disp, xr->cmap, 0, |
| 164 |
|
NULL, 0, xr->pixels, xr->ncolors) == 0) |
| 165 |
|
if (xr->cmap == DefaultColormap(xr->disp, xr->screen)) |
| 166 |
< |
xr->cmap = newcmap(xr->disp, xr->screen, w, xr->visual); |
| 166 |
> |
xr->cmap = newcmap(xr->disp, xr->screen, xr->visual); |
| 167 |
|
else { |
| 168 |
|
free((char *)xr->pixels); |
| 169 |
|
xr->pixels = NULL; |