Thank you for your example. It's much different than mine. I will test it later, because I don't have Lazarus now. But why do you think there is a memory leak when I assign png picture to an icon? It works fine. I didn't try your example yet, but you use imagelist and bitmap and I don't know if this will keep alpha channel in my pictures. That's why I used png format. I load png files and covert them to icon. If I don't use png format, the alpha channel doesn't work properly. I did try it, but it's different issue, not for this thread, so maybe I will not discuss it here.
Is there a memory leak when I assign png to icon?
var
tmpPng: TPortableNetworkGraphic;
begin
result := TIcon.Create;
//32x32
tmpPng := TPortableNetworkGraphic.Create;
tmpPng.PixelFormat := pf32bit;
tmpPng.SetSize(32, 32);
tmpPng.Canvas.Pen.Color := clRed;
tmpPng.Canvas.MoveTo(0, 0);
tmpPng.Canvas.LineTo(32, 32);
result.Assign(tmpPng); //<-- this is the memory leak?
tmpPng.Free;
I do use tmpPng.Free after that, so where is the leak?