Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!mit-eddie!snorkelwacker!usc!ucsd!ucbvax!pasteur!graft!scott From: scott@graft.Berkeley.EDU (Scott Silvey) Newsgroups: comp.windows.x Subject: XCopyPlane() bug (sort of). Message-ID: <26023@pasteur.Berkeley.EDU> Date: 9 Jul 90 22:13:49 GMT Sender: news@pasteur.Berkeley.EDU Reply-To: scott@xcf.berkeley.edu Organization: UC Berkeley Experimental Computing Facility Lines: 54 I am trying to turn a window's image into an X11 bitmap. I want to write this bitmap out to a file using XWriteBitmapFile(). However, I can't find any way to do this using XCopyPlanes or XGet/PutImage if the window is on a color display (multiple planes). 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. Here are the two methods I've tried: 1) [XCopyPlane()] 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): XCopyPlane(display, window, /* 8 bits deep */ bitmap, /* 1 bit deep */ gc, /* GC with function GXor */ 0, 0, width, height, 0, 0, /* width, height == 300 */ plane_mask); /* only 1 bit set */ 2) [XGetImage() / XPutImage()] For XGetImage() on the type XYPixmap, the Xlib manual says that the depth of the returned image is equal to the number of planes requested in the plane mask. So, I tried to use XGetImage() and XPutImage() with type XYPixmap, but this also generates a BadMatch error: image = XGetImage(display, window, /* 8 bits deep */ 0, 0, width, height, /* width, height == 300 */ plane_mask, /* 1 bit set */ XYPixmap); XPutImage(display, bitmap, /* 1 bit deep */ gc, /* GC with function GXor */ image, /* image from XGetImage */ 0, 0, 0, 0, width, height); /* width, height == 300 */ The one thing I CAN get to work is to do an XGetImage() and then query each and every pixel using XGetPixel. For each pixel that is not the background color, I do and XDrawPoint() on the bitmap. This is dog-slow though, doing two X operations per pixel (what if I have a megapixel image?!). It really suprised me to find that there is no supported way to copy data between pixmaps of different depth (or actually from a multiplane pixmap to a bitmap). Am I right this deficiency here? Or am I missing something obvious? Will there be more support for these sort of operations in future X releases? Thanks a lot for your help if you answer these questions ... Scott