小编szp*_*ter的帖子

如何正确使用 TBitmap 对象来保存具有透明度的文件?

下面是我的示例代码:

var    lBitmap: TBitmap;
begin
    lBitmap := TBitmap.Create;
    lBitmap.PixelFormat := TPixelFormat.pf32bit;
    lBitmap.Transparent := TRUE; // !

    lBitmap.LoadFromFile( 'd:\temp\bmp32b_300dpi_transparent_400x250.bmp' ); 
    // Bitmap RGB+Alpha created with GIMP  

    // modifications on pixels

    Canvas.Draw(100, 0, lBitmap);
    // Up to this point it is correct, the drawing is painted with transparency

    lBitmap.SaveToFile( 'd:\tmp\after.bmp' ); // after this -> I have lost transparency

    lBitmap.Free;
end;
Run Code Online (Sandbox Code Playgroud)

如何正确使用 TBitmap 对象来保存具有透明度的文件?

delphi vcl bitmap delphi-10-seattle

2
推荐指数
1
解决办法
200
查看次数

标签 统计

bitmap ×1

delphi ×1

delphi-10-seattle ×1

vcl ×1