home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.windows.x
- Path: sparky!uunet!utcsri!newsflash.concordia.ca!sifon!thunder.mcrcim.mcgill.edu!mouse
- From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
- Subject: Re: Want to overlay bitmap onto a pixmap
- Message-ID: <1992Nov6.120920.24181@thunder.mcrcim.mcgill.edu>
- Organization: McGill Research Centre for Intelligent Machines
- References: <RPB.92Nov3144841@brain.psy.ox.ac.uk>
- Date: Fri, 6 Nov 92 12:09:20 GMT
- Lines: 46
-
- In article <RPB.92Nov3144841@brain.psy.ox.ac.uk>, rpb@psy.ox.ac.uk (Ray Bellis) writes:
-
- > I have an application where a 3D wireframe object is rendered into a
- > 1 bit deep pixmap and a shaded version is rendered into an 8 bit deep
- > pixmap. I'd like to overlay the wireframe image onto the shaded
- > image, and have the wire frame appear in white on top, with the
- > original black parts of the wireframe not altering the shaded image.
- > I've tried using an XCopyArea with a GCFunction of GXor but that
- > doesn't seem to work.
-
- When copying from a one-bit pixmap to something deeper, you can't use
- XCopyArea - you must use XCopyPlane. But you also have to deal with
- modifying only the portions of the deep pixmap you want to. (To
- simplify the language, I'll speak of "the bitmap" and "the pixmap",
- meaning the 1-bit and 8-bit pixmaps, respectively.)
-
- Assuming you've drawn the wireframe in 1s on a background of 0s in the
- bitmap, and assuming that "gc" is a graphics context of depth 8 on the
- same screen as the pixmap,
-
- set gc foreground=~0, background=0, function=GXandInverted
- XCopyPlane from bitmap to pixmap
- set gc foreground=white, function=GXor
- XCopyPlane from bitmap to pixmap
-
- If you've got the bitmap drawn with 0s on a background of 1s, then just
- read "background" for "foreground", and vice versa, in the above.
- There are other possible ways of setting up the fg/bg/function values;
- for example,
-
- first XCopyPlane: fg=0, bg=~0, function=GXorInverted
- second XCopyPlane: fg=white, function=GXand
-
- There are some other possibilities, of course. You can set the bitmap
- as the stipple in the GC, set the fill-style to FillStippled, and call
- XFillRectangle. You can set the bitmap as the clip-mask of the GC and
- call XFillRectangle. (Both these require you to draw with 1s on a
- background of 0s in the bitmap.) There may be other possibilities, but
- none occur to me at the moment. In most cases I would guess calling
- XCopyPlane twice will give you best performance, but if possible I
- recommend you try them all and see.
-
- der Mouse
-
- mouse@larry.mcrcim.mcgill.edu
-