home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / windows / x / 18802 < prev    next >
Encoding:
Text File  |  1992-11-07  |  2.5 KB  |  56 lines

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