Reputation: 3020
I have HBITMAP hBitmap. I use GetBitmapBits(hbitmap, width * height, buffer);
what is the pixel format written in buffer?
Thanks.
Upvotes: 0
Views: 2780
Reputation: 21956
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
Upvotes: 3