把 TBitMap 里的
Transparent := true
TransparentMode := tmFixed;
TransparentColor 设成该颜色
如果图像的左下角的颜色就是透明色,那么可以
TransparentMode := tmAuto; 自动,不用设 TransparentColor
procedure TForm1.Button1Click(Sender: TObject);
var
Bitmap : TBitMap;
begin
Bitmap := TBitmap.Create;
try
with Bitmap do begin
LoadFromFile('MyBitmap.png');
Transparent := True;
TransParentColor := BitMap.Canvas.Brush.Color;
Form1.Canvas.Draw(0,0,BitMap);
TransparentMode := tmAuto;
Form1.Canvas.Draw(50,50,BitMap);
end;
finally
Bitmap.Free;
end;
end;