Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bitmap file header size

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!!

like image 622
user1657743 Avatar asked Sep 09 '12 06:09

user1657743


People also ask

What is the header of a bitmap image?

DIB header (bitmap information header) This block of bytes tells the application detailed information about the image, which will be used to display the image on the screen. The block also matches the header used internally by Windows and OS/2 and has several different variants.

What is the size of a bitmap image?

A bitmap is rectangular and has a spatial dimension, which is the width and height of the image in pixels. For example, this grid could represent a very small bitmap that is 9 pixels wide and 6 pixels high or, more concisely, 9 by 6: By convention, the shorthand dimension of a bitmap is given with the width first.

What is the file header signature for a bitmap file?

BMP (bitmap image) files start with a signature BM and the next 4 bytes contain file's length. we can see that it starts with a signature BM and next 4 bytes (hex: F6 04 00 00).

Does bitmap have a large file size?

Both the BMP format and the TIFF format are limited to a maximum file size of 4 GBytes.


1 Answers

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.

like image 59
nneonneo Avatar answered Sep 20 '22 06:09

nneonneo