title: copying gdi+ bitmap into directx texture
body: <p>I'm currently attempting to copy a gdi+ bitmap into a directx texture. </p>
  
  <p>I'm using DirectX9 due to Win XP restraints. The following is my code attempt:</p>
  
  <pre><code>#include &lt;gdiplus.h&gt;
  #pragma comment(lib, "Gdiplus.lib")
  
  void attemptCopy()
  {
  static IDirect3DTexture9* mTexture;
  Gdiplus::GdiplusStartupInput m_gdiplusStartupInput;
  ULONG_PTR m_gdiplusToken;
  
  Gdiplus::GdiplusStartup(&amp;m_gdiplusToken, &amp;m_gdiplusStartupInput, NULL);
  
  HDC hdc;
  PAINTSTRUCT  ps;
  UINT mWidth = 1024;
  UINT mHeight = 1024;
  
  //hdc = BeginPaint(g_engine-&gt;getWindowHandle(), &amp;ps);
  using namespace Gdiplus;
  
  Bitmap bitmap(1024, 1024, PixelFormat32bppARGB);
  Graphics graphics(&amp;bitmap);
  
  Color transparent = Color(0, 255, 255, 255);
  graphics.Clear(transparent);
  
  graphics.SetSmoothingMode(SmoothingModeAntiAlias);
  graphics.SetInterpolationMode(InterpolationModeHighQualityBicubic);
  graphics.SetTextRenderingHint(TextRenderingHintAntiAlias);
  
  FontFamily fontFamily(L"Arial");
  StringFormat strformat;
  wchar_t pszbuf[] = L"Text Designer";
  
  GraphicsPath path;
  path.AddString(pszbuf, wcslen(pszbuf), &amp;fontFamily, 
      FontStyleRegular, 48, Gdiplus::Point(10,10), &amp;strformat );
  Pen pen(Color(234,137,6), 6);
  graphics.DrawPath(&amp;pen, &amp;path);
  SolidBrush brush(Color(128,0,255));
  graphics.FillPath(&amp;brush, &amp;path);
  
  //save bitmap for comparison
  CLSID pngClsid;
  GetEncoderClsid(L"image/png", &amp;pngClsid);
  bitmap.Save(L"test_bit.png", &amp;pngClsid, NULL);
  
  D3DXCreateTexture(
      g_engine-&gt;getDevice(),
      mWidth,
      mHeight,
      1,
      0,
      //D3DFMT_A8L8,
      D3DFMT_A8R8G8B8,
      D3DPOOL_MANAGED,
      &amp;mTexture);
  
  D3DLOCKED_RECT lockedRect;
  mTexture-&gt;LockRect(0, &amp;lockedRect,0, 0);   
  
  unsigned char* TexData = (unsigned char*)lockedRect.pBits;
  
  memcpy(TexData, &amp;bitmap, sizeof(bitmap) );
  
  mTexture-&gt;UnlockRect(0);
  
  D3DXSaveTextureToFileA("test.png",D3DXIFF_PNG, mTexture, 0);
  
  //EndPaint(g_engine-&gt;getWindowHandle(), &amp;ps);
  Gdiplus::GdiplusShutdown(m_gdiplusToken);
  }
  </code></pre>
  
  <p>Basically I'm trying to attempt a memcpy of the gdiplus bitmap to the directx texture.
  The results are the following:</p>
  
  <ol>
  <li><p><code>test.png</code>(the saved directx texture)
  <a href="http://i1280.photobucket.com/albums/a500/daegon123/test_zps09f12c7f.png" rel="nofollow">http://i1280.photobucket.com/albums/a500/daegon123/test_zps09f12c7f.png</a></p></li>
  <li><p><code>test_bit.png</code>(the saved bitmap for comparison)
  <a href="http://i1280.photobucket.com/albums/a500/daegon123/test_bit_zpse8be6cd7.png" rel="nofollow">http://i1280.photobucket.com/albums/a500/daegon123/test_bit_zpse8be6cd7.png</a></p></li>
  </ol>
  
  <p>test_bit.png is returning a proper image, while the directx texture remains blank. Hence, it seems I'm just doing some incorrectly in the copy procedure.</p>
  
  <p>Any ideas on how I could get this done? </p>