I'm working on scanning application at a low level where I'm not very comfortable already :)
Anyway, I'm trying to make sense out of numbers I'm getting.
Here we go:
Basically, I do not understand why difference between calculated 467500 and 475200 that's in BITMAPHEADER?
I also do not understand why header says it is 40 bytes but in reality it is 48? I'm just guessing it's 8 bytes for color infor? Because image is 2 color (B/W) - it uses 4 bytes per each color?
EDIT
Here is info:
I think I get it. When scanned line saved in memory it have to be in pack of 4 bytes. So, according to my calculations 1700 bits is 212.5 bytes and according to what I see - it uses 216 bytes. So, it kind of makes sense.
BITMAPINFOHEADER
really is 40 bytes in size. Keep in mind that a bitmap is represented by a BITMAPINFO
struct, not a BITMAPINFOHEADER
struct by itself. BITMAPINFO
contains an optional RGBQUAD
color palette immediately after the BITMAPINFOHEADER
struct.
1700x2200 would be 3740000 pixels, which would take up 467500 bytes as the bitmap is using 1-bit pixels, ie it is a monochrome bitmap. Your bitmap has an extra 8 bytes in between the header and pixel data, with is consistent with a monochrome bitmap as the color palette would contain 2 RGBQUAD
values. You have to take the BITMAPINFOHEADER::biBitCount
field into account, as it tells you how many bits are actually used per pixel and how the color palette is used.
The additional bytes are accounted for by each scanline being padded at the end to align on DWORD
boundaries. biSizeImage
is calculated in this situation as:
biWidth = 1700
biCount = 1
biHeight = 2200
biSizeImage = ((((((biWidth * biCount) + 31) / 32) * 32) / 8) * biHeight) = 475200