Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!uc!cs.umn.edu!dmshq!com50!pai!erc From: erc@pai.UUCP (Eric Johnson) Newsgroups: comp.windows.x Subject: Re: How to copy from depth 1 to depth n Summary: XCopyPlane() Keywords: bitmaps, pixmaps, images Message-ID: <1369@pai.UUCP> Date: 26 Jul 90 14:36:50 GMT References: <114409@linus.mitre.org> Organization: Boulware Technologies, Inc., Burnsville, MN Lines: 53 In article <114409@linus.mitre.org>, dsr@luke.mitre.org (Douglas S. Rand)writes: > I'm a little stuck. I can create a pixmap from a bitmap file > with XReadBitmapData. Great. Now what do I do to create > a pixmap with the same depth as my display but with the same > bitmap data? What I don't want to do (and the only alternative I > see) is to do a XGetImage and XGetPixel along with a separate > XCreatePixmap (right depth). > > Douglas S. Rand > Internet: > Snail: MITRE, Burlington Road, Bedford, MA > Disclaimer: MITRE might agree with me - then again... Here's a suggestion: 1) Create a pixmap of the proper size, but the same depth as the drawable you want to display it on (e.g., the window you want to show this image in). Create a Graphics Context (GC) for this pixmap. DefaultDepth( display, screen ) can often give an acceptable value for this depth. 2) Create your bitmap from data. What you'll get is a single-plane depth pixmap. 3) Use XCopyPlane() to copy one plane from the single-plane pixmap (your bitmap in #2) to the potentially multi-plane pixmap (created in #1). Use the GC also created in #1: XCopyPlane( display, /* display connection */ single_plane_bitmap, /* source drawable */ multi_plane_pixmap, /* destination drawable */ gc, /* created in #1 */ 0, 0, /* source X, Y */ width, height, /* size of bitmap AND pixmap */ 0, 0, /* destination X, Y */ 0x01 ); /* which plane to copy */ Note that your bitmap (really a Pixmap type) only has one plane. Your destination pixmap may have many more planes (or one if on a monochrome system). So, you want to copy the one plane from the bitmap to the pixmap. For more information, you can check out Advanced X Window Applications Programming, coming soon from MIS: Press (phone in USA: 1-800-MANUALS). Hope this helps, -Eric -- Eric F. Johnson phone: +1 612 894 0313 BTI: Industrial Boulware Technologies, Inc. fax: +1 612 894 0316 automation systems 415 W. Travelers Trail email: erc@pai.mn.org and services Burnsville, MN 55337 USA