File Formats
  • Audio
  • Video
  • Images
  • 3D & CAD
  • Documents
  • Data
  • Code
  • System
Images
  • Raster
  • Vector
  • Camera raw
  • Layered projects
  • HDR & scientific
  • Icons
  • Retro
  1. Home
  2. Images
  3. Raster
  4. BMP
  5. BM
.BMP
  • Overview
  • Windows bitmap (BM)
    • File header
    • DIB header
    • Colour spaces
    • Colour table
    • Bit masks
    • Pixel data
    • Compression
  • OS/2 bitmap array (BA)
  • OS/2 icon (IC)
  • OS/2 colour icon (CI)
  • OS/2 pointer (PT)
  • OS/2 colour pointer (CP)

.BMP

Windows bitmap (BM)

Introduction

BMP is the bitmap image format of Microsoft Windows. It stores a device independent bitmap (DIB): a header describing the image, an optional palette and the pixels, usually uncompressed. It appeared with Windows and OS/2 in the late 1980s and gained new header versions with Windows 3.0, Windows 95 and Windows 98, each adding to the one before.

Because the pixels are usually stored as they are, BMP files are large but very simple to read and write, which keeps the format common in programming, games, embedded systems and test images. The same bitmap structure, without the file header, is used on the Windows clipboard, in program resources and inside ICO icons. Files may use the extension .bmp or .dib.

This page is the ordinary bitmap, whose file starts with BM. OS/2 used the same file header for bitmap arrays, icons and pointers, with other type codes; see all the BMP variations.

Software

  • GIMP (Windows, macOS, Linux)
  • Adobe Photoshop (Windows, macOS)
  • Paint.NET (Windows)
  • Krita (Windows, macOS, Linux)
  • IrfanView (Windows)
  • XnView MP (Windows, macOS, Linux)
  • ImageMagick (Windows, macOS, Linux)
  • Photopea (web browser)
  • Preview (macOS)

Structure

A BMP file has up to five parts, in this order. Only the first two are always present, and the values in the DIB header decide which of the others follow and how the pixels are stored. All numbers are little-endian.

  1. 0File header BM, the file size and the offset of the pixels14 bytes
  2. 14DIB header size, bit count, compression and, in later versions, colour space details; its first 4 bytes give its length and so its version12 to 124 bytes
  3. …Bit masks three or four 4-byte masks, only after a 40-byte header with bit field compression12 or 16 bytes
  4. …Colour table the palette, required at 8 bits per pixel and belowup to 1024 bytes
  5. …Pixel data rows padded to 4 bytes, bottom row first, or compressed; found at the offset in the file headervaries
The parts of a BMP file, in order

How the header shapes the rest

Two fields of the DIB header, the bit count and the compression, decide what comes between the header and the pixels and how each pixel is stored:

Bit countCompressionColour tableBit masksPixel data
1BI_RGB2 coloursnone8 pixels per byte, each a palette index
4BI_RGBup to 16 coloursnone2 pixels per byte
4BI_RLE4up to 16 coloursnonerun-length encoded, 4-bit indexes
8BI_RGBup to 256 coloursnone1 byte per pixel
8BI_RLE8up to 256 coloursnonerun-length encoded, 8-bit indexes
16BI_RGBonly if biClrUsed is setfixed 5-5-52 bytes per pixel
16BI_BITFIELDSonly if biClrUsed is setred, green, blue2 bytes per pixel, split by the masks
24BI_RGBonly if biClrUsed is setnone3 bytes per pixel: blue, green, red
32BI_RGBonly if biClrUsed is setfixed 8-8-84 bytes per pixel: blue, green, red, unused
32BI_BITFIELDSonly if biClrUsed is setred, green, blue (and alpha)4 bytes per pixel, split by the masks
0BI_JPEG or BI_PNGnonenonea complete JPEG or PNG image

A BITMAPCOREHEADER file allows only the uncompressed 1, 4, 8 and 24-bit rows, and its colour table uses 3-byte entries instead of 4.

A complete file

This 2 by 2 pixel, 24-bit image is 70 bytes long. The file header is marked, then the 40-byte BITMAPINFOHEADER, then two rows of pixels, each 6 bytes padded to 8, bottom row first.

00000000  42 4D 46 00 00 00 00 00 00 00 36 00 00 00 28 00
00000010  00 00 02 00 00 00 02 00 00 00 01 00 18 00 00 00
00000020  00 00 10 00 00 00 13 0B 00 00 13 0B 00 00 00 00
00000030  00 00 00 00 00 00 FF 00 00 00 FF 00 00 00 00 00
00000040  FF FF FF FF 00 00
Blue and green on the bottom row, red and white on the top
© 2026 fileformats.org About Contact Made by Lewpen