home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / windows / x / motif / 5866 < prev    next >
Encoding:
Internet Message Format  |  1992-08-27  |  3.5 KB

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