I use Delphi 10.3.3 VCL.
I want to load a PNG image, convert to TBitmap (in order to make some modifications), then save it as PNG.
I use this code, but it loses transparency. Transparent background becomes black.
var
InputPNG: TPngImage;
OutputPNG: TPngImage;
BMP: TBitmap;
begin
InputPNG := TPngImage.Create;
OutputPNG := TPngImage.Create;
BMP := TBitmap.Create;
InputPNG.LoadFromFile('C:\input.png');
BMP.Assign(InputPNG);
OutputPNG.Assign(BMP);
OutputPNG.SaveToFile('C:\output.png');
InputPNG.Free;
OutputPNG.Free;
BMP.Free;
end;
How can I modify the code and preserve PNG transparency? Any solutions with free components such as Skia4Delphi are welcome.