What is BMP (Bitmap)?

BMP (Bitmap) is the most straightforward image file format developed by Microsoft and IBM. This file format is widely used, especially on Windows and OS/2 platforms.

BMP (Bitmap) Format Definition

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.

BMP File Header

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.

  1. The signature indicates it is a two-character BMP file.
  2. Hexadecimal BM, 424D indicates that this is an OS/2 bitmap or CI. The IC suggests that it’s an OS/2 color icon, or CP is an OS/2 color pointer, the IC is an OS/2 icon, or PT indicates it’s an OS/2 pointer.
  3. It has a reserved space of 4 bytes.
  4. It has an image offset of 4 bytes. This adjusts the location of the image information relative to the beginning of the file.

BMP Information Header

The information header contains information about the image, especially its size and colors. The size of the information header in bytes is 4.

Also, 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, i.e., 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.

One pixel for RLE means 8 bits per encoding, 2 pixels for RLE, 4 bits per encoding, and 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 essential colors in the palette is 4 bytes. This field can equal 0 when all colors matter.

Image Palette

The image palette is optional. When the palette is defined, it contains 4 consecutive bytes for each of the entries and includes the blue component, a green component, a red component, and a reserved field.

Image Coding

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.

Accurate 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.

Add a Comment

Your email address will not be published. Required fields are marked *