BMP (Bitmap) is the simplest image file format developed by Microsoft and IBM. This file format is widely used especially on Windows and OS/2 platforms.
What is the BMP File Format?
A BMP file is a bitmap file/graphic image file with pixels stored in colors as true colors or as a point table created using an indexed palette.
BMP supports RGB, Indexed Color, Grayscale, and Bitmap color modes. Thus, a bit depth of 32 bits per channel and Windows or OS/2 format can be set in an image.
For 4-bit and 8-bit images using Windows format, you can also configure RLE compression.
This image format is designed to allow us to obtain a bitmap independent of the peripheral display device. The structure of the bitmap consists of the file header, information header, palette, and image body.
The file header provides information about the file type and size as well as where the image information actually starts and consists of four parts.
The signature indicates it is a two-character BMP file.
Hexadecimal BM, 424D indicates that this is an OS/2 bitmap or CI. And the IC indicates that it’s an OS/2 color icon, or CP is an OS/2 color pointer or IC, it’s an OS/2 icon, or PT indicates it’s an OS/2 pointer.
It has a reserved space of 4 bytes.
It has an image offset of 4 bytes. This adjusts the location of the image information relative to the beginning of the file.
The information header contains information about the image, especially its size and colors. The size of the information header in bytes is 4.
The width and height of the image are 4 bytes, and the size of the plane is 2 bytes. It is the depth of the color model, ie the number of bits used to encode the color. This value can be equivalent to 1, 4, 8, 16, 24, or 32.
It includes a size of 4 bytes as a compression method. This value is 0 when the image is not compressed or 1, 2, or 3 depending on the compression type used.
1 pixel for RLE means 8 bits per encoding, 2 pixels for RLE 4 bits per encoding, 3 for bitfield encoding, meaning the color is encoded with a triple mask represented by the palette.
The total size of the picture in bytes is 4 bytes. Horizontal and vertical resolution is the number of pixels per meter 4 bytes.
The number of important colors in the palette is 4 bytes. This field can equal 0 when all colors matter.
The image palette is optional. When the palette is defined, it contains 4 consecutive bytes for each of the entries and contains the blue component, a green component, a red component, and a reserved field.
Image coding is done by writing the bits corresponding to each pixel line by line starting from the lower left pixel.
2-color images use 1 bit per pixel, i.e. one byte encodes 8 pixels. 16 color images use 4 bits per pixel, which means one byte encodes 2 pixels.
256-color images use 8 bits per pixel, and one byte is required to encode each pixel.
True color images use 24 bits per pixel, which requires 3 bytes to encode each pixel in the alternating color order for blue, green, and red.
Each line in the image contains the total number of bytes that are a multiple of 4. If this schema is not met, it must be completed with all required 0s to accommodate line information.
Hi, I'm Tolga, a computer expert with 20 years of experience. I help fix computer issues with things like hardware, systems, networks, virtualization, servers, and operating systems. Check out my website for helpful info, and feel free to ask me anything. Keep yourself in the loop about the newest technologies!