Bitmap file header size

▼魔方 西西 提交于 2020-01-12 14:03:44

问题


I'm a newbie in programming bmp files and i checked this web site to learn about bmp header.. http://www.daubnet.com/en/file-format-bmp

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

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

but 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 please?

thanks a lot!!


回答1:


Lines in BMPs are padded out to multiples of 4 bytes.

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



来源:https://stackoverflow.com/questions/12336994/bitmap-file-header-size

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!