title: GDI+ Image to HBITMAP
body: <p>I have the following code:</p>
  
  <pre><code>Image *img=Image::FromFile(currentImagePath.c_str(), false);
  
  
  Bitmap* pBitmap = static_cast&lt;Bitmap*&gt;(img/*-&gt;Clone()*/);
  HBITMAP handleToSliceRet=NULL;
  Status status = pBitmap-&gt;GetHBITMAP(Color(0,0,0), &amp;handleToSliceRet);
  </code></pre>
  
  <p>I have initialized gdi and everything, but when I try to run this, if I uncomment the /<em>->Clone()</em>/ the debugger will say Access violation reading <code>0x0000</code> and if I leave it commented, it fails on the line <code>Status status = pBitmap-&gt;GetHBITMAP(Color(0,0,0), &amp;handleToSliceRet);</code> with another access violation. I've been at this for about 6 hours now to no avail.  </p>
  
  <p>The current path of the image I'm trying to process is "C:\cube\cube0000.png"</p>