The sizeof operator gives the number of bytes in the object referred to. So in your case it will be the size of a BITMAPFILEHEADER, and the read operation will read the correct number of bytes into the structure. When complete each field of the structure should be correctly aligned*.
*There are conditions where this may not be true, so beware if you have a structure containing single byte elements. You may ignore that for the moment.
For a left-shift by a single bit, yes, a multiplication by 2.
But a left-shift by n bits, in the end, is the same as a multiplication by 2 to the power of n; since original value is 1, this leads to 2 to the power of n. Or am I missing something?
"Five fruits and vegetables a day? What a joke!
Personally, after the third watermelon, I'm full."
Once you have a HBITMAP (handle to a bitmap) in Windows you can basically do everything with it.
If you want the details from the bitmap once you have it loaded you just ask windows to extract them for you
So with my handle above I can extract the header with 2 lines of code the 3rd line is just to throw the details out (it assumes you are doing a console app).
So I can load the bitmap and extract the header with 3 lines in absolute safety.
If you are messing around with the actual header etc in Windows you are doing it all wrong
The only time you might play with a BMP file header is writing a BMP in a specific format.
That is why there is no need for libraries on Windows to handle bitmaps. Now JPEGS are a little trickier it's about 20 lines of code to get windows to load one of those most of the issue the filename has to be in UNICODE. Let me know if you need to know how to do it.
You probaly meant the [LoadImageA function (winuser.h) - Win32 apps | Microsoft Docs](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadimagea) function that can load the bitmap from the file. LoadBitmap only loads the bitmap from resources.
Last Visit: 31-Dec-99 19:00 Last Update: 9-Dec-23 8:40