views:

1069

answers:

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?

A: 

Check the return value of the GetHBITMAP function.

arul
+1  A: 

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