LQ Newbie
Registered: Sep 2003
Posts: 1
Rep:
|
Xlib question
Hi all,
I'm in the process of learning X, here's a basic program that should draw a pixmap on the display, but instead I get runtime error. I'd really appreciate any help...
================
#include <X11/Xlib.h>
Display *dpy;
XImage *img;
Visual *visual;
GC gc;
Window win;
XEvent report;
int win_width=500, win_height=500;
int img_width=16, img_height=1;
char myImage[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
int main() {
dpy = XOpenDisplay(NULL);
win = XCreateSimpleWindow(dpy, RootWindow(dpy,0), 1, 1, win_width, win_height, 0, WhitePixel (dpy,0), WhitePixel(dpy,0));
XMapWindow(dpy,win);
XSelectInput(dpy,win,ExposureMask | KeyPressMask | ButtonPressMask);
gc = XCreateGC(dpy, win, 0,0);
visual = DefaultVisual(dpy, DefaultScreen(dpy));
img = XCreateImage (dpy, visual, 8, ZPixmap, 0, myImage, img_width, img_height, 8, 0);
XPutImage(dpy, win, gc, img, 0, 0, win_width/2, win_height/2, img_width, img_height);
XFlush(dpy);
while(1) {
XNextEvent(dpy,&report);
switch (report.type) {
case Expose:
break;
case KeyPress:
break;
}
}
return(0);
}
==============
runtime error:
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 72 (X_PutImage)
Serial number of failed request: 11
Current serial number in output stream: 11
Who knows why?
Thanks!
|