Path: utzoo!utgpu!watserv1!watmath!att!bellcore!rutgers!tut.cis.ohio-state.edu!snorkelwacker!bloom-beacon!LARRY.MCRCIM.MCGILL.EDU!mouse From: mouse@LARRY.MCRCIM.MCGILL.EDU (der Mouse) Newsgroups: comp.windows.x Subject: Re: Problem with GXxor on sun server Message-ID: <9006160338.AA14478@Larry.McRCIM.McGill.EDU> Date: 16 Jun 90 03:38:37 GMT Sender: root@athena.mit.edu (Wizard A. Root) Organization: The Internet Lines: 40 [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