How to fade bmp

How to fade bmp

Post by Theuns Heydenryc » Thu, 27 Jul 2000 04:00:00



Hi
I want to fade the bmp so that it displays softer in color.
It dont have to be like animation fade, like you press the button and it
slowly fade away, no I want to press the button and it must display half as
clear.
 
 
 

How to fade bmp

Post by Eric SIBER » Thu, 27 Jul 2000 04:00:00


You just need to change each pixel's color.
You extract red, green and blue from the color and do
red:=255-(255-red) div 2;
green:=...
blue:=...
And put this back on your pixel.

Using Canvas.Pixel could be very slow.
If you know you pixel resolution (pfBit), you can use scanline.

--
Eric SIBERT

http://www.multimania.com/esibert

Quote:>slowly fade away, no I want to press the button and it must display half as
>clear.


 
 
 

How to fade bmp

Post by Volker Berning » Sun, 30 Jul 2000 04:00:00



>You just need to change each pixel's color.
>You extract red, green and blue from the color and do
>red:=255-(255-red) div 2;
>green:=...
>blue:=...
>And put this back on your pixel.

The color transformation will be faster, if you built up a table
first:

var transformed : array[0..255] of Byte;

procedure prep;
var i:integer;
begin
 for i:=0 to 255 do transformed[i]:= 255-(255-i) div 2;
end;

then use

red:= transformed[red];
blue:= transformed[blue];
...

Volker Berninger