Path: utzoo!utgpu!watserv1!watmath!att!rutgers!tut.cis.ohio-state.edu!snorkelwacker!bloom-beacon!EXPO.LCS.MIT.EDU!rws From: rws@EXPO.LCS.MIT.EDU (Bob Scheifler) Newsgroups: comp.windows.x Subject: Re: XCopyPlane() bug (sort of). Message-ID: <9007101317.AA18600@expire.lcs.mit.edu> Date: 10 Jul 90 13:17:57 GMT References: <26023@pasteur.Berkeley.EDU> Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 52 There is apparently no way for me to copy the information from the window to a single plane bitmap short of checking each and every pixel one at a time. You are wrong. The Xlib manual says that XCopyPlane() doesn't care if the depth of it's two drawables is different, however, when I try the following line, XCopyPlane() generates a BadMatch error (Invalid parameter attribues) One of the causes of BadMatch is if the two drawables are on different screens. You don't give any hint about what system you're running on, what release you're using (how do you expect any help?). Perhaps you're running on a 3/60 or other dual-screen server, and created the bitmap on a different screen? Submitting a complete but stripped-down program is always more likely to get help than code fragments, the bug is almost always somewhere you don't think it is (else you would have found it :-). So, I tried to use XGetImage() and XPutImage() with type XYPixmap, but this also generates a BadMatch error: This sounds like you have created the gc with the wrong depth. Or am I missing something obvious? I have no idea what you're missing. The following works just fine for me: #include main() { Display *dpy; Pixmap pix, bit; GC gc8, gc1; XImage *img; dpy = XOpenDisplay(0); pix = XCreatePixmap(dpy, DefaultRootWindow(dpy), 32, 32, 8); bit = XCreatePixmap(dpy, DefaultRootWindow(dpy), 32, 32, 1); gc8 = XCreateGC(dpy, pix, 0, 0); gc1 = XCreateGC(dpy, bit, 0, 0); XFillRectangle(dpy, pix, gc8, 0, 0, 32, 32); XSetForeground(dpy, gc8, 1); XDrawLine(dpy, pix, gc8, 0, 0, 32, 32); XCopyPlane(dpy, pix, bit, gc1, 0, 0, 32, 32, 0, 0, 1); XWriteBitmapFile(dpy, "/tmp/rws1", bit, 32, 32, 15, 15); img = XGetImage(dpy, pix, 0, 0, 32, 32, 1, XYPixmap); XPutImage(dpy, bit, gc1, img, 0, 0, 0, 0, 32, 32); XWriteBitmapFile(dpy, "/tmp/rws2", bit, 32, 32, 15, 15); XCloseDisplay(dpy); }