Thanks for replies but proposed solutions are not complete as the black color (colBlack) for some reason will be transparent in saved png:
// version 5 - not working because black will be transparent
img := TLazIntfImage.Create(100, 100, [riqfRGB, riqfAlpha]);
img.CreateData;
img.FillPixels(colRed);
img.Colors[10, 10] := colGreen;
img.Colors[11, 10] := colTransparent;
img.Colors[12, 10] := colBlack; // this will be transparent
png := TPortableNetworkGraphic.Create;
png.LoadFromIntfImage(img);
png.SaveToFile('v5.png');
// version 6 - UseAlpha:=true, not working because black will be transparent
img := TLazIntfImage.Create(100, 100, [riqfRGB, riqfAlpha]);
img.CreateData;
img.FillPixels(colRed);
img.Colors[10, 10] := colGreen;
img.Colors[11, 10] := colTransparent;
img.Colors[12, 10] := colBlack; // this will be transparent
pngWriter := TLazWriterPNG.create;
pngWriter.UseAlpha := true; // <----- needed to get an alpha channel
img.SaveToFile('v6.png', pngWriter);
pngWriter.Free;
// version 7 - workaround using almost black, works, but well, it's not black color
img := TLazIntfImage.Create(100, 100, [riqfRGB, riqfAlpha]);
img.CreateData;
img.FillPixels(colRed);
img.Colors[10, 10] := colGreen;
img.Colors[11, 10] := colTransparent;
img.Colors[12, 12] := FPColor(0,0,0,$FFFF); // this is real black, will be transparent
img.Colors[13, 13] := FPColor(1,1,1,$FFFF); // this is almost black, will be transparent, because FPColor use 16 bit per channel, but png only 8, so $0001 is reduced to $00
img.Colors[14, 14] := FPColor($00FF,$00FF,$00FF,$FFFF); // this is almost black, will be transparent, because FPColor use 16 bit per channel, but png only 8, so $00FF is reduced to $00
img.Colors[15, 15] := FPColor($0100,$0100,$0100,$FFFF); // this is almost black, will be almost black, $01FF will be reduced to $01 which will become RGB(1,1,1)
pngWriter := TLazWriterPNG.create;
pngWriter.UseAlpha := true;
img.SaveToFile('v7.png', pngWriter);
pngWriter.Free;
Any ideas on how to make it work with black color too?