Bitmap file header size

I am new to programming bmp files and I checked this website to find out about the bmp header .. http://www.daubnet.com/en/file-format-bmp

it seems that the header of the bmp file is 54 bytes.

Using Paint, I created a simple 10x10 image and I saved it in 24 bits. therefore, according to simple math, the file size should be 10 * 10 * 3 + 54 = 354 bytes.

but the hex editor and file explorer returned a size of 374 bytes.

So, I have a difference of 20 bytes, and I don't know why.

Could you tell me why?

Many thanks!

+8
file-format bmp
source share
1 answer

Lines in BMP are padded to 4 bytes.

Without padding, each row has 3 * 10 = 30 bytes. When filled, each line has 32 bytes, so the image data is 320 bytes in size. Thus, the file size is 54 + 320 = 374 bytes.

+10
source share

All Articles