home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / windows / x / 14600 < prev    next >
Encoding:
Text File  |  1992-07-29  |  3.8 KB  |  96 lines

  1. Newsgroups: comp.windows.x
  2. Path: sparky!uunet!snorkelwacker.mit.edu!thunder.mcrcim.mcgill.edu!mouse
  3. From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
  4. Subject: Re: Blitting through a clipmask
  5. Message-ID: <1992Jul30.002456.6378@thunder.mcrcim.mcgill.edu>
  6. Organization: McGill Research Centre for Intelligent Machines
  7. References: <9207232018.AA00192@yellowpig.mathworks.com>
  8. Date: Thu, 30 Jul 92 00:24:56 GMT
  9. Lines: 86
  10.  
  11. In article <9207232018.AA00192@yellowpig.mathworks.com>, debbieg@mathworks.UUCP writes:
  12.  
  13. > I'm having a problem with clipmasks and blitting.
  14.  
  15. [has a (rectangular) clip area set in a GC already, wants to blit a
  16. non-rectangular image to a position where it may be partially clipped
  17. by the GC's clip.]
  18.  
  19. > How do I blit the image through my clipmask through the GC's clipmask
  20. > onto the screen?  I've tried a lot of things and none of them seems
  21. > to work.
  22.  
  23. Okay, as I understand it you have
  24.  
  25.     - GC whose clip is set to what you want.
  26.     - Pixmap (depth matching that of the window) containing your
  27.         picture in some pixels, with unspecified values in the
  28.         other pixels.
  29.     - Bitmap containing 1 where the pixmap has stuff of interest, 0
  30.         elsewhere.
  31.  
  32. It should work to:
  33.  
  34.     - CopyArea the pixmap into a temporary pixmap of the same size
  35.         and depth, using a GC with no clipping.
  36.     - CopyPlane the bitmap into this temporary pixmap, with fg=~0,
  37.         bg=0, function=GXand.
  38.     - CopyPlane the bitmap onto the window with fg=0, bg=~0,
  39.         function=GXand, using the clipping GC.
  40.     - CopyArea the temporary pixmap to the window with
  41.         function=GXor, using the clipping GC.
  42.  
  43. If you don't mind destroying the don't-care pixels in the pixmap, you
  44. can skip the first item and do the rest using the pixmap itself as the
  45. temporary.
  46.  
  47. If you don't like the way this briefly flashes a piece of the window
  48. with pixel value 0, then you can CopyArea that piece of the window to a
  49. temporary, do the above on the temporary without clipping, and then
  50. CopyArea back with clipping.
  51.  
  52. > Here is the final way I tried:
  53. > 1) Create a 1 bit blank pixmap and a Screen Depth blank pixmap.
  54. > 2) Create the clipmask image and the data image.
  55. > 3) Do an XPutImage using the window's gc to put the clipmask image
  56. >      into the Screen Depth blank pixmap.
  57. > 4) Create a 1 bit gc (its drawable is the 1 bit pixmap) with
  58. >      foreground 1 and background 0.
  59. > 5) XCopyPlane the Screen Depth pixmap to the 1 bit blank pixmap.
  60. > 6) Set the window's gc's clipmask to the 1 bit pixmap.
  61. > 7) Set the window's gc's cliporigin to where the image is going in
  62. >      the window.
  63. > 8) XPutImage the image into the window.
  64.  
  65. This has lots of things wrong with it.  To list them as I notice them,
  66. reading over it...
  67.  
  68. - The PutImage in step 3 will be clipped by a clipping area designed
  69.     for clipping the whole window, not just this little part of it.
  70.     There's really no reason to clip at this step, though if you want
  71.     to you *might* be able to make it work by setting the clip origin
  72.     of the GC to the negative of the small area's position in the
  73.     window.
  74.  
  75. - I don't know *what* step 5 is supposed to do.  You're picking out one
  76.     of the bitplanes (you don't say which one); Murphy's law says
  77.     you'll get one that's constant across the whole pixmap....
  78.  
  79. - Step 6 looks mildly sensible, except that you probably want to use
  80.     the clipmask bitmap instead of one containing whatever weirdness
  81.     step 5 resulted in.  You probably also want to combine the clips,
  82.     not replace it, or you'll lose the clip you had already set up.
  83.  
  84. - If step 6 is fixed, the rest looks fine.
  85.  
  86. > How can I get the Screen Depth pixmap to contain the clipmask image
  87. > ANDed with the window's gc's clipmask?????
  88.  
  89. Why would you want to?  You'd want in a bitmap, not a deep pixmap.
  90. Also, why would you care?  Just do all the operations except for the
  91. final drawing to the window with GCs that don't clip at all....
  92.  
  93.                     der Mouse
  94.  
  95.                 mouse@larry.mcrcim.mcgill.edu
  96.