2

I have a gdi+ bitmap, and I want to convert bitmap into HBitmap. I write the following code.

    HBITMAP temp;
    Color color;
    img->GetHBITMAP(color, &temp);

But It do not work, How can I get a HBitmap?

user25749
  • 4,825
  • 14
  • 61
  • 83

2 Answers2

0

Check the return value of the GetHBITMAP function.

arul
  • 13,998
  • 1
  • 57
  • 77
0

Demonstration code from MSDN:

void DemonstrateGetHbitmapWithColor()
{
   Bitmap^ bm = gcnew Bitmap( "Picture.jpg" );
   IntPtr hBitmap = bm->GetHbitmap( Color::Blue );

   // Do something with hBitmap.
   DeleteObject( hBitmap );
}
schnaader
  • 49,103
  • 10
  • 104
  • 136