home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / windows / x / 14337 < prev    next >
Encoding:
Internet Message Format  |  1992-07-24  |  2.5 KB

  1. Path: sparky!uunet!gatech!usenet.ins.cwru.edu!agate!dog.ee.lbl.gov!epb9.lbl.gov!envbvs
  2. From: envbvs@epb9.lbl.gov (Brian V. Smith)
  3. Newsgroups: comp.windows.x
  4. Subject: Re: GXcopy and GXxor
  5. Date: 24 Jul 1992 16:12:05 GMT
  6. Organization: lbl
  7. Lines: 42
  8. Distribution: world
  9. Message-ID: <24854@dog.ee.lbl.gov>
  10. References: <xia.711911424@odin> <MICHAEL.920724095149@maine.maine.EDU>
  11. NNTP-Posting-Host: 128.3.12.98
  12.  
  13. In article <MICHAEL.920724095149@maine.maine.EDU>, michael@maine.maine.edu (Michael Johnson) writes:
  14.  
  15.  
  16. |> There's not really much you can do about it. When you XOR the pixels, the
  17. |> resulting pixel value is going to yield whatever color that pixel maps to.
  18. |> Do you understand what an XOR operation is?
  19. |> 
  20. |> I find that a useful value for rubber-banding with XOR is -1, cast to Pixel.
  21. |> This usually yields a consistent color (usually black, though I've seen cases
  22. |> where an application actually allocated pixels that high, resulting in a
  23. |> different color).
  24.  
  25. This has been asked many times and is in the FAQ:
  26.  
  27. ----------------------------------------------------------------------
  28. Subject: 129)  Why doesn't GXxor produce mathematically-correct color values?
  29.  
  30.         When using GXxor you may expect that drawing with a value of black on a
  31. background of black, for example, should produce white. However, the drawing
  32. operation does not work on RGB values but on colormap indices. The color that
  33. the resulting colormap index actually points to is undefined and visually
  34. random unless you have actually filled it in yourself. [On many X servers Black
  35. and White often 0/1 or 1/0; programs taking advantage of this mathematical
  36. coincidence will break.]
  37.         If you want to be combining colors with GXxor, then you should be 
  38. allocating a number of your own color cells and filling them with your chosen
  39. pre-computed values.
  40.         If you want to use GXxor simply to switch between two colors, then you 
  41. can take the shortcut of setting the background color in the GC to 0 and the
  42. foreground color to a value such that when it draws over red, say, the result 
  43. is blue, and when it draws over blue the result is red. This foreground value 
  44. is itself the XOR of the colormap indices of red and blue.
  45.  
  46. [Thanks to Chris Flatters (cflatter@zia.aoc.nrao.EDU) and Ken Whaley 
  47. (whaley@spectre.pa.dec.com), 2/91]
  48.  
  49. ----------------------------------------------------------------------
  50.  
  51. -- 
  52. Brian V. Smith    (bvsmith@lbl.gov)
  53. Lawrence Berkeley Laboratory
  54. I don't speak for LBL; they don't pay me enough for that.
  55.