home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / windows / x / 21040 < prev    next >
Encoding:
Text File  |  1993-01-12  |  5.4 KB  |  135 lines

  1. Newsgroups: comp.windows.x
  2. Path: sparky!uunet!mcsun!ub4b!reks.uia.ac.be!news
  3. From: makke@wins.uia.ac.be (Marc Gemis)
  4. Subject: GXxor and GXnor (Summary)
  5. Message-ID: <MAKKE.93Jan12083441@wins.uia.ac.be>
  6. Sender: news@reks.uia.ac.be (USENET News System)
  7. Organization: /home/wins/inf/makke/.organization
  8. Distribution: comp
  9. Date: Tue, 12 Jan 1993 07:34:41 GMT
  10. Lines: 123
  11.  
  12.  
  13. In article <MAKKE.93Jan8172333@wins.uia.ac.be> I wrote:
  14. >Hi,
  15. >
  16. >I found the following strange behavior in X11R4, delivered with DG/UX 5.4.1.
  17. >To have xor behavior, (draw on a set pixel means clear that pixel),
  18. >I must use GXnor. On a Sun with X11R5, I'll have to use GXxor.
  19. >My question is: Is this a bug in the DG/UX-port, a bug in X11R4
  20. >and are there any other systems that have the same problem ?
  21. >
  22. >I have a small Motif program to test this. If you want I can send you
  23. >a copy of it.
  24. >
  25. >I'll summarize the responses and post it to the net.
  26. >
  27. >Thanks in advance.
  28. >
  29.  
  30. I misunderstand the concept of GXxor, as pointed out by Errol Crary
  31. (errolc@tv.tv.tek.com.).
  32.  
  33. Errol> I would guess from the wording of your news article that the
  34. Errol> answer is that you are not understanding the concept of a pixel
  35. Errol> and of xor in this case.
  36.  
  37. Errol> First, a pixel is a value that has bits set in different places
  38. Errol> depending upon the color mapping hardware of your system. Only
  39. Errol> in the simplist case- mono screen- does that become a case that
  40. Errol> you can pre-guess.
  41.  
  42. Errol> For example a White pixel might have a value of 0xffffff while
  43. Errol> a Black pixel might have a value of 0x1.
  44.  
  45. Errol> Second, there is no concept of set and clear of a pixel in X.
  46. Errol> What are you expecting when you say clear? Does the pixel value
  47. Errol> represent the Background color, or ???. And to set a pixel
  48. Errol> means ???
  49.  
  50. Errol> This means that the idea of xor is to convert pixel values to a
  51. Errol> known pattern based on the boolean xor operation usually so
  52. Errol> that the pixels may later be converted back to their original
  53. Errol> color. Oliver Jones seems to be the expert on this set of
  54. Errol> operations, and describes them best. I don't see his normal
  55. Errol> response in the FAQ, but I do see one by Flatters and Whaley
  56.  
  57. Errol> -----------------------------------------------------------
  58. Errol> Subject: 139) Why doesn't GXxor produce mathematically-correct
  59. Errol> color values?
  60.  
  61. Errol>     When using GXxor you may expect that drawing with a value of
  62. Errol> black on abackground of black, for example, should produce
  63. Errol> white.  However, the drawing operation does not work on RGB
  64. Errol> values but on colormap indices. The color that the resulting
  65. Errol> colormap index actually points to is undefined and visually
  66. Errol> random unless you have actually filled it in yourself. [On many
  67. Errol> X servers Blackand White often 0/1 or 1/0; programs taking
  68. Errol> advantage of this mathematical coincidence will break.]  If you
  69. Errol> want to be combining colors with GXxor, then you should be
  70. Errol> allocating a number of your own color cells and filling them
  71. Errol> with your chosen pre-computed values.  If you want to use GXxor
  72. Errol> simply to switch between two colors, then you can take the
  73. Errol> shortcut of setting the background color in the GC (graphics
  74. Errol> context) to 0 and the foreground color to a value such that
  75. Errol> when it draws over red, say, the result is blue, and when it
  76. Errol> draws over blue the result is red.  This foreground value is
  77. Errol> itself the XOR of the colormap indices of red and blue.
  78.  
  79. Errol> [Thanks to Chris Flatters (cflatter@zia.aoc.nrao.EDU) and Ken
  80. Errol> Whaley (whaley@spectre.pa.dec.com), 2/91]
  81. Errol> -------------------------------------------------------------
  82.  
  83. Errol> Without testing, I think the hint you need is that there are 2
  84. Errol> colors that are of concern-- Present pixel and Desired pixel.
  85. Errol> Create a conversion mask by Mask = Present ^ Desired.  Now, to
  86. Errol> go from the present color use the mask with the GXxor
  87. Errol> operation, and to get back to the current color, use the mask a
  88. Errol> second time with the GXxor operation.
  89.  
  90. Errol> The only places you are guaranteed the Desired color are the
  91. Errol> pixels that are the Present color. All other pixels will be
  92. Errol> changed, and will revert, but not to the Desired color and the
  93. Errol> Present color.
  94.  
  95. Errol> I hope this helps. I would guess that DG does not use the same pixel values
  96. Errol> as Sun for the WhitePixel and BlackPixel, and that is where you are getting
  97. Errol> your error. Have you printed the values of these variables on both
  98. Errol> machines??
  99.  
  100. The solution is to set the mask to Present ^ Desire (see above).
  101.  
  102. in my code this gives:
  103.  
  104.      values.function = GXxor ;
  105.      values.foreground = BlackPixelOfScreen(XtScreen(wdg)) ^ WhitePixelOfScreen(XtScreen(wdg));
  106.  
  107.  
  108. This was also the answer of George Ross (gdmr@dcs.edinburgh.ac.uk).
  109.  
  110.  
  111. I would like to thank
  112.  
  113.  
  114. dhawes@dcs.qmw.ac.uk
  115. George Ross (gdmr@dcs.edinburgh.ac.uk)
  116. Errol Crary (errolc@tv.tv.tek.co)
  117. Mark Lanzo (gecko!lanzo@uunet.UU.NET)
  118.  
  119.  
  120.  
  121. --
  122.  
  123.  
  124.  
  125. --------------------------------------------------------------------------
  126. Marc Gemis                                   Tel: + 32 (3) 820.24.18
  127. University of Antwerp (UIA)                  Fax: + 32 (3) 820.24.21
  128. Dept. Math. and Comp. Science                Telex 33.646
  129. Universiteitsplein 1                         Email: gemis@uia.ac.be
  130. B-2610 Wilrijk - Antwerpen
  131. BELGIUM
  132.                 A dog is for life... not just for Christmas
  133. --------------------------------------------------------------------------
  134.  
  135.