title: How to convert icon to png with alpha transparency in delphi?
body: <p>The code below will extract icon from file and convert it to png but without alpha transparency ?</p>
  
  <pre><code>var
     IconIndex : word;
     icon:TIcon;
     png:TPngImage;
     bmp:TBitmap;
  begin
    IconIndex := 0;
    icon := TIcon.Create;
    icon.Handle := ExtractAssociatedIcon(hInstance,pChar(Edit1.Text), IconIndex) ;
    bmp:= TBitmap.Create;
    bmp.LoadFromFile('blank.bmp');
    DrawIcon(bmp.Canvas.Handle, 0, 0, icon.Handle) ;
    png := TPngImage.Create();
    png.Assign(bmp);
    png.SaveToFile('icon.png');
  end;
  </code></pre>