Ich habe eine PNG Datei mit transparentem Hintergrund. Diese möchte ich so beim Start der EXE in der Bildschirmmitte anzeigen.
Neues Formular erzeugen, das Bild rein setzen, soweit klappt das.
Aber wie mache ich von dem Fenster den transparenten Teil der Grafik transparent?
Das ist der Code den ich bisher geschrieben habe:
Code: Alles auswählen
procedure TfrmSplash.FormCreate(Sender: TObject);
begin
frmSplash := Self;
ShapeControl(Self);
end;
procedure TfrmSplash.ShapeControl(AControl: TWinControl);
var
ABitmap: TBitmap;
x, y: Integer;
begin
ABitmap := TBitmap.Create;
ABitmap.Width := Image1.Picture.Bitmap.Width;
ABitmap.Height := Image1.Picture.Bitmap.Height;
ABitmap.Monochrome := True;
ABitmap.Canvas.Brush.Color := clBlack; // transparent color
ABitmap.Canvas.FillRect(0, 0, ABitmap.Width, ABitmap.Height);
ABitmap.Canvas.Brush.Color := clWhite;
For x := 0 To ABitmap.Width - 1 do
Begin
For y := 0 To ABitmap.Height - 1 Do
Begin
If Image1.Picture.PNG.Canvas.Pixels[x,y] <> Image1.Picture.PNG.TransparentColor Then
ABitmap.Canvas.Pixels[x,y] := clWhite;
end;
end;
//Image1.Picture.Assign(ABitmap);
AControl.SetShape(ABitmap);
ABitmap.Free;
end;
Muss ich im Formular noch was spezielles einstellen?
Oder ist der Ansatz schon mal ganz falsch?
Es sollte unter Linux und Windows funktionieren.
Dankeschön, Grüße Markus