unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
BGRAGraphicControl, BGRABitmap, BGRABitmapTypes, BCTypes;
type
{ TForm1 }
TForm1 = class(TForm)
BGRAGraphicControl1: TBGRAGraphicControl;
Button1: TButton;
Button2: TButton;
procedure BGRAGraphicControl1Paint(Sender: TObject);
procedure BGRAGraphicControl1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
public
end;
var
Form1: TForm1;
TheImage1: TBGRABitmap;
TheImage2: TBGRABitmap;
theBMP: TBGRABitmap;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
TheImage1:= TBGRABitmap.Create('test1.jpg');
TheImage2:= TBGRABitmap.Create('test2.jpg');
theBMP:= TBGRABitmap.Create(TheImage1.width,TheImage1.height);
BGRAGraphicControl1.width:=TheImage1.width;
BGRAGraphicControl1.height:=TheImage1.height;
theBMP.PutImage(0, 0, TheImage1, dmLinearBlend );
theBMP.PutImage(0, 0, TheImage2, dmLinearBlend ); //dmLinearBlend
BGRAGraphicControl1.Bitmap.Assign(theBMP);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
theBMP.SaveToFile('test.png');
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
TheImage1.Free;
TheImage2.Free;
theBMP.Free;
end;
procedure TForm1.BGRAGraphicControl1Paint(Sender: TObject);
begin
if assigned(TheImage1) then
begin
TheImage1.Draw(Canvas,0,0,false); //true makes it opaque - false makes transparent
end;
if assigned(TheImage2) then
begin
TheImage2.Draw(Canvas,0,0,false); //true makes it opaque - false makes transparent
end;
if assigned(theBMP) then
begin
theBMP.Draw(Canvas,0,0,false); //true makes it opaque - false makes transparent
end;
end;
end.