Keith Thompson said:
Surely it's simpler to invert the image itself, using the unary "~"
operator, rather than constructing another bitmap and xor'ing against
that.
<OT>
Yes, but probably what he was getting at was more along the lines of the
famous Atari (was it?) XOR patent for drawing the cursor, namely, that
you can "stamp" arbitrary data on other data, and remove it again with
XOR, since:
(x ^ y) ^ y == x
(I'm sure you already knew this, Keith; this post is for posterity.)
Cursor on:
....XXX.. XXXXXXXX XXX...XX
...XX.XX. XXXXXXXX XX..X..X
..XX...XX XXXXXXXX X..XXX..
..XXXXXXX XXXXXXXX X.......
..XX...XX XOR XXXXXXXX == X..XXX..
..XX...XX XXXXXXXX X..XXX..
..XX...XX XXXXXXXX X..XXX..
......... XXXXXXXX XXXXXXXX
Then cursor off:
XXX...XX XXXXXXXX ...XXX..
XX..X..X XXXXXXXX ..XX.XX.
X..XXX.. XXXXXXXX .XX...XX
X....... XXXXXXXX .XXXXXXX
X..XXX.. XOR XXXXXXXX == .XX...XX
X..XXX.. XXXXXXXX .XX...XX
X..XXX.. XXXXXXXX .XX...XX
XXXXXXXX XXXXXXXX ........
Of course, the cursor could be anything--not just a solid block--and the
character beneath would be restored to its original state when the
cursor was turned off.
IIRC, old versions of Windows would draw the window frame in XOR mode
when you were moving or resizing it. Ugly but effective.
</OT>
-Beej, still looking for that elusive XNOT operation.