home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Shareware 1999 March
/
PCShareware-3-99.iso
/
IMPLE
/
DJGPP.RAR
/
DJGPP2
/
XLIB-SR0.ZIP
/
SRC
/
XLIBEMU
/
COPYPLAN.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-10
|
2KB
|
84 lines
/* $Id: copyplan.c 1.3 1994/02/10 22:37:45 ulrich Exp $ */
/*
* copyplane.c
*
* X library function XCopyPlane.
* Only Bitmap to Screen Pixmap is supported.
*/
#include "Xlibemu.h"
int XCopyPlane(
Display* display,
Drawable src,
Drawable dest,
GC gc,
int src_x,
int src_y,
unsigned int width,
unsigned int height,
int dest_x,
int dest_y,
unsigned long plane)
{
FlushGC(display, gc);
if (src->type == 0) { /* Bitmap */
int x, y, pad;
Pixmap bitmap = (Pixmap) src, pixmap;
unsigned char *data, bits, mask;
if ((plane & 1) == 0
|| src_x >= bitmap->width
|| src_y >= bitmap->height)
return 0;
data = (unsigned char *) bitmap->data;
pad = (bitmap->width + 7) >> 3;
if (src_x + width > bitmap->width)
width = bitmap->width - src_x;
if (src_y + height > bitmap->height)
height = bitmap->height - src_y;
if (dest->type == 3) {
GrContext save;
GrSaveContext (&save);
GrSetContext (((Pixmap) dest)->context);
data += src_y * pad;
for (y = 0; y < height; y++) {
mask = 1 << (src_x % 8);
for (x = 0; x < width; x++) {
bits = data [(src_x + x) / 8];
GrPlot (dest_x + x, dest_y + y,
(mask & bits) ? gc->values.foreground : gc->values.background);
if (mask & 0x80)
mask = 1;
else
mask <<= 1;
}
data += pad;
}
GrSetContext (&save);
GrDestroyContext (&save);
}
if (dest->type == 2) {
pixmap = XCreatePixmap (display, dest, bitmap->width, bitmap->height,
DefaultDepth(display, DefaultScreen (display)));
_WDrawContext ((Drawable) pixmap, gc);
for (y = 0; y < bitmap->height; y++) {
for (x = 0; x < bitmap->width; x++) {
bits = data [x / 8];
mask = 1 << (x % 8);
GrPlot (x, y, (mask & bits) ? gc->values.foreground : gc->values.background);
}
data += pad;
}
XCopyArea (display, pixmap, dest, gc, src_x, src_y, width, height, dest_x, dest_y);
XFreePixmap (display, pixmap);
}
return 1;
}
return 0;
}