LLMpediaThe first transparent, open encyclopedia generated by LLMs

BITMAPFILEHEADER

Note: This article was automatically generated by a large language model (LLM) from purely parametric knowledge (no retrieval). It may contain inaccuracies or hallucinations. This encyclopedia is part of a research project currently under review.
Article Genealogy
Parent: BMP Hop 5 terminal

This article was accepted into the corpus but its outbound wikilinks were never NER-processed — typical at the deepest BFS hop or when the run's entity cap was reached. No expansion funnel to show.

BITMAPFILEHEADER
NameBITMAPFILEHEADER
Extension.bmp, .dib
OwnerMicrosoft
Introduced1989
GenreImage file formats
ContainerforBitmap (raster graphics) data

BITMAPFILEHEADER The BITMAPFILEHEADER is a fixed-size header used by the Microsoft Bitmap file format to describe basic properties of a bitmap file, including signature, file size, reserved fields, and offset to pixel data. It precedes the bitmap information header and pixel array in BMP file format files produced by implementations on Microsoft Windows, OS/2, and third-party graphics libraries. Implementations and tooling in environments such as GDI+, Win32 API, libpng, ImageMagick, Graphics Device Interface ecosystems rely on correct BITMAPFILEHEADER fields for interoperability.

Overview

The BITMAPFILEHEADER provides essential metadata required by decoders such as Windows Graphics Device Interface, Microsoft Paint, Adobe Photoshop, GIMP, and IrfanView to locate the bitmap data block. It appears at the very start of classic BMP file format files and is followed by a DIB header like the BITMAPINFOHEADER used by Windows 3.1, Windows 95, and later systems. Historical and contemporary applications including LibreOffice, XnView, Netpbm, FFmpeg, and Qt image loaders examine the signature to confirm format, while graphics APIs such as DirectX and OpenGL utilities sometimes convert BMP assets for textures.

Structure and Fields

The header is typically 14 bytes in the canonical layout defined by Microsoft documentation and present in archives produced by Windows NT, Windows 2000, Windows XP, and later releases. Primary fields include: - Signature: two-byte ASCII signature (commonly "BM") used by decoders like GDI32.dll and viewers such as Paint.NET and ACDSee. - FileSize: a 32-bit little-endian unsigned integer indicating total file length as used by file managers like Windows Explorer and archivers like 7-Zip. - Reserved1 and Reserved2: two 16-bit fields historically reserved by Microsoft and ignored by most applications including IrfanView and ImageMagick. - PixelDataOffset: a 32-bit offset to the bitmap pixel data, enabling editors like Adobe Photoshop and converters like ImageMagick to find the image payload.

Conforming implementations adhere to little-endian ordering on x86 and x86-64 platforms used by vendors such as Intel Corporation and AMD. Cross-platform libraries such as libbmp and stb_image handle endianness when parsing headers on architectures including ARM and PowerPC.

File Layout and Alignment

The BITMAPFILEHEADER precedes a DIB header (for example, BITMAPINFOHEADER, BITMAPV4HEADER, or BITMAPV5HEADER) and color tables used by indexed bitmaps. The PixelDataOffset accounts for the combined size of the BITMAPFILEHEADER, the DIB header, and any palette data as required by standards referenced in Microsoft Windows SDK documentation and tooling like Visual Studio. Row padding aligns scanlines to 4-byte boundaries, a behavior observed in decoders on Windows CE and image utilities such as GIMP and Krita. Some platforms or converters associated with projects like Wine (software) and ReactOS may accept nonstandard offsets but this can break compatibility with strict parsers used by antivirus engines or image validators in GitHub repositories.

Usage and Compatibility

Bitmaps using BITMAPFILEHEADER are widely supported across software including Microsoft Paint, Adobe Photoshop, GIMP, IrfanView, ImageMagick, FFmpeg, VLC media player, and embedded systems from vendors such as Texas Instruments and STMicroelectronics. Compatibility issues arise when atypical values are used: oversized FileSize fields, nonzero reserved fields expected to be zero by some validators, or offsets that place pixel data beyond the file end — situations that have been discussed in standards bodies and bug reports involving Microsoft documentation, Wine (software), and open source parsers on GitHub. Applications converting between formats—such as from PNG or JPEG—must construct a valid BITMAPFILEHEADER for BMP output to ensure interoperability with target platforms like Windows 10, Windows 7, Android image viewers, and iOS utilities that accept BMP.

Examples and Code Snippets

Typical C struct definitions and parsing examples are used in projects like SDL, Qt and wxWidgets codebases. Example C layout: - Two bytes for signature ('B','M'). - uint32_t for file size. - uint16_t reserved1, reserved2. - uint32_t for pixel data offset.

Developers reference headers in Microsoft Windows SDK and implementations in open source projects such as stb_image.h, ImageMagick, libbmp, GIMP plugins, and FFmpeg BMP demuxers to ensure correct packing and alignment. Bindings for languages like Python (Pillow), Java (ImageIO), C# (.NET), and Rust crates also construct or parse BITMAPFILEHEADER fields for reading and writing .bmp assets in applications ranging from Unity to Unreal Engine.

History and Standardization

The BITMAPFILEHEADER originated with Microsoft's early bitmap implementations in the late 1980s and early 1990s, coinciding with releases of Windows 2.0, Windows 3.0, and OS/2 Presentation Manager. Over time, the DIB header successors—BITMAPINFOHEADER, BITMAPV4HEADER, and BITMAPV5HEADER—extended capability for color management and alpha channels, referenced in Microsoft Windows SDK and discussed in interoperability efforts involving Apple Inc. image tools, Adobe Systems software, and open source communities such as GNOME and KDE. Documentation, sample code, and community knowledge evolved through resources like MSDN, Stack Overflow, and numerous project repositories on GitHub.

Category:Image file formats