title: Is there a way to save a PNG from bitmap with transparency GDI+
body: <p>Im trying to get and icon from and exe and save it as png with transparency.
  i've been able to get the bitmap from it with gdi+ and save the .bmp with the correct alpha channel(checked in Photoshop).
  but now the problem is that when i want to save it as .png, the transparency will not transfer to the file (transpaernt areas are black)
  here's my code:</p>
  <pre><code>using namespace Gdiplus;
  
  SHFILEINFO sfi;
  IImageList* piml;
  HICON hicon;
  
  // Getting the largest icon from FILEPATH(*.exe)
  SHGetFileInfo(FILEPATH, 0, &amp;sfi, sizeof(sfi), SHGFI_SYSICONINDEX);
  SHGetImageList(SHIL_JUMBO, IID_IImageList, (void**)&amp;piml);
  piml-&gt;GetIcon(sfi.iIcon, 0x00000001, &amp;hicon);
  
  // Getting the HBITMAP from it
  ICONINFO iconinfo;
  GetIconInfo(hicon, &amp;iconinfo);
  
  //GDI+
  GdiplusStartupInput gdiplusStartupInput;
  ULONG_PTR gdiplusToken;
  GdiplusStartup(&amp;gdiplusToken, &amp;gdiplusStartupInput, NULL);
  
  //Creating nessecery palettes for gdi, so i can use Bitmap::FromHBITMAP
  PALETTEENTRY pat = { 255,255,255,0 };
  LOGPALETTE logpalt = { 0, 1, pat };
  HPALETTE hand = CreatePalette(&amp;logpalt);
  
  Bitmap* h = Bitmap::FromHBITMAP(iconinfo.hbmColor, hand);
  
  //Getting image encoders for saving
  UINT num, sz;
  GetImageEncodersSize(&amp;num, &amp;sz);
  ImageCodecInfo* inf = new ImageCodecInfo[sz];
  GetImageEncoders(num, sz, inf);
  //4 -&gt; png ; 0 -&gt; bitmap
  CLSID encoderClsid = inf[4].Clsid;
  h-&gt;Save(L&quot;PATH_TO_SAVE&quot;, &amp;encoderClsid, NULL);
  GdiplusShutdown(gdiplusToken);
  </code></pre>