| /*
Jeremy Pack digital 24-Aug-1989
*/
#include <stdio.h>
#include <decw$include/Xlib.h>
#include <decw$include/Xutil.h>
#include <decw$include/Xatom.h>
#define jetr_width 16
#define jetr_height 16
#define jetr_x_hot 0
#define jetr_y_hot 0
static char jetr_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x7d, 0x00, 0xfb, 0x01,
0xf3, 0x1f, 0xff, 0x7f, 0xfe, 0xff, 0xf0, 0x07, 0xf8, 0x03, 0x7c, 0x00,
0x1e, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00};
#define screenNumber DefaultScreen(display)
#define rootWindow RootWindow(display,screenNumber)
#define displayWidth DisplayWidth(display,screenNumber)
#define displayHeight DisplayHeight(display,screenNumber)
#define windowX (displayWidth/4)
#define windowY (displayHeight/8)
#define blackPixel BlackPixel(display,screenNumber)
#define whitePixel WhitePixel(display,screenNumber)
#define defaultGC DefaultGC(disprog_dir:jetr.bm>play,screenNumber)
#define depth DefaultDepth(display,screenNumber)
#define borderWidth 1
#define minWidth (displayWidth/2)
#define minHeight (displayWidth/4)
main(argc,argv)
unsigned int argc;
char *argv[];
{
Display *display; /* display id */
Window window; /* main window id */
GC gcor; /* graphic context to or values onto window */
XImage *jetrimage;
unsigned long attribute_mask;
XSetWindowAttributes window_attributes;
XEvent event;
int x,y;
unsigned long gcmask;
XGCValues gcvalues;
Pixmap pixmap;
/* request creation of main display */
if (!(display = XOpenDisplay(NULL)))
{
fprintf(stderr,"WINDOW-F-BADDISP Can't open display\n");
exit(0);
}
/* Define window attributes and create the window */
window_attributes.border_pixel = blackPixel;
window_attributes.background_pixel = whitePixel;
window_attributes.event_mask = ButtonPressMask|ButtonReleaseMask|ExposureMask;
attribute_mask = CWBorderPixel|CWEventMask|CWBackPixel;
/* create the window */
window = XCreateWindow(display,rootWindow,
windowX,windowY,minWidth,minHeight,
borderWidth,depth,
CopyFromParent, /* window class */
CopyFromParent, /* Visual */
attribute_mask,
&window_attributes);
/* Tell the window manager about our window */
XMapWindow(display,window);
/* copy gc for xor function */
gcmask = GCFunction;
gcvalues.function = GXxor; /*ensures exclusive of of pixel values */
gcor = XCreateGC(display, window, GCFunction, &gcvalues);
/* create pix map and then image for jet */
pixmap = XCreatePixmapFromBitmapData(display,window,
jetr_bits,jetr_width,
jetr_height,blackPixel,whitePixel,
depth);
jetrimage = XGetImage(display, pixmap,0,0,jetr_width,jetr_width,AllPlanes
,XYPixmap);
y = minHeight/2;
for(x = minWidth/4; x<= minWidth* 0.75; x++)
{
/* paint the jet on */
XPutImage(display, window, gcor,jetrimage,0,0,x,y,
jetr_width,jetr_height);
XSync(display,0);
/* xor the jet off - this is the bit that 'doesnt' work */
XPutImage(display, window, gcor,jetrimage,0,0,x,y,
jetr_width,jetr_height);
XSync(display,0);
}
do
{
XNextEvent(display,&event);
} while (event.type != ButtonPress);
XFreePixmap(display,pixmap);
XDestroyImage(jetrimage);
XDestroyWindow(display,window);
exit(1);
}
|
| On a "whim" I changed XYPixmap to ZPixmap, and your program now works.
Don't ask...
>> jetrimage = XGetImage(display, pixmap,0,0,jetr_width,jetr_width,AllPlanes
>> ,XYPixmap);
becomes:
jetrimage = XGetImage(display, pixmap,0,0,jetr_width,jetr_width,AllPlanes
,ZPixmap);
-steve-
|