Gdiplus::Bitmap --> Drawing::Image

Hi,

I want to create a Drawing::Image object (managed) from a Gdiplus::Bitmap object. This was my approach:

Gdiplus::Bitmap* BMP = Gdiplus::Bitmap::FromStream((IStream*)MyStream);

HBITMAP hbmp;

BMP->GetHBITMAP(*(new Gdiplus::Color(0, 0, 0)),&hbmp);

Drawing::Image^ IMG = Drawing::Image::FromHbitmap((System::IntPtr)new IntPtr((void*)hbmp));

But unfortunately BMP->GetHBITMAP() returns 7 (Win32Error) even though it's possible to get the bitmap's image dimensions correctly. Surely the rest of the code can't work because the function call fails.

I would appreciate every comment regarding this issue,
Thanks!


Answer this question

Gdiplus::Bitmap --> Drawing::Image