| 18 |
|
|
| 19 |
|
|
| 20 |
|
XRASTER * |
| 21 |
< |
make_raster(disp, scrn, depth, data, width, height, bm_pad) |
| 21 |
> |
make_raster(disp, vis, npixbits, data, width, height, bm_pad) |
| 22 |
|
Display *disp; |
| 23 |
< |
int scrn; |
| 24 |
< |
int depth; |
| 23 |
> |
XVisualInfo *vis; |
| 24 |
> |
int npixbits; |
| 25 |
|
char *data; |
| 26 |
|
int width, height; |
| 27 |
|
int bm_pad; |
| 28 |
|
{ |
| 29 |
+ |
static long swaptest = 1; |
| 30 |
|
register XRASTER *xr; |
| 31 |
< |
XVisualInfo ourvinfo; |
| 31 |
< |
/* Pick appropriate Visual */ |
| 32 |
< |
if (depth == 1) { |
| 33 |
< |
ourvinfo.visual = DefaultVisual(disp,scrn); |
| 34 |
< |
} else if (depth == 8) { |
| 35 |
< |
if (!XMatchVisualInfo(disp,scrn,8,PseudoColor,&ourvinfo)) |
| 36 |
< |
return(NULL); |
| 37 |
< |
} else if (depth == 24) { |
| 38 |
< |
if (!XMatchVisualInfo(disp,scrn,24,TrueColor,&ourvinfo) && |
| 39 |
< |
!XMatchVisualInfo(disp,scrn,24,DirectColor,&ourvinfo)) |
| 40 |
< |
return(NULL); |
| 41 |
< |
} else |
| 42 |
< |
return(NULL); |
| 31 |
> |
|
| 32 |
|
if ((xr = (XRASTER *)calloc(1, sizeof(XRASTER))) == NULL) |
| 33 |
|
return(NULL); |
| 34 |
|
xr->disp = disp; |
| 35 |
< |
xr->screen = scrn; |
| 36 |
< |
xr->visual = ourvinfo.visual; |
| 37 |
< |
xr->image = XCreateImage(disp,ourvinfo.visual,depth, |
| 38 |
< |
depth==1 ? XYBitmap : ZPixmap, |
| 39 |
< |
0,data,width,height,bm_pad,0); |
| 35 |
> |
xr->screen = vis->screen; |
| 36 |
> |
xr->visual = vis->visual; |
| 37 |
> |
if (npixbits == 1) |
| 38 |
> |
xr->image = XCreateImage(disp,vis->visual,1, |
| 39 |
> |
XYBitmap,0,data,width,height,bm_pad,0); |
| 40 |
> |
else |
| 41 |
> |
xr->image = XCreateImage(disp,vis->visual,vis->depth, |
| 42 |
> |
ZPixmap,0,data,width,height,bm_pad,0); |
| 43 |
|
xr->image->bitmap_bit_order = MSBFirst; |
| 44 |
< |
if (xr->image->bits_per_pixel == 32) { |
| 45 |
< |
xr->image->bytes_per_line = xr->image->bytes_per_line*24/32; |
| 46 |
< |
xr->image->bits_per_pixel = 24; |
| 44 |
> |
xr->image->byte_order = *(char *)&swaptest ? LSBFirst : MSBFirst; |
| 45 |
> |
if (vis->depth >= 24 && (xr->image->red_mask != 0xff || |
| 46 |
> |
xr->image->green_mask != 0xff00 || |
| 47 |
> |
xr->image->blue_mask != 0xff0000) && |
| 48 |
> |
(xr->image->red_mask != 0xff0000 || |
| 49 |
> |
xr->image->green_mask != 0xff00 || |
| 50 |
> |
xr->image->blue_mask != 0xff)) { |
| 51 |
> |
xr->image->red_mask = 0xff; |
| 52 |
> |
xr->image->green_mask = 0xff00; |
| 53 |
> |
xr->image->blue_mask = 0xff0000; |
| 54 |
|
} |
| 55 |
< |
xr->gc = XCreateGC(disp, RootWindow(disp,scrn), 0, 0); |
| 57 |
< |
XSetState(disp, xr->gc, BlackPixel(disp,scrn), WhitePixel(disp,scrn), |
| 58 |
< |
GXcopy, AllPlanes); |
| 55 |
> |
xr->gc = 0; |
| 56 |
|
return(xr); |
| 57 |
|
} |
| 58 |
|
|
| 93 |
|
return(xr->ncolors); |
| 94 |
|
} |
| 95 |
|
|
| 96 |
+ |
|
| 97 |
|
Colormap |
| 98 |
|
newcmap(disp, scrn, w, vis) /* get colormap and fix b & w */ |
| 99 |
|
Display *disp; |
| 189 |
|
|
| 190 |
|
|
| 191 |
|
Pixmap |
| 192 |
< |
make_rpixmap(xr) /* make pixmap for raster */ |
| 192 |
> |
make_rpixmap(xr, d) /* make pixmap for raster */ |
| 193 |
|
register XRASTER *xr; |
| 194 |
+ |
Drawable d; |
| 195 |
|
{ |
| 196 |
|
Pixmap pm; |
| 197 |
|
|
| 198 |
|
if (xr->pm != 0) |
| 199 |
|
return(xr->pm); |
| 200 |
< |
pm = XCreatePixmap(xr->disp, RootWindow(xr->disp, xr->screen), |
| 200 |
> |
pm = XCreatePixmap(xr->disp, d, |
| 201 |
|
xr->image->width, xr->image->height, |
| 202 |
< |
DisplayPlanes(xr->disp, xr->screen)); |
| 202 |
> |
xr->image->depth); |
| 203 |
|
if (pm == 0) |
| 204 |
|
return(0); |
| 205 |
|
put_raster(pm, 0, 0, xr); |
| 230 |
|
if (ysrc + height > xr->image->height) |
| 231 |
|
height = xr->image->height - ysrc; |
| 232 |
|
|
| 233 |
+ |
if (xr->gc == 0) { |
| 234 |
+ |
xr->gc = XCreateGC(xr->disp, d, 0, 0); |
| 235 |
+ |
XSetState(xr->disp, xr->gc, BlackPixel(xr->disp,xr->screen), |
| 236 |
+ |
WhitePixel(xr->disp,xr->screen), GXcopy, AllPlanes); |
| 237 |
+ |
} |
| 238 |
|
if (xr->pm == 0) |
| 239 |
|
XPutImage(xr->disp, d, xr->gc, xr->image, xsrc, ysrc, |
| 240 |
|
xdst, ydst, width, height); |
| 277 |
|
free((char *)xr->cdefs); |
| 278 |
|
} |
| 279 |
|
XDestroyImage(xr->image); |
| 280 |
< |
XFreeGC(xr->disp, xr->gc); |
| 280 |
> |
if (xr->gc != 0) |
| 281 |
> |
XFreeGC(xr->disp, xr->gc); |
| 282 |
|
free((char *)xr); |
| 283 |
|
} |