Board index » delphi » Strange thing happen with TCanvas

Strange thing happen with TCanvas

Ok...here is my problem

I have 2 TImage components and load one (call it the source) with a 256
color bitmap.  And everything looks fine.

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
half was distored again with only 10 or 20 colors.

I have tried the program out on 4 computers and got the same result on 3
of them.  2 of the computers had ATI Wonder XL with 1MB memory video cards
and 1 had a Trident 8900 512K memory (all 3 of which gave the distorted
images).  The only 1 of the 4 that worked was some local bus video card (I
forget what exactly it was).  Oh ya....I also tried it on a IBM notebook
with SVGA and it didn't work there either.

Is it a matter a problem with these older video cards or something else.

Thanks for the help.

Stephen McGann    smcg...@gpu.srv.ualberta.ca

 

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...

Other Threads