How BMP Image Files Store Graphics: Pixel Data, Structure, and Compatibility
Article Nov 29, 2026

How BMP Image Files Store Graphics: Pixel Data, Structure, and Compatibility

M Seemab

M Seemab

Content Creator & Editor

BMP image files store a picture as a plain grid of pixel values behind a small header, usually without compression. That makes the format simple for programs to read and write and very large on disk. BMP remains useful for legacy Windows software and programming exercises, and is rarely the right choice for storage, sharing, or websites.
The bitmap format came with early versions of Microsoft Windows and OS/2, where it served as the native way to exchange pictures between programs and the operating system. Its design favors simplicity over efficiency. Looking at how a BMP is laid out is a useful way to understand what every other raster format is trying to improve on. This guide walks through the structure, the color options, the quirks that trip up programmers, and the practical question of what to do with a BMP you have received.

Key Points

  • A BMP is a file header, an information header, an optional color table, and a raw pixel array.
  • Pixel rows are padded to multiples of four bytes and are usually stored bottom to top.
  • Common depths are 1, 4, 8, 16, 24, and 32 bits per pixel; low depths use palettes.
  • Compression is rare, so file size is predictable: width times height times bytes per pixel, plus padding.
  • Alpha transparency exists in 32-bit variants but is unreliable across programs.
  • PNG stores the same pixels losslessly in a much smaller file.
KEY TAKEAWAY
“BMP shows what an image looks like without any cleverness. Every format that came later is a different answer to the question of how to make that grid smaller.”

How a BMP File Is Laid Out

A typical BMP begins with a 14-byte file header: the letters BM, the file size, and the offset at which pixel data begins. Next comes a DIB header that describes the image. The most common version, BITMAPINFOHEADER, is 40 bytes and records width, height, color planes, bits per pixel, compression type and, optionally, resolution and palette size. Later versions add fields for color masks, alpha, and color profiles. If the image uses a palette, a color table follows. The pixel array comes last.
Section
Typical size
Contents
File header14 bytesSignature "BM", total size, offset to pixel data
DIB header40 bytes in the common versionWidth, height, bits per pixel, compression, resolution
Color table0 to 1,024 bytesPalette entries for 1-, 4- and 8-bit images
Pixel arrayMost of the fileRow-by-row pixel values, padded to 4-byte rows

Pixel Data, Row Order and Channel Order

Three details regularly surprise people who write their own BMP readers. First, each row of pixels is padded so that its length in bytes is a multiple of four, so a 3-pixel-wide 24-bit row, which needs 9 bytes, is padded to 12. Second, rows are normally stored bottom to top, meaning the first row in the file is the bottom of the picture, unless the stored height is negative. Third, color channels are stored in blue, green, red order rather than red, green, blue. A program that ignores any of these shows a flipped picture or swapped colors.

Color Depths in BMP

Bits per pixel
Colors
Notes
12Black and white, with a two-entry palette
416Palette image; optional run-length compression
8256Palette image; optional run-length compression
16ThousandsUses bit masks to define channels
24About 16.7 millionTruecolor, three bytes per pixel
32About 16.7 million plus alphaFourth byte may be alpha, but many programs ignore it
The size arithmetic is easy to check. A 1920 by 1080 image at 24 bits per pixel needs 1920 times 1080 times 3 bytes, which is about 6.2 MB, whatever the picture contains. A photograph of the same dimensions saved as JPG is usually a few hundred kilobytes, and a flat screenshot saved as PNG is often well under 2 MB.

Compression: Possible but Rarely Used

The specification does define run-length encoding for 4- and 8-bit palette images, and bit-field modes for 16- and 32-bit data. Run-length encoding stores a repeated pixel as a count and a value, which helps only when long runs of identical pixels exist. It was never widely used, support is inconsistent, and most BMP files are simply uncompressed. That is the single biggest reason BMP files are large.

Transparency and Color Management

A normal 24-bit BMP has no transparency. A 32-bit BMP can carry an alpha channel, especially with the newer header versions, but many programs treat the fourth byte as unused or apply it inconsistently, so alpha cannot be relied on. The version 5 header can embed a color profile, but few programs read it. For dependable transparency, use PNG or WebP instead.

Where BMP Is Still Used

  • Legacy Windows software: older applications and some industrial or scientific tools expect BMP files.
  • Programming and teaching: the format is simple enough to read and write with a few dozen lines of code.
  • Embedded systems: devices with little memory can display a bitmap without implementing a decompressor.
  • Windows resources: DIB data appears inside icons, cursors, and clipboard transfers.

Compatibility

BMP opens in nearly all Windows software and in most modern editors and viewers, and current browsers can display standard bitmaps. Support for unusual variants is less certain. Run-length compressed files, OS/2 headers, 16-bit bit-field layouts and version 5 color profiles may display with distorted colors or fail to open in some programs. For websites, BMP is a poor choice because the file size is large and nothing is gained over PNG.

BMP Compared With Related Formats

Format
Compared with BMP
Better when
PNGSame lossless pixels, compressed, reliable alpha, web-friendlyYou need a lossless file of reasonable size
JPGLossy and far smallerThe image is a photograph
TIFFCompression options, high bit depth, CMYK, multiple pages, metadataScanning, print or archiving
TGAAlso simple, with dependable 8-bit alphaGame and 3D pipelines
The TIFF guide shows how a flexible container extends the same basic idea of storing a pixel grid.

What to Do With a BMP You Receive

The SnapZain Image Format Converter accepts BMP as an input and lists BMP among its outputs, together with JPG, PNG, GIF, WebP, AVIF, HEIC, ICO, TIFF, and SVG, up to 20 MB per file.
  • BMP to PNG: usually the best choice. The pixels are identical, the file is far smaller, and alpha is more reliable.
  • BMP to JPG: smallest for photographs, but lossy and without transparency.
  • Image to BMP: only when a program insists on it. Converting a JPG to BMP restores no detail; it simply stores the decoded pixels uncompressed.

Reading a BMP by Hand: a Worked Example

The simplicity of the format makes it possible to check a file with nothing but a hex viewer. Suppose a 24-bit BMP is 3 pixels wide and 2 pixels high. Each pixel needs 3 bytes, so one row needs 9 bytes, which is padded to 12 to reach a multiple of four. Two rows therefore take 24 bytes. Add the 14-byte file header and the 40-byte information header, and the file should be 78 bytes long. If a file of that size does not report 78 bytes, something has been added or truncated.
Measure
Value in the example
Pixels per row3
Bytes per row before padding9
Bytes per row after padding12
Pixel array size24 bytes
Headers14 + 40 = 54 bytes
Expected file size78 bytes
The same arithmetic scales to real images and explains why BMP sizes are so predictable.

Common BMP Mistakes

  • Uploading BMPs to websites: convert to PNG, JPG, or WebP.
  • Expecting transparency from a 24-bit file: it has none.
  • Misreading a flipped or color-swapped picture as corruption: the viewer may mishandle row or channel order.
  • Archiving as BMP: metadata support is poor, so prefer PNG or TIFF.
  • Renaming a file to .bmp: this does not convert the content.

Conclusion

BMP is the plainest common raster format: simple to parse and costly to store. It is worth understanding as a baseline and worth keeping for legacy programs, but modern work belongs in PNG for lossless needs and in lossy formats for photographs. If a BMP lands in your folder, convert a copy to PNG and enjoy the space savings.

Frequently Asked Questions

Where did the BMP format come from?

It came from early Microsoft Windows and OS/2, where a device-independent bitmap let programs exchange pictures with the operating system.

How does a DIB differ from a .bmp file?

A DIB is the bitmap data without the 14-byte file header, used in memory and inside resources. A .bmp file is a DIB preceded by that header.

Why is a BMP so much larger than a PNG of the same picture?

BMP usually stores every pixel uncompressed, while PNG compresses losslessly. The decoded pictures can be identical.

Does BMP lose quality when saved repeatedly?

No. It stores pixel values without lossy compression, so repeated saves do not degrade it.

Why is my BMP upside down?

Rows are normally stored bottom to top, and a program that ignores the height sign can show the image flipped.

Why are the colors wrong in my BMP?

BMP stores channels as blue, green, red. A program that assumes red, green, blue swaps the colors.

What is row padding in BMP?

Each pixel row is extended with unused bytes so its length is a multiple of four bytes. Readers must skip the padding.

Can BMP have transparency?

Only in 32-bit variants with an alpha channel, and many programs ignore that channel. PNG or WebP is the dependable option.

What color depths does BMP support?

Typically 1, 4, 8, 16, 24, and 32 bits per pixel. The lower depths use a palette.

How do I calculate the size of a BMP?

Multiply padded row bytes by height and add the headers. For 24-bit images, row bytes are width times three, rounded up to a multiple of four.

Can a BMP be compressed?

Run-length encoding exists for 4- and 8-bit images, but it is rarely used and not universally supported.

Do browsers display BMP files?

Current browsers show standard BMPs, but the size makes it a poor web format.

Is BMP good for printing?

It can print, but it offers no CMYK mode and little metadata. TIFF or PDF suits professional printing better.

Why do programmers like BMP?

The layout is simple enough to read and write with very little code, and it needs no decompression library.

What is BITMAPINFOHEADER?

It is the common 40-byte header that records width, height, bits per pixel, compression, and related fields for a BMP.

Does BMP store metadata like camera settings?

Not in any standard way. It holds basic fields such as resolution, so use JPG, TIFF, or PNG with metadata when records matter.

Is there a practical size limit for BMP images?

Limits come from 32-bit size fields and from software, so very large images may be unreliable. Use TIFF or another format for huge pictures.

What does SnapZain say about BMP conversion?

Its page lists BMP as an accepted input and an available output, with a 20 MB limit per file and the usual caution that some conversions depend on server codecs.

Is converting BMP to PNG lossless?

Yes, for the pixel values. PNG stores the same data with lossless compression, though a 32-bit alpha channel may be handled differently by some programs.

Should I keep my old BMP archive?

Convert copies to PNG or TIFF to save space and gain metadata support, verify the results, and keep the originals until you are sure.

How much space does a 3 by 2 pixel 24-bit BMP need?

Each row needs 9 bytes padded to 12, so the pixel array is 24 bytes, and the two headers add 54 bytes, giving a file of 78 bytes.

Share this article

Join the Conversation