Just tried this quickly, seems to work fine on Windows 7 32-bit, and somewhat new Lazarus. It saves both BMP and PNG. There is clear difference in their file size, and both show alpha channel in Gimp too, PNG also in Windows Photo viewer and explorer.
TForm1 = class(TForm)
..
private
bmp: TBitmap;
end;
..
procedure TForm1.FormCreate(Sender: TObject);
var i, j, n: integer; data: PByte;
pic: TPicture;
begin
randomize;
bmp:=TBitmap.Create;
bmp.PixelFormat:=pf32bit;
bmp.SetSize(256, 256);
data:=bmp.RawImage.Data;
for i:=0 to 255 do
for j:=0 to 255 do begin
n:=(j*256+i)*4;
data[n+0]:=0; // B
data[n+1]:=255; // G
data[n+2]:=0; // R
data[n+3]:=i*2 mod 256; // A
end;
bmp.SaveToFile('tmp.bmp');
pic:=TPicture.Create;
pic.Assign(bmp);
pic.SaveToFile('tmp.png');
pic.Free;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
bmp.Free;
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
canvas.Clear;
canvas.Draw(0, 0, bmp);
end;