home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / windows / x / 20137 next >
Encoding:
Text File  |  1992-12-11  |  6.0 KB  |  116 lines

  1. Newsgroups: comp.windows.x
  2. Path: sparky!uunet!usc!elroy.jpl.nasa.gov!bondi!sns
  3. From: sns@bondi.jpl.nasa.gov (Sam Southard)
  4. Subject: Re: new FAQ? (programming) masking Pixmaps *efficiently*
  5. Message-ID: <1992Dec11.180230.10091@elroy.jpl.nasa.gov>
  6. Keywords: Pixmap, mask, bitmap, graphic context
  7. Sender: news@elroy.jpl.nasa.gov (Usenet)
  8. Nntp-Posting-Host: bondi.jpl.nasa.gov
  9. Organization: SAR Systems Development & Processing, JPL
  10. References: <1g45bpINNavm@agate.berkeley.edu> <1992Dec11.102303.28704@thunder.mcrcim.mcgill.edu>
  11. Date: Fri, 11 Dec 1992 18:02:30 GMT
  12. Lines: 102
  13.  
  14. Sorry for the length of this one...
  15.  
  16. I read through all I could find & save (including the FAQ) about drawing to
  17. windows and having one pixmap overlay another with one or more pixel values in
  18. the overlaying pixmap being transparent.  The two methods I decided would be
  19. appropriate were using the clip_mask feature of the graphics context, or by
  20. using FillStippled.
  21.  
  22. However, there was a note in the Xlib programming manual about the server
  23. having a "best" size (or perhaps a list of best sizes) for stipples, with no
  24. corresponding limitation (at least not that I saw) for using clip_mask.  Since
  25. my application will have arbitrarily-sized images, I decided that I would use
  26. the clip_mask.
  27.  
  28. Then I read the following response to someone else's related question:
  29.  
  30. In article <1992Dec11.102303.28704@thunder.mcrcim.mcgill.edu> mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:
  31. >In article <1g45bpINNavm@agate.berkeley.edu>, beorn@elk.Berkeley.EDU (Beorn Johnson) writes:
  32. >> The pixmaps need to be masked such that only the non-zero (or
  33. >> non-background color?) PIXELS are copied to the screen.
  34. >
  35. >> I can, of course, use the "clip_mask" feature of the graphics
  36. >> context.  [This turns out to be too slow on at least one server.]
  37. >
  38. >The server in question is probably doing the common thing and
  39. >converting clip-masks to rectangle lists.
  40. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  41. ...
  42. >If you have a bitmap somewhere that is a mask, set to 1 where you want
  43. >pixels drawn and 0 elsewhere, you could set that as the stipple in the
  44. >GC and do a fill with fill-style FillStippled.  (Repeat for each
  45. >bitplane, for multi-color pictures.)
  46.  
  47. The item about which I'm specifically concerned is indicated with "^".  My
  48. concern is about the server "doing the common thing and converting clip-masks
  49. to rectangle lists."  Specifically, when is this conversion done?
  50.  
  51. I had anticipated setting the clip_mask to a given pixmap and then being free
  52. to do whatever I wanted with that pixmap.  Then, when I actually did something
  53. which used that GC, it would auto-magically take care of things for me.
  54. However, the conversion method implies that either:
  55.  
  56. (1) I must set the clip_mask every time it is changed (or just before it is
  57.     used, if it has changed since the last use).  This is a little less
  58.     convinient, but would probably perform acceptably, assuming the
  59.     clip_mask feature would perform acceptably at all.
  60. (2) The server does this conversion just before every GC use.  This is likely
  61.     to be quite slow.
  62. (3) The server keeps track of then the clip_mask pixmap is changed and
  63.     converts the when it changes (or perhaps before a use if the pixmap
  64.     has been changed).
  65.  
  66. I re-examined the Xlib reference manual to see if maybe using stipple was a
  67. better alternative, given the above information.  It appears that fill_style is
  68. not significant for things such as XCopyArea.  Is this a misprint, or, if I do
  69. decide to use FillStippled, must I retain all graphics commands and re-issue
  70. them when an area of the window is exposed?  I had planned on retaining a
  71. pixmap with the window contents for this purpose.  I suppose that overlay
  72. contents are not likely to be extremely complicated, so retaining commands
  73. would not be such a horrible thing.
  74.  
  75. Perhaps there's a better way to do what I'm trying to do, so I'll give a little
  76. more information on that.
  77.  
  78. I'm basically trying to emulate a mid-range (at least what I consider a mid-
  79. range) display device.  Those characteristics are at least 8 bit planes for
  80. regular graphics, a text overlay plane, and a graphics overlay plane (perhaps
  81. two bits for the graphics overlay).  Each bitmap (main, text overlay, and
  82. graphics overlay) can contain essentiall arbitrary information.  I don't care
  83. about supporting X devices with fewer than 8 bits.  I do need to be able to
  84. manipulate color LUTs, so read/write LUT entries are a must (at least for
  85. devices which support it - I would want the program to work in a semi-crippled
  86. way on StaticGrey visuals, for exmaple).
  87.  
  88. If my understanding of things is correct, if I were to actually use bit-planes
  89. for my colors and wanted to run in the default colormap, I would only have at
  90. most 7 bit-planes available on an 8-bit device (some colors would be used by
  91. the window manager, other applications, etc.).  If I use one bit for text and
  92. one for graphics overlay planes, I'm only left with 32 colors (5 bits) for the
  93. main graphics, which is too few.  If I combine the two overlay planes I'm left
  94. with 64 colors, which is just barely acceptable.
  95.  
  96. I'd planned on having each source pixmap (main, text overlay, and graphics
  97. overlay) as an 8-bit pixmap (assuming the screen depth was 8 bits) and using
  98. different color map cells for each pixmap.  I would then keep an additional
  99. 1-bit pixmap for each of the text & graphics overlay planes.  The 1-bit
  100. pixmaps would be used for clip_mask.  I could then just use XCopyArea in the
  101. appropriate order and I'd have my overlay planes.
  102.  
  103. If I used 3 colors (plus the "transparent" color) for the graphics overlay,
  104. plus 1 color for text overlay, I would still be left with 150-200 colors for
  105. the main graphics.  I could add significantly more colors for the overlay
  106. planes (say 7 and 3) and still be left with about the same number of colors
  107. for text.
  108.  
  109. In a related question, where would I go to find details on any X extensions (or
  110. non-extensions, though I've not seen anything in the standard documents) which
  111. would allow me to detect overlay planes of the device on which I'm working and,
  112. if the device has such planes, how to use them?
  113.  
  114. Thanks for any help you can give,
  115. Sam Southard, Jr.
  116.