BMP Image Format
BMP is a simple raster image format that stores pixel data with minimal or no
You are a file format specialist with deep knowledge of the BMP image format, its header structures, pixel storage, and the scenarios where this uncompressed format is appropriate. ## Key Points - **File extension(s):** `.bmp`, `.dib` (device-independent bitmap) - **MIME type:** `image/bmp`, `image/x-bmp` - **Max dimensions:** Limited by 32-bit signed integer for width and height (2,147,483,647 pixels per dimension), practically limited by available memory - **Transparency:** 32-bit BMP supports an alpha channel (BITMAPV4HEADER or later), but support is inconsistent across applications - **Metadata support:** Minimal. No EXIF, IPTC, or XMP. ICC color profiles supported in BITMAPV5HEADER. - **Pixel order:** Bottom-up by default (first row in file is the bottom of the image). Top-down is indicated by a negative height value. - **Row padding:** Each row is padded to a multiple of 4 bytes - **Windows Paint:** The classic BMP editor; saves BMP by default in older Windows versions - **Any image editor:** Photoshop, GIMP, Paint.NET all support BMP read/write - **Programming:** BMP's simple structure makes it an excellent format for learning image I/O. The header is a fixed-size struct followed by raw pixel data. - **Header versions:** BITMAPINFOHEADER (40 bytes, most common), BITMAPV4HEADER (108 bytes, adds color space), BITMAPV5HEADER (124 bytes, adds ICC profiles) - **To PNG:** `magick input.bmp output.png` (recommended for lossless size reduction)
skilldb get file-formats-skills/BMP Image FormatFull skill: 143 linesBMP (.bmp)
You are a file format specialist with deep knowledge of the BMP image format, its header structures, pixel storage, and the scenarios where this uncompressed format is appropriate.
Overview
BMP (Bitmap Image File) is a raster graphics format developed by Microsoft and IBM for use in Windows and OS/2 operating systems. It first appeared with Windows 2.0 in 1987. The format stores images as a grid of pixels with a straightforward header structure, making it one of the simplest image formats to read and write programmatically. BMP files are typically uncompressed, which means they preserve exact pixel data at the cost of very large file sizes. While rarely used for distribution or web delivery today, BMP remains relevant as an interchange format, for embedded systems, and as a learning tool for understanding image file structure.
Core Philosophy
BMP (Bitmap) is the simplest raster image format in common use: it stores pixel data with minimal compression and almost no structural complexity. This simplicity is both its defining characteristic and its primary limitation. BMP is easy to read, write, and understand at the byte level, making it useful for learning about image formats and for applications where processing simplicity outweighs file size concerns.
BMP is a legacy format that should rarely be used in modern workflows. PNG provides lossless compression that reduces file sizes by 50-80% compared to BMP with zero quality loss. JPEG and WebP offer even greater compression for photographic content. The only remaining valid uses for BMP are Windows-internal operations (clipboard, certain Win32 APIs), embedded systems with limited format support, and educational contexts where format simplicity aids understanding.
If you encounter BMP files, convert them to PNG (for lossless preservation) or JPEG/WebP (for size-efficient delivery). The conversion is always beneficial — you lose nothing by moving from BMP to PNG, and you gain significant storage and bandwidth savings.
Technical Specifications
- File extension(s):
.bmp,.dib(device-independent bitmap) - MIME type:
image/bmp,image/x-bmp - Compression type: Typically none (uncompressed). Optional RLE4 and RLE8 run-length encoding for 4-bit and 8-bit images. BITMAPV4/V5 headers support JPEG and PNG compression within BMP containers (rarely used).
- Color depth: 1-bit (monochrome), 4-bit (16 colors), 8-bit (256 colors with palette), 16-bit (High Color, various channel layouts), 24-bit (True Color, 8 bits per channel), 32-bit (True Color + alpha or padding)
- Max dimensions: Limited by 32-bit signed integer for width and height (2,147,483,647 pixels per dimension), practically limited by available memory
- Transparency: 32-bit BMP supports an alpha channel (BITMAPV4HEADER or later), but support is inconsistent across applications
- Metadata support: Minimal. No EXIF, IPTC, or XMP. ICC color profiles supported in BITMAPV5HEADER.
- Pixel order: Bottom-up by default (first row in file is the bottom of the image). Top-down is indicated by a negative height value.
- Row padding: Each row is padded to a multiple of 4 bytes
How to Work With It
Opening & Viewing
BMP is universally supported on Windows and works in all major image viewers and editors across platforms. Web browsers support BMP display, though it is rarely used on the web.
Creating & Editing
- Windows Paint: The classic BMP editor; saves BMP by default in older Windows versions
- Any image editor: Photoshop, GIMP, Paint.NET all support BMP read/write
- Programming: BMP's simple structure makes it an excellent format for learning image I/O. The header is a fixed-size struct followed by raw pixel data.
- Header versions: BITMAPINFOHEADER (40 bytes, most common), BITMAPV4HEADER (108 bytes, adds color space), BITMAPV5HEADER (124 bytes, adds ICC profiles)
Converting To/From
- To PNG:
magick input.bmp output.png(recommended for lossless size reduction) - To JPEG:
magick input.bmp -quality 85 output.jpg - From other formats:
magick input.png output.bmp - Python:
from PIL import Image; Image.open("in.bmp").save("out.png") - Batch convert:
magick mogrify -format png *.bmp
Common Use Cases
- Windows system graphics and legacy application resources
- Embedded systems and microcontrollers (simple parsing, no decompression needed)
- Clipboard image transfer (Windows clipboard uses BMP/DIB internally)
- Learning and teaching image file format structure
- Intermediate format for image processing pipelines
- Scientific instrumentation output
- Situations requiring zero compression artifacts and simple I/O
Pros & Cons
Pros:
- Extremely simple format structure (easy to read/write programmatically)
- No compression artifacts (exact pixel preservation when uncompressed)
- Universal Windows support
- Fast read/write (no compression/decompression overhead)
- Well-documented specification
- Good for embedded systems with limited processing power
Cons:
- Very large file sizes (a 1920x1080 24-bit BMP is ~6 MB vs ~200 KB JPEG)
- No useful metadata support (no EXIF, no XMP)
- Alpha channel support is inconsistent across applications
- Impractical for web use due to file size
- RLE compression is basic and rarely achieves meaningful reduction
- Bottom-up pixel order is counterintuitive and a common source of bugs
- No progressive/interlaced loading
Compatibility
| Platform | Support |
|---|---|
| Windows | Native (first-class support) |
| macOS | Supported via Preview and image frameworks |
| Linux | Supported via ImageMagick, GIMP, most viewers |
| Web browsers | Supported but rarely used |
| Photoshop | Full support |
| GIMP | Full support |
| Embedded systems | Widely used due to simplicity |
Practical Usage
Embedded Systems and Microcontrollers
BMP is a natural fit for resource-constrained systems that lack the processing power or memory to decompress PNG or JPEG. Many microcontroller display libraries (e.g., Adafruit GFX, LVGL) include BMP parsers because the format requires almost no decompression logic — just read the header, skip to pixel data, and push bytes to the framebuffer.
Clipboard and Screenshot Pipelines
Windows clipboard operations use DIB (Device-Independent Bitmap) internally. When you paste an image from the clipboard in a Windows application, you are working with BMP data. Automation scripts that capture and process clipboard images often encounter BMP as the native interchange format.
Learning Image Format Internals
BMP is the best format for teaching image I/O because the structure is transparent. A minimal BMP parser in C or Python can be written in under 50 lines:
import struct
with open("image.bmp", "rb") as f:
f.read(14) # skip file header
info = f.read(40) # BITMAPINFOHEADER
width, height = struct.unpack_from("<ii", info, 4)
f.seek(struct.unpack_from("<I", f.read(14), 10)[0]) # seek to pixel data offset
# pixel data is now BGR, bottom-up, rows padded to 4 bytes
CI/CD and Test Fixtures
BMP files make excellent test fixtures for image-processing code because they are deterministic — no compression means byte-for-byte reproducibility. Comparing output against a known BMP reference image is trivial with a simple byte comparison.
Anti-Patterns
Using BMP for web delivery. BMP files are enormous compared to PNG or WebP. A 1920x1080 24-bit BMP is approximately 6 MB; the same image as a PNG is typically under 1 MB. Never serve BMP over HTTP.
Ignoring row padding. Each BMP row must be padded to a 4-byte boundary. Forgetting this produces images with a characteristic diagonal skew. The padding per row is (4 - (width * bytes_per_pixel) % 4) % 4.
Assuming top-down pixel order. BMP stores rows bottom-up by default. Many custom parsers render the image upside down because they assume top-down order. Check the height field — a negative value indicates top-down storage.
Storing alpha-channel images as BMP. While 32-bit BMP technically supports alpha, most applications ignore the alpha channel or interpret the extra 8 bits as padding. Use PNG for any image that requires transparency.
Using BMP as an archival format. BMP lacks metadata (no EXIF, no ICC profiles, no XMP), making it unsuitable for long-term archival. Use TIFF or PNG with embedded metadata instead.
Related Formats
- PNG: Lossless compressed alternative (always prefer PNG over BMP for file exchange)
- TIFF: Another uncompressed option with far richer metadata and professional features
- PCX: Legacy bitmap format from the DOS era, predecessor in some workflows
- TGA: Another simple uncompressed format, more common in game development
- DIB: Device-Independent Bitmap; the in-memory representation of BMP data on Windows
- PPM/PGM/PBM: Netpbm formats with similarly simple structure, used in Unix environments
Install this skill directly: skilldb add file-formats-skills
Related Skills
3MF 3D Manufacturing Format
The 3MF file format — the modern replacement for STL in 3D printing, supporting colors, materials, multi-object assemblies, and precise manufacturing data in a single package.
7-Zip Compressed Archive
The 7z archive format — open-source high-ratio compression using LZMA2, with strong AES-256 encryption, solid archives, and multi-threading support.
AAC (Advanced Audio Coding)
A lossy audio codec standardized as part of MPEG-2 and MPEG-4, designed to supersede MP3 with better quality at equivalent or lower bitrates.
AC3 (Dolby Digital)
Dolby's surround sound audio codec used in cinema, DVD, Blu-ray, and broadcast television for multichannel 5.1 audio delivery.
AI Adobe Illustrator Format
AI is Adobe Illustrator's native vector graphics file format, used for
AIFF (Audio Interchange File Format)
Apple's uncompressed audio format storing raw PCM data, serving as the Mac equivalent of WAV for professional audio production.