What Is a .BMP File?

BMP image data

📂Image
🏷️.bmp
🎯image/bmp

BMP Bitmap Image (.bmp)

Overview

BMP (Bitmap) is a raster graphics image file format developed by Microsoft for storing bitmap digital images. It is one of the oldest image formats still in use today and remains widely supported across different platforms and applications. BMP files store images as a grid of individual pixels, each with specific color information.

What makes BMP distinctive today is what it does not do: in its common form it applies no compression at all. A 1920 by 1080 image at 24 bits per pixel is about 6 MB as a BMP, regardless of what the picture shows, where the same image might be 200 KB as a JPEG or 1 MB as a PNG. That simplicity is why the format survives in places where predictability matters more than size.

Technical Specifications

  • File Extensions: .bmp, .dib (device-independent bitmap, the same format)
  • MIME Type: image/bmp (also image/x-ms-bmp)
  • Category: Image
  • Magic bytes: 42 4D (BM) at offset 0
  • Developed by: Microsoft, with IBM, for OS/2 and Windows
  • Introduced: 1987 (OS/2 1.0), Windows 2.0 in 1987
  • Byte order: little-endian throughout

Identification

00000000  42 4d 36 ec 5e 00 00 00  00 00 36 00 00 00 28 00  |BM6.^.....6...(.|
00000010  00 00 80 07 00 00 38 04  00 00 01 00 18 00 00 00  |......8.........|

The BM signature, a 4-byte file size, two reserved words, and the offset to the pixel data (here 0x36 = 54, the usual value for an uncompressed 24-bit image with a 40-byte DIB header). The 28 00 00 00 that follows is the DIB header size of 40 bytes, identifying it as a BITMAPINFOHEADER, the most common header version.

Technical Details

File Structure

  • File Header (14 bytes): signature, file size, and the offset to the pixel array
  • DIB Header: Device-Independent Bitmap header with image dimensions, colour depth and compression. Several versions exist: 12 bytes (OS/2), 40 bytes (BITMAPINFOHEADER, the usual one), 108 and 124 bytes (V4 and V5, adding colour space and alpha masks)
  • Color Palette: Optional palette for indexed colour images of 8 bits or fewer
  • Pixel Data: Raw bitmap data storing individual pixel colours

Two quirks trip up anyone writing a parser. Rows are stored bottom-up by default (a positive height means the first row in the file is the bottom of the image), and every row is padded to a multiple of 4 bytes, so a 3-pixel-wide 24-bit image uses 12 bytes per row, not 9.

Color Depth Support

  • 1-bit: Monochrome (black and white)
  • 4-bit: 16 colors with palette
  • 8-bit: 256 colors with palette
  • 16-bit: High color (65,536 colors)
  • 24-bit: True color (16.7 million colors)
  • 32-bit: True color with alpha channel

Compression

  • Uncompressed (BI_RGB): the overwhelmingly common case
  • RLE: Run-length encoding for 4-bit and 8-bit images
  • Bitfields: Custom bit masks for colour channels, used for 16-bit and 32-bit images with alpha

History and Development

BMP was introduced by Microsoft in the 1980s as part of the Windows operating system. It was designed to provide a simple, uncompressed format for storing bitmap images that could be easily displayed on Windows systems. The format has evolved through several versions, with improvements in color depth support and optional compression methods.

The format is a direct serialisation of how Windows held bitmaps in memory, which is why the pixel data can be handed straight to the display driver. That design decision, made for 1980s hardware, is the reason the format is large and the reason it is trivial to read.

How to Open a BMP File

BMP is one of the few image formats that opens everywhere without installing anything:

  • Windows: Photos (double-click), Paint, and the File Explorer preview pane all open BMP natively. Paint can also convert it.
  • macOS: Preview opens it; Quick Look (Space in Finder) previews it.
  • Linux: Eye of GNOME, gThumb, feh and every GTK or Qt image viewer.
  • iPhone and Android: Photos, Google Photos and the Files app display BMP. Some messaging apps refuse to attach it because of the size.
  • Browsers: Chrome, Firefox, Edge and Safari all render BMP directly, so dragging a file into a browser tab works as a viewer.

Image Editors

  • GIMP: Free alternative with comprehensive BMP support, including the alpha-mask variants
  • Adobe Photoshop: Full support for reading and writing BMP files
  • Paint.NET: Windows-focused editor with native BMP support
  • IrfanView and XnView: Lightweight viewers and batch converters
  • Microsoft Paint: enough for cropping, resizing and saving to PNG or JPEG

How to Convert a BMP File

Converting out of BMP almost always means shrinking it. Choose the target by content:

  • Screenshots, UI, logos, anything with flat colour: PNG. Lossless, usually 5 to 10 times smaller.
  • Photographs: JPEG at quality 85 to 92, or WebP. Much smaller; slight loss that is invisible for photos.
  • For the web: WebP or AVIF.
# ImageMagick, any OS
magick image.bmp image.png
magick image.bmp -quality 90 image.jpg

# Batch: every BMP in a folder to PNG
magick mogrify -format png *.bmp

# ffmpeg also works for single images
ffmpeg -i image.bmp image.png
  • Windows: open in Paint, File, Save as, choose PNG or JPEG.
  • macOS: open in Preview, File, Export, choose the format.
  • Converting to BMP: the same tools in reverse. Use 24-bit for compatibility with old software; 32-bit only when you need the alpha channel and know the consumer reads it.

Programming Libraries

  • GDI+ and WIC: native Windows imaging
  • Pillow (Python): Image.open("file.bmp").save("file.png")
  • ImageMagick and libvips: cross-platform command-line and library use
  • OpenCV: cv2.imread and cv2.imwrite handle BMP, and it is a common capture-output format
  • stb_image (C): a single-header reader used throughout game development

Writing a BMP from scratch is a common teaching exercise precisely because it needs no compression library: a 54-byte header followed by raw pixel rows.

Common Use Cases

Where BMP still makes sense

  • Legacy Windows software that predates PNG support
  • Embedded and firmware images, boot logos and splash screens, where a decoder is too much code
  • Scientific and machine-vision capture, where no compression artefacts can be tolerated and disk is cheap
  • Game asset pipelines as an intermediate before conversion to a GPU texture format
  • Teaching: the simplest real image format to parse by hand

Where it does not

  • The web, email and messaging, where the file size is a burden with no benefit
  • Archiving photographs, where PNG gives identical quality at a fraction of the size

Example Structure

BMP File Header (14 bytes):
- Signature: "BM" (2 bytes)
- File size: (4 bytes)
- Reserved: (4 bytes)
- Data offset: (4 bytes)

DIB Header (40 bytes, BITMAPINFOHEADER):
- Header size: (4 bytes)
- Image width: (4 bytes)
- Image height: (4 bytes, negative = top-down rows)
- Color planes: (2 bytes, always 1)
- Bits per pixel: (2 bytes)
- Compression: (4 bytes)
- Image size: (4 bytes)
- X pixels per meter: (4 bytes)
- Y pixels per meter: (4 bytes)
- Colors used: (4 bytes)
- Important colors: (4 bytes)

Advantages and Disadvantages

Advantages

  • Simplicity: Straightforward format that is easy to implement
  • Quality: Uncompressed format preserves image data exactly
  • Compatibility: Opens on every platform and in every browser
  • No patents: Free from licensing restrictions

Disadvantages

  • File size: Large files due to lack of compression
  • Unsuitable for the web: supported by browsers, but wasteful to serve
  • Weak metadata: no EXIF, no colour profile in the common header versions
  • Limited transparency: alpha works only in 32-bit bitfield variants and is inconsistently honoured by older software
  • PNG: the lossless replacement; what most BMPs should become.
  • JPEG: the right target for photographs.
  • WEBP: the web-oriented replacement for both.
  • TIFF: the professional uncompressed-or-lossless format with real metadata.
  • ICO: Windows icons, which embed BMP-structured image data.

How to identify .BMP files from the bytes

BMP image data files carry a fixed byte pattern, the file signature or magic number, that identifies them regardless of the extension. This is what our detector reads.

OffsetHexASCII
042 4DBM

Check a file yourself: xxd -l 16 file.bmp on macOS and Linux, or Format-Hex file.bmp | Select-Object -First 1 in PowerShell.Full BMP signature reference

File Information

File Description

BMP image data

Category

Image

Extensions

.bmp

MIME Type

image/bmp

Related File Types

Other file types in the Image category you might also need:

Start Analyzing BMP Files Now

Use our free AI-powered tool to detect and analyze BMP image data files instantly with Google's Magika technology.

⚡Try File Detection Tool