# What is a DIB File?

A DIB file stores a Windows device-independent bitmap using defined headers, optional color tables, and pixel data. Its representation is closely related to BMP and is designed to be independent of a particular display device.

<span aria-hidden="true" id="how-it-works"></span>

## How DIB Files work

A DIB describes raster pixels with a bitmap information header, optional color masks or a color table, and scan lines aligned to four bytes. The same structure appears in three places: inside a BMP file after the 14-byte `BITMAPFILEHEADER`, as a packed DIB in memory, and on the Windows clipboard as `CF_DIB` or `CF_DIBV5`. Windows treats `.dib` as a second extension for BMP, whereas some tools use DIB to mean the headerless form. Four header generations exist (`BITMAPCOREHEADER`, `BITMAPINFOHEADER`, `BITMAPV4HEADER`, `BITMAPV5HEADER`), told apart by the size value in their first four bytes. A color table is mandatory at 1, 4, and 8 bits per pixel, and `BI_BITFIELDS` bitmaps place three color masks directly after a `BITMAPINFOHEADER`, so an importer has to read the declared layout rather than assume 24-bit pixels.

<span aria-hidden="true" id="key-facts"></span>

## Key facts

1. DIB can mean data with or without the BMP file header. Windows’ BMP codec registers both `.bmp` and `.dib` for the same `image/bmp` format, which starts with a `BITMAPFILEHEADER` (bytes `BM`); clipboard `CF_DIB` data is a `BITMAPINFO` followed directly by the pixel bits; and ImageMagick defines its `DIB` format as a BMP file without the BMP header. Check for the `BM` signature before choosing a parser.
2. Uncompressed scan lines are padded to a multiple of four bytes, and the padding is not pixel data: a 10×10 24-bit bitmap carries two padding bytes per row. Compute the row stride as `((width * bitsPerPixel + 31) & ~31) >> 3`. RLE-compressed bitmaps are the exception and are not aligned this way.
3. A positive height means bottom-up storage, where the first stored row is the bottom of the image, and a negative height means top-down. Top-down is available only for uncompressed data: RLE-compressed bitmaps and `BITMAPCOREHEADER` bitmaps cannot be top-down.
4. Do not assume a 32-bit DIB carries valid transparency. Microsoft’s BMP codec ignores the extra channel of 16-bit and 32-bit bitmaps because many legacy files hold invalid data there; starting with Windows 8 it reads alpha only from 32-bit files written with a `BITMAPV5HEADER`. That is one codec’s policy, not a format limit: the earlier `BITMAPV4HEADER` also defines an alpha mask, so confirm how your own decoder treats the fourth channel.

<span aria-hidden="true" id="when-it-matters"></span>

## When DIB Files matter

Expect DIB data in Windows graphics APIs, clipboard transfers, and legacy image workflows. Correct parsing requires attention to header variants, row padding, color tables, and whether pixel rows are stored bottom-up.

<span aria-hidden="true" id="references"></span>

## Sources

* [Microsoft Learn: Device-Independent Bitmaps](https://learn.microsoft.com/en-us/windows/win32/gdi/device-independent-bitmaps)
* [Microsoft Learn: Bitmap Header Types (header generations, color tables, scan-line alignment)](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmap-header-types)
* [Microsoft Learn: Bitmap Storage (BMP file layout with BITMAPFILEHEADER)](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmap-storage)
* [Microsoft Learn: BITMAPINFOHEADER structure (height sign, color tables, stride)](https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapinfoheader)
* [Microsoft Learn: BITMAPV4HEADER structure (color and alpha masks)](https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapv4header)
* [Microsoft Learn: Standard Clipboard Formats (CF\_DIB, CF\_DIBV5)](https://learn.microsoft.com/en-us/windows/win32/dataxchg/standard-clipboard-formats)
* [Microsoft Learn: BMP Format Overview, Windows Imaging Component (extensions and alpha handling)](https://learn.microsoft.com/en-us/windows/win32/wic/bmp-format-overview)
* [ImageMagick: Image Formats, DIB entry](https://imagemagick.org/formats/)

[← Device Pixel Ratio](/glossary/device-pixel-ratio.md)[Digital Asset Archiving →](/glossary/digital-asset-archiving.md)

More in file formats & compression

* [Common Media Application Format (CMAF)](/glossary/common-media-application-format-cmaf.md)
* [DAT File](/glossary/dat-file.md)
* [DDS File](/glossary/dds-file.md)
* [DivX File](/glossary/divx-file.md)
* [ECW File](/glossary/ecw-file.md)
* [Entropy Coding](/glossary/entropy-coding.md)

[All 505 terms](/glossary.md)

## Turn media knowledge into a working pipeline

Connect uploads, processing, AI, storage, and delivery through one declarative API — with the encoding stack, scaling, and format churn handled for you.

[Try Transloadit for free](/c/signup/)
