unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 =
class(TForm)
Image1: TImage;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Image1MouseEnter(Sender: TObject);
function Mischen(Percent : Real) : TBitmap;
procedure Timer1Timer(Sender: TObject);
private
Bitmap1 : TBitmap;
Bitmap2 : TBitmap;
Percent : Real;
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
type
TFarbe =
record
Rot : Integer;
Gruen : Integer;
Blau : Integer;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var x, y : Integer;
Farbe : TFarbe;
Arith : Integer;
begin
Timer1.Enabled:=False;
Percent:=0;
Bitmap1:=TBitmap.Create();
Bitmap1.LoadFromFile(ExtractFilePath(Application.ExeName) + '
Floppy.bmp');
Bitmap2:=TBitmap.Create();
Bitmap2.LoadFromFile(ExtractFilePath(Application.ExeName) + '
Floppy.bmp');
for x:=0
to Bitmap1.Width
do
begin
for y:=0
to Bitmap1.Height
do
begin
with Farbe
do
begin
Rot:=GetRValue(Bitmap1.Canvas.Pixels[x, y]);
Gruen:=GetGValue(Bitmap1.Canvas.Pixels[x, y]);
Blau:=GetBValue(Bitmap1.Canvas.Pixels[x, y]);
Arith:=Round((Rot + Gruen + Blau) / 3);
end;
Bitmap1.Canvas.Pixels[x, y]:=
RGB(Arith, Arith, Arith);
end;
end;
Image1.Picture.Bitmap:=Bitmap1;
Form1.DoubleBuffered:=True;
end;
procedure TForm1.Image1MouseEnter(Sender: TObject);
begin
Timer1.Enabled:=True;
end;
function TForm1.Mischen(Percent: Real) : TBitmap;
var x, y : Integer;
Farbe1 : TFarbe;
Farbe2 : TFarbe;
Farbe3 : TFarbe;
Temp : TBitmap;
begin
Temp:=TBitmap.Create();
Temp.Width:=Bitmap1.Width;
Temp.Height:=Bitmap1.Height;
for x:=0
to Bitmap1.Width
do
begin
for y:=0
to Bitmap1.Height
do
begin
with Farbe1
do
begin
Rot:=GetRValue(Bitmap1.Canvas.Pixels[x, y]);
Gruen:=GetGValue(Bitmap1.Canvas.Pixels[x, y]);
Blau:=GetBValue(Bitmap1.Canvas.Pixels[x, y]);
end;
with Farbe2
do
begin
Rot:=GetRValue(Bitmap2.Canvas.Pixels[x, y]);
Gruen:=GetGValue(Bitmap2.Canvas.Pixels[x, y]);
Blau:=GetBValue(Bitmap2.Canvas.Pixels[x, y]);
end;
with Farbe3
do
begin
Rot:=Round(Farbe1.Rot + (Farbe2.Rot - Farbe1.Rot) * Percent);
Gruen:=Round(Farbe1.Gruen + (Farbe2.Gruen - Farbe1.Gruen) * Percent);
Blau:=Round(Farbe1.Blau + (Farbe2.Blau - Farbe1.Blau) * Percent);
end;
Temp.Canvas.Pixels[x, y]:=
RGB(Farbe3.Rot, Farbe3.Gruen, Farbe3.Blau);
end;
end;
Result:=Temp;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if Percent = 1
then
begin
Timer1.Enabled:=False;
end
else
begin
Percent:=Percent + 0.2;
Image1.Picture.Graphic:=Mischen(Percent);
end;
end;
end.