I have a TBitmap which contains semi-transparent image with alpha channel (in this example I got it from TPngImage).
var
SourceBitmap: TBitmap;
PngImage: TPngImage;
begin
PngImage := TPngImage.Create();
SourceBitmap := TBitmap.Create();
try
PngImage.LoadFromFile('ImgSmallTransparent.png');
SourceBitmap.Assign(PngImage);
SourceBitmap.SaveToFile('TestIn.bmp');
imgSource.Picture.Assign(SourceBitmap);
finally
PngImage.Free();
SourceBitmap.Free();
end;
When I save this TBitmap to a TestIn.bmp
file and open it with any image viewer, I can see the transparency. But when I assign it to TImage, transparent pixels appear as black (TImage has Transparent = True
).
How to display TBitmap with transparency correctly on TImage?