Re:Strange thing happen with TCanvas
Quote
smcg...@gpu.srv.ualberta.ca (Stephen McGann) wrote:
[...]
Quote
>Then I simple loop copying each pixel of the canvas (via the Pixels
>property) of the source to the canvas of the other TImage component (call
>it the destination). The resulting bitmap in the destination seems to be
>in a palette of 10 or 20 colors. Strange.
>Assuming I may have had a palette problem I decided to copy the top half
>of the source image to the bottom half of the SAME component...the same
>thing happened. The top half was a nice 256 color image and the bottom
The problem is that when you set the value of ACanvas.Pixels what
you get is the closest matching system color (I imagine they set it up that
way is because these are the only colors they know will be available when
the image is finally displayed. OTOH adding $02000000 to a color value says
"use the closest available color in the currently realized palette". Try
for j:=1 to 100 do
for k:=1 to 100 do
image1.canvas.pixels[j,k]:=image1.canvas.pixels[j+100,k];
and
for j:=1 to 100 do
for k:=1 to 100 do
image1.canvas.pixels[j,k]:=$02000000 + image1.canvas.pixels[j+100,k];
and note the difference.
--
David Ullrich
Don't you guys find it tedious typing the same thing
after your signature each time you post something?
I know I do, but when in Rome...