BMP

BMP Format Explained — Structure and Uses of Windows Bitmap Files

BMP explained: the Windows bitmap file header, info header, color table and pixel array, why files are huge, bottom-up rows, padding and uses today.

Extension.bmp (.dib)
MIMEimage/bmp
SpecificationMicrosoft documentation (no official international standard)
CompressionMostly uncompressed (RLE optional)
TransparencyLimited (alpha defined in 32-bit V4/V5 headers)
AnimationNo
Color depth1, 4, 8, 16, 24 or 32 bits per pixel

BMP is a format for saving the device-independent bitmaps (DIB) used in Microsoft Windows and OS/2 as files. It isn't a specification set by an international standards body; Microsoft's developer documentation serves as the de facto specification. Its defining feature is a simple structure that any program can easily read and write.

File structure

According to the Microsoft Learn "Bitmap Storage" documentation, a BMP file consists of the following, in order.

OrderComponentContents
1BITMAPFILEHEADERFile identifier (BM), file size, offset to the pixel data
2BITMAPINFOHEADER (or V4/V5 header)Width and height in pixels, bits per pixel, compression method, resolution
3Color table (RGBQUAD array)Used by 1-, 4- and 8-bit images with a palette
4Pixel arrayThe actual image data

Because the first two bytes of the file are ASCII BM (hex 42 4D), this signature confirms a BMP even if the extension has been changed. The info header also has a field for print resolution (pixels per meter).

Stored from bottom to top

A typical BMP stores pixels from the bottom row to the top row (bottom-up). If the height value in the header is negative, the image is stored top to bottom (top-down). In addition, padding bytes are added to the end of each row so its byte count is a multiple of 4. These are common pitfalls when writing a program that parses BMP directly.

Row size calculation example

Each BMP row must be aligned to 4 bytes. If a 24-bit image is 101 pixels wide, one row holds 101 × 3 = 303 bytes of actual data, and 1 padding byte is added to store it as 304 bytes, a multiple of 4. So the total pixel data size is (bytes per row) × height in pixels, and adding the header (usually 54 bytes) gives the file size. Because of this rule, images whose width isn't a multiple of 4 often show a skewed, row-shifted error when handled by hand.

Why files are large

BMP usually stores raw pixels uncompressed. A 24-bit BMP uses 3 bytes per pixel, so a 1920×1080 image is about 6.2MB and a 4032×3024 smartphone photo about 36.6MB. RLE (run-length encoding) compression is available for palette images of 8 bits or less, but it does little for photos. MDN also recommends avoiding BMP for web content because of its size.

Transparency

Traditional 24-bit BMP has no alpha channel. A 32-bit BMP using a V4/V5 header can define an alpha mask, but many programs don't interpret it as transparency properly, so PNG is the safer choice for exchanging transparent images.

When BMP is still used

  • Older industrial equipment, embedded devices, receipt printers and some in-house programs that accept only BMP
  • Simple programs or learning examples that need to handle pixels directly, without compression and decompression
  • The way small images are stored inside Windows icons (ICO)

Things to watch when converting

  • BMP → PNG: Lossless and much smaller. The best conversion for storage and sharing.
  • BMP → JPG: For photos, the file becomes tens of times smaller, but lossy compression is applied.
  • Other formats → BMP: Check the bit depth your device requires (24-bit or 8-bit). Transparent areas are filled with the background color. You can save as BMP with the image converter.

Last updated: 2026-09-23

Sources

← Back to formats