Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!decwrl!sgi!shinobu!odin!news From: hajadi@goofy.csd.sgi.com (Ivan Hajadi) Newsgroups: comp.windows.x Subject: XGetImage, BadMatch Message-ID: <1991Apr17.022705.14758@odin.corp.sgi.com> Date: 17 Apr 91 02:27:05 GMT Sender: news@odin.corp.sgi.com (Net News) Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 133 I copied the reflect_window program from Vol 1 O`Reilly book, and tried to run it. I keep getting BadMatch error. Anyone knows what's wrong with this program ? Configuration : Sun3/60, 4.1.1, X11R4. Thanks. X Error of failed request: BadMatch (invalid parameter attributes) Major opcode of failed request: 73 (X_GetImage) Minor opcode of failed request: 0 Resource id in failed request: 0x600003 Serial number of failed request: 10 Current serial number in output stream: 10 -------- code -------------- #include #include #include Display *disp; int screen; XPoint points[] = { {10,10}, {400,10}, {400,400} }; main() { Window win1, win2; XSetWindowAttributes attr; unsigned long attrmask; unsigned long gcmask; XGCValues gcvalues; GC gc; if (!(disp = XOpenDisplay(NULL))) { printf("Can't open display.\n"); exit(-1); } screen = DefaultScreen(disp); attrmask = CWBackPixel | CWBorderPixel; attr.background_pixel = WhitePixel(disp, screen); attr.border_pixel = BlackPixel(disp, screen); win1 = XCreateWindow(disp, RootWindow(disp, screen), /* parent window */ 100,100, /* x,y location */ 500,500, /* width, height */ 3, /* border width */ CopyFromParent, /* window depth */ InputOutput, /* window class */ CopyFromParent, /* visual type */ attrmask, /* attribute mask */ &attr /* window attributes */ ); win2 = XCreateWindow(disp, RootWindow(disp, screen), /* parent window */ 100,100, /* x,y location */ 500,500, /* width, height */ 3, /* border width */ CopyFromParent, /* window depth */ InputOutput, /* window class */ CopyFromParent, /* visual type */ attrmask, /* attribute mask */ &attr /* window attributes */ ); gcmask = GCBackground | GCForeground; gcvalues.foreground = BlackPixel(disp, screen); gcvalues.background = WhitePixel(disp, screen); gc = XCreateGC(disp, win1, gcmask, &gcvalues); XMapWindow(disp, win1); XMapWindow(disp, win2); XFillPolygon(disp, win1, gc, points, 3, Convex, CoordModeOrigin); XFlush(disp); reflect_window(win1, win2, gc, 500, 500); XFlush(disp); printf("\nHit Enter to quit."); getchar(); /* hit return to exit */ } int reflect_window(window, newwindow, gc, w,h) Window window; Window newwindow; GC gc; unsigned int w; unsigned int h; { XImage *xi; unsigned long pixval1, pixval2; int y; int left_x, right_x; xi = XGetImage(disp, window, 0,0, w,h, AllPlanes, XYPixmap); printf("calculating...."); for (left_x=0; left_x