anderson@cme.nist.gov (William E. Anderson) (06/15/90)
Please pardon my ignorance but I am trying to port a graphics package to X11. This software writes messages to the screen and then unwrites them using the GXxor logical operation. The server is a Sun 3/160 running X11R4 patched through fix-11. On a monochrome display with foreground and background set using WhitePixel() and BlackPixel() respectively, foreground xor writes result in no visible text using XDrawString(). If I do a `XSetForeground(display,gc,backgnd)`, things work. On a color display, xor writes are blank if the foreground is white (either with WhitePixel() or via the colormap). Other colors work fine. It appears that xor writes do not work with the foreground set to white. I assume I am missing something. -- NAME: William E. Anderson TELE: (301) 975-2423 USMAIL: NIST (formerly NBS) INTERNET: anderson@ceee.nist.gov Rm. B-344, Bldg. 220 UUCP: uunet!cme-durer!anderson Gaithersburg, MD 20899
mouse@LARRY.MCRCIM.MCGILL.EDU (der Mouse) (06/16/90)
[William Anderson writes that he's trying to port something to X11] > This software writes messages to the screen and then unwrites them > using the GXxor logical operation. > On a monochrome display with foreground and background set using > WhitePixel() and BlackPixel() respectively, foreground xor writes > result in no visible text using XDrawString(). If I do a > `XSetForeground(display,gc,backgnd)`, things work. You're writing the wrong thing. There is no guarantee that the foreground pixel value is anything special; in particular, it may be 0. Drawing 0s with GXxor won't do a whole lot, now will it? Set the foreground value of the GC to the XOR of the foreground pixel value and the background pixel value. *Then* try drawing with GXxor. You're assuming that the blank window background is pixel value 0 and that the foreground is something else. The situations where it works for you now are precisely those where this is so. On a color machine, for example, assume your background and foreground colors are pixel values 9 and 10 respectively. Then when you draw something (text, line, whatever) with the foreground color and GXxor as the function, the pixels will be set to 9 XOR 10 = 3, which is probably not what you want. (Pixel value 3 will likely come from someone else's colormap cell, and thus will get displayed as an effectively random color.) Instead, store 9 XOR 10 = 3 as the foreground pixel value of the GC. Then when you draw, you will get pixels set to to 9 XOR 3 = 10, which is what you want. The same thing is true on a one-bit screen; it's just that there are only the two possible pixel values, which can easily confuse you because it means that drawing with GXxor will always appear to work with one of them as the GC's foreground color. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu