title: Create transparent bitmap with Gdiplus in C++
body: <p>In C++, I want to create a simple transparent image with Gdiplus and save it as a png. I have the following code:</p>
  
  <pre><code>    // These variables are class members and got initialized and are used elsewhere
      BITMAPINFO bmi;
      HDC hdc;
      void* pvBits;
  
      ZeroMemory(&amp;bmi, sizeof(BITMAPINFO));
      bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
      bmi.bmiHeader.biWidth = some_width;
      bmi.bmiHeader.biHeight = some_height;
      bmi.bmiHeader.biPlanes = 1;
      bmi.bmiHeader.biBitCount = 32;
      bmi.bmiHeader.biCompression = BI_RGB;
      bmi.bmiHeader.biSizeImage = ((((bmi.bmiHeader.biWidth * bmi.bmiHeader.biBitCount) + 31) &amp; ~31) &gt;&gt; 3) * bmi.bmiHeader.biHeight;
  
      HBITMAP hBM = CreateDIBSection(hDC, &amp;bmi, DIB_RGB_COLORS, &amp;pvBits, NULL, 0x0);
      FillMemory(pvBits, bmi.bmiHeader.biSizeImage, 255);
  
      HGDIOBJ oldObj = SelectObject(hDC, hBM);
      ReleaseDC(NULL, hDC);
  
      GdiFlush();
  
      GdiPlusBitmap* bitmap = new Gdiplus::Bitmap(&amp;bmi, pvBits);
  </code></pre>
  
  <p>When I save the image to png, I can see that there is an alpha channel, but its set to 0, so nothing transparent (RGB is all set). I also tried changing the 255 to 0, but that only gives me a black image with no transpirancy. Why is the <code>Fillmemory</code> call not filling the alpha channel, or am I missing something else?</p>