0

I have HBITMAP hBitmap. I use GetBitmapBits(hbitmap, width * height, buffer);

what is the pixel format written in buffer?

Thanks.

Hayri Uğur Koltuk
  • 2,970
  • 4
  • 31
  • 60

2 Answers2

3

Can be different, it depends on the bitmap. Here’s a code to find out:

BITMAP bmp;
if( 0 == GetObject( hbitmap, sizeof( BITMAP ), &bmp ) ) // handle error

From that BITMAP structure you can find out pixel format and other important things about memory layout. For example, here’s a formula for the required buffer size: bmp.bmWidthBytes * bmp.bmHeight

Soonts
  • 20,079
  • 9
  • 57
  • 130
3

You want to use GetDIBits instead.

Check out what MSDN says about it: GetDIBits

Always ask MSDN (if using Visual Studio)

noelicus
  • 14,468
  • 3
  • 92
  • 111