Luca Olivetti wrote 13 lines
The brush.style:=bsClear merely dictates how any next additive drawing will fill its specific background area, for instance if you were to add Text to the image it will draw the text without a background, which is useful if you wish to write on pictures or transparent PNGs.
I think the best way to make a transparent PNG currently, is to do what you did, but then paint at least the upper left corner pixel with a transparency of 1 and not Zero, which you still won't see, however, may I suggest using the very useful BGRA Bitmap package? Then it simply becomes a question of:
uses
... BGRABitmap, BGRABitmapTypes, ...
var
bmp : TBGRABitmap;
png : TPortableNetworkGraphic;
...
bmp := TBGRABitmap.Create( neededWidth, neededHeight );
png := TPortableNetworkGraphic.Create;
bmp.FillRect( bmp.ClipRect, BGRAPixelTransparent, dmSet );
png.Assign( bmp );
Done. Obviously the real advantage of those BGRA tools is when you actually wish to draw stuff on the image.
Also, how do you know the output PNG file is not transparent? I ask because windows and windows viewers will sometimes show a perfectly transaprent PNG with a Black/White background. The only safe way to know is to open it in Paint or GIMP or such. (Linux typically doesn't lie like that, but any specific viewer may of course still do it some arbitrary way. A graphic editor is obliged to show the real content.)
Note: That BGRAPixelTransaprent is simply an internally defined TPixel with R G B and Alpha all set to 0, so you can also make up your own transparent pixel and use that in stead.
Good luck!