From: debbieg@mathworks.com (Debbie)
Newsgroups: fj.mail-lists.x-window
Subject: problem with clipmasks
Date: 24 Jul 92 22:53:42 GMT
Distribution: fj
Organization: Workstation Div., Supermicro Systems Group, Sony Corporation

Date: Fri, 24 Jul 92 14:37:53 EDT
Message-Id: <9207241837.AA02694@turing.mathworks.com>

Hi,

I'm having a problem with clipmasks and blitting.
Here's the situation:


		+-------------------------------------------+
		|                                           |
		|                ............               |
		|                .          .               |
		|                .          .               |
		|                .          .               |
		|                .          .               |
		|                .          .               |
		|                .          .               |
		|                .          .               |
		|                .      +-------+           |
		|                .      |   .   |           |
		|                .      |   .   |           |
		|                .      +-------+           |
		|                .          .               |
		|                ............               |
		|                                           |
		|                                           |
		+-------------------------------------------+

The outer box is my window.  The dotted ('.') box is the current
GC clipmask.  The small box is the area where I want to blit
an image.

The image could look something like this:

	+--------+
	|xxx/\xxx|
	|xx/  \xx|
	|x/    \x|
	|/      \|
	|\      /|
	|x\    /x|
	|xx\  /xx|
	|xxx\/xxx|
	+--------+

Where x is unknown and the blank part is filled with what I want
to be displayed on the screen.
I also have a clipmask set up to look just like the image except
that the x's are 0's and the blank part is filled with 1's.

How do I blit the image through my clipmask through the GC's
clipmask onto the screen?  I've tried a lot of things and none of
them seems to work.
Here is the final way I tried:
1) Create a 1 bit blank pixmap and a Screen Depth blank pixmap.
2) Create the clipmask image and the data image.
3) Do an XPutImage using the window's gc to put the clipmask
   image into the Screen Depth blank pixmap.
4) Create a 1 bit gc (its drawable is the 1 bit pixmap)
   with foreground 1 and background 0.
5) XCopyPlane the Screen Depth pixmap to the 1 bit blank pixmap.
6) Set the window's gc's clipmask to the 1 bit pixmap.
7) Set the window's gc's cliporigin to where the image is going
   in the window.
8) XPutImage the image into the window.

Somehow, after step 3, the Screen Depth pixmap is still blank (and doesn't
contain the clipmask ANDed with the window's gc's clipmask like it should)
no matter what I try setting the clip origin to.  When I set the window's
gc's clipmask to None though, the Screen Depth pixmap contains the whole
clipmask image.
How can I get the Screen Depth pixmap to contain the clipmask image ANDed
with the window's gc's clipmask?????
Or can anyone tell me a better way to do this whole thing?


-------------------------------------------------------
debbieg@mathworks.com                508/653.1415  x328
the mathworks, inc, 24 prime park way, natick, ma 01760
-------------------------------------------------------