home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!ucbvax!istwok.ods.com!chris
- From: chris@istwok.ods.com (Chris Atkins)
- Newsgroups: comp.windows.x.motif
- Subject: Re: Overlaying pixmaps
- Message-ID: <199208271452.AA21566@istwok.ods.com>
- Date: 27 Aug 92 14:52:32 GMT
- References: <9208220556.AA20184@ponder>
- Sender: daemon@ucbvax.BERKELEY.EDU
- Distribution: inet
- Organization: The Internet
- Lines: 60
-
- I received the following message the other day, the response to which I believe
- would be of general interest.
- >
- > I will be very happy, If you can suggest me a way to do the following:
- >
- > I have a gif file converted to a XPM file and displayed as a
- > pixmap in my drawing area widget.
- >
- > I want to display another pixmap over the the first one with
- > exclusive-OR property, so that I can remove the second pixmap
- > and display on the first in another location.
- >
- > I am able to do this with GXor/and/copy. When I do this with
- > GXxor this will mess the second pixmap.
- >
- > So, Please suggest me a method so that I can display my second
- > pixmap over the first one with XOR property.
- >
- > I have another request. That is,
- >
- > When I display the xlogo64 provided by the X sources over my
- > first pixmap (which is a NASA shuttle takeoff scene), I am
- > getting it with a rectangle with some color and the letter X.
- >
- > How can I just display the letter (that is the contents of the
- > bitmap or Just the contents of any pixmap) over the first pixmap.
- >
- > I really appreciate your guidance for the above doubts. I hope, I am
- > NOT disturbing you. Feel free to express your opinions.
- >
-
- I assume that you are trying to superimpose a bitmap on a color image and
- trying to use the concept of rubber banding to do this. The problem with
- rubber banding on a multicolor background is that when you do the xor, each
- different background color gets a seperate pixel value. For example, if you
- have 4 background colors with the following binary pixel values (I will use 4
- bit color for the example) a) 0110 b) 1101 c) 1110 d)0101 and you XOR this
- value with a value of 1001 then the new pixel values are a')1111 b')0100
- c') 0111 d') 1100. Remember that these new values are really indices into
- the currently installed colormap. Unless you have created a colormap with
- read/write colorcells so that you could place RGB values in a specific cell,
- XAllocColor and XAllocNamedColor don't allow you to specify which cell to use
- for the RGB value, they return the cell # to you, then you don't know what color
- will be displayed for the four new pixel values. If you wish to do this with
- rubberbanding, you need to look at OReilly volume 1 section 7.4.2, Allocating
- Read/Write Colorcells for overlays. This approach will work, but will severely
- limit the number of colors available for the background image.
-
- Another approach is to use the clip_mask member of the GC. The idea is to set
- the clip_mask member of the GC to the bitmask you wish to overlay. The pixels
- you wish to write should be set. You would then use the clip_x_origin and
- clip_y_origin to position the clip_mask in the drawable you wish to overwrite.
- You can then use the GXset function to overlay the bitmap on the image and the
- CXCopy function to undo the effect when copying from a pixmap holding the image
- back to the drawable. Only the bits set in the clip mask will be affected, and
- unlike the rubber band approach above you know which colors will appear on the
- screen, and unlike the overlay approach, you do not eat up a lot of colorcells.
-
- Chris Atkins
- chris@ods.com
-