unit testform;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, JPEG;
type
TForm3 =
class(TForm)
Image1: TImage;
Button2: TButton;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form3: TForm3;
implementation
uses
main;
var
PicCount: Integer;
{$R *.dfm}
//JPGs in Bitmaps umwandeln
procedure JpegToBmp(
const Filename:
String);
var
jpeg: TJPEGImage;
bmp: TBitmap;
begin
jpeg:=TJPEGImage.Create;
try
jpeg.LoadFromFile(Filename);
bmp:=TBitmap.Create;
try
bmp.Assign(jpeg);
bmp.SaveToFile(ExtractFilePath(Application.ExeName)+'
TempImage.bmp');
finally
bmp.free;
end;
finally
jpeg.free;
end;
end;
//JpegToBmp(D:\Eigene Dateien\Eigene Bilder\zunge.jpg);
type
PRGBTripleArray = ^TRGBTripleArray;
TRGBTripleArray =
array[0..32767]
of TRGBTriple;
procedure FadeIn(ImageFileName: TFileName);
var
left, top: integer;
Bitmap, BaseBitmap: TBitmap;
Row, BaseRow: PRGBTripleArray;
x, y, step: integer;
begin
// Bitmaps vorbereiten / Preparing the Bitmap //
Bitmap := TBitmap.Create;
try
Bitmap.PixelFormat := pf32bit;
// oder pf24bit / or pf24bit //
Bitmap.LoadFromFile(ImageFileName);
BaseBitmap := TBitmap.Create;
try
BaseBitmap.PixelFormat := pf32bit;
BaseBitmap.Assign(Bitmap);
// Fading //
for step := 0
to 32
do
begin
for y := 0
to (Bitmap.Height - 1)
do
begin
BaseRow := BaseBitmap.Scanline[y];
// Farben vom Endbild holen / Getting colors from final image //
Row := Bitmap.Scanline[y];
// Farben vom aktuellen Bild / Colors from the image as it is now //
for x := 0
to (Bitmap.Width - 1)
do
begin
Row[x].rgbtRed := (step * BaseRow[x].rgbtRed)
shr 5;
Row[x].rgbtGreen := (step * BaseRow[x].rgbtGreen)
shr 5;
// Fading //
Row[x].rgbtBlue := (step * BaseRow[x].rgbtBlue)
shr 5;
end;
end;
left := (Screen.WorkAreaWidth
div 2) - (Bitmap.Width
div 2);
top := (Screen.WorkAreaHeight
div 2) - (Bitmap.Height
div 2);
Form3.Canvas.Draw(left, top, Bitmap);
// neues Bild ausgeben / Output new image //
InvalidateRect(Form3.Handle,
nil, False);
// Fenster neu zeichnen / Redraw window //
RedrawWindow(Form3.Handle,
nil, 0, RDW_UPDATENOW);
end;
finally
BaseBitmap.Free;
end;
finally
Bitmap.Free;
end;
end;
/////////////////////////////////////////////////
// Fade Out //
/////////////////////////////////////////////////
procedure FadeOut(ImageFileName: TFileName);
var
left, top: integer;
Bitmap, BaseBitmap: TBitmap;
Row, BaseRow: PRGBTripleArray;
x, y, step: integer;
begin
// Bitmaps vorbereiten / Preparing the Bitmap //
Bitmap := TBitmap.Create;
try
Bitmap.PixelFormat := pf32bit;
// oder pf24bit / or pf24bit //
Bitmap.LoadFromFile(ImageFileName);
BaseBitmap := TBitmap.Create;
try
BaseBitmap.PixelFormat := pf32bit;
BaseBitmap.Assign(Bitmap);
// Fading //
for step := 32
downto 0
do
begin
for y := 0
to (Bitmap.Height - 1)
do
begin
BaseRow := BaseBitmap.Scanline[y];
// Farben vom Endbild holen / Getting colors from final image //
Row := Bitmap.Scanline[y];
// Farben vom aktuellen Bild / Colors from the image as it is now //
for x := 0
to (Bitmap.Width - 1)
do
begin
left := (Screen.WorkAreaWidth
div 2) - (Bitmap.Width
div 2);
top := (Screen.WorkAreaHeight
div 2) - (Bitmap.Height
div 2);
Row[x].rgbtRed := (step * BaseRow[x].rgbtRed)
shr 8;
Row[x].rgbtGreen := (step * BaseRow[x].rgbtGreen)
shr 8;
// Fading //
Row[x].rgbtBlue := (step * BaseRow[x].rgbtBlue)
shr 8;
end;
end;
Form3.Canvas.Draw(left, top, Bitmap);
// neues Bild ausgeben / Output new image //
InvalidateRect(Form3.Handle,
nil, False);
// Fenster neu zeichnen / Redraw window //
RedrawWindow(Form3.Handle,
nil, 0, RDW_UPDATENOW);
end;
finally
BaseBitmap.Free;
end;
finally
Bitmap.Free;
end;
end;
procedure TForm3.Button2Click(Sender: TObject);
begin
Form3.Timer1.Enabled := False;
form3.Close;
end;
procedure TForm3.FormCreate(Sender: TObject);
begin
PicCount := 0;
//Fullscreen erstellen
self.Width := Screen.Width;
self.Height := Screen.Height;
//Bild zentrieren
Image1.Left:= (Screen.Width - Image1.Width)
div 2;
FadeIn(ExtractFilePath(Application.ExeName)+'
TempImage.bmp');
end;
procedure TForm3.Timer1Timer(Sender: TObject);
begin
if PicCount >= Form1.Memo1.Lines.Count-1
then
PicCount := 0
else
Inc(PicCount);
sleep(1000);
Fadeout(ExtractFilePath(Application.ExeName)+'
TempImage.bmp');
sleep(1000);
JpegToBmp(Form1.Edit1.Text + Form1.Memo1.Lines[PicCount]);
sleep(1000);
FadeIn(ExtractFilePath(Application.ExeName)+'
TempImage.bmp');
end;
end.