Question

I am using MFC, now i have a bitmap object, obtained by using:

Gdiplus::Bitmap* bmp = Gdiplus::Bitmap::FromStream(pStream);

How to convert this bmp object into HBITMAP? I used :

HBITMAP hBitmap = NULL;
bmp->GetHBITMAP(Color::White, &hBitmap);

but it can't, hBitmap always return 0xcccccccc and notices that {unused=??? }. What can i do?

Was it helpful?

Solution

Not a direct answer but a way to load a stream into a bitmap. It doesn't need GDI+ at all.

  1. Use CImage::Load
  2. Than use the HBITMAP conversion operator

CImage is a direct slim wrapper for a HBITMAP object from the ATL.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top