tags:

views:

21

answers:

1

HI, I am using loadImage to load an 24bit bmp file and then try to get the bmp info

 hBitmap = (HBITMAP)LoadImage(NULL, "logo.bmp", IMAGE_BITMAP, 0, 0,
                LR_LOADFROMFILE | LR_DEFAULTSIZE)
 GetObject( hBitmap, sizeof(BITMAP), &bm );

When I do the same operation with windows color display setting 32 hi color than i got the following value bmBitsPixel = 32 but if i set the windows color display to 16 than i got bmBitsPixel = 16

Can any one please explain what does it mean. I if i used the following formula to calculate the size of the bmp than the size of the bmp depends on the window color setting.

size = bmWidth * bmHeight* bmBitsPixel/8

Thanks and Regards

+1  A: 

An HBITMAP is a device-dependent bitmap: its internal representation depends on the color format of your screen.

Accordingly, if you set your display color format to 32 bits per pixel (bpp), then your bitmap will use 32 bpp. If you switch your color format to 16 bpp, the bitmap will follow and use 16 bpp.

You formula is correct, you have to take bmBitsPixel into account when computing the bitmap size.

Frédéric Hamidi