I tried to get a moving dot on a "Canvas" by XOR-ing the pixel with
$00FFFFFF twice, once to create the dot, the second time to restore the
original color. In doing so, I came across an unexpected (to me) effect of
the XOR function. Can anybody explain what is going on ?
The code looks like this ...
Canvas.Pixels[x,y] := Canvas.Pixels[x,y] xor $00FFFFFF ;
My understanding is that XOR flips a bit in Canvas.Pixels if that bit is set
in the mask $00FFFFFF, or leaves it alone if that bit is not set. However,
the results were as follows ...
Initial Colour clNavy clTeal clBlue
Initial Pixel value $00800000 $00808000 $00FF0000
After one XOR $00C0DCC0 $00A4A0A0 $0000FFFF
After second XOR $00000000 $00808080 $00FF0000
Final Colour is clBlack Grey clBlue
Expected result ? No No Yes
Typecasting to Longint before the XOR and back to TColor after the XOR does
not seem to help.
I suspect that I am getting caught up in some "closest color" rule. Any
ideas ? My general impression is that this works if the intial colour is of
high intensity (uses FF or 00) but not if it is a subdued colour.
--- PPoint 2.00
---------------
* Origin: Kingston, Canada (1:249/109.11)
|