Clean Coding Company Version: V1.1 Table of Contents Introduction This document describes the Microsoft Windows and IBM OS/2 picture bitmap files, called Bitmaps or BMP files. Most of the descriptions of the BMP file concentrate on the Microsoft Windows BMP structures like BMPINFOHEADER and BMPCOREINFO , but only a few describe the file contents on byte level. This information is therefor only intended to be used in applications where direct reading and writing of a BMP file is required. Bitmap File Format The following chapters contain the detailed information on the contents of the BMP file. First more general information will be given regarding the byte order and file alignment. The second chapter will concentrate on the byte-level contents of a BMP file. The third chapter will elaborate on this chapter and explain some of the concepts - like compression - and/or values in detail. General The BMP file has been created by Microsoft and IBM and is therefor very strictly bound to the architecture of the main hardware platform that both companies support: the IBM compatble PC. This means that all values stored in the BMP file are in the Intel format, sometimes also called the Little Endian format because of the byte order that an Intel processor uses internally to store values. The BMP files are rd in the bitmap array represents a single pixel. Windows NT specific: When the Compression field is set to BI_BITFIELDS, bits set in each dword mask must be contiguous and should not overlap the bits of another mask. All the bits in the pixel do not have to be used. Windows 95 specific: When the Compression field is set to BI_BITFIELDS, Windows 95 supports only the following 16bpp color masks: A 5-5-5 16-bit image, where the blue mask is 0x001F, the green mask is 0x03E0, and the red mask is 0x7C00; and a 5-6-5 16-bit image, where the blue mask is 0x001F, the green mask is 0x07E0, and the red mask is 0xF800. When this field is equal to 24. The bitmap has a maximum of 2^24 colors, and the Palette field does not contain any entries. Each 3-byte triplet in the bitmap array represents the relative intensities of blue, green, and red, respectively, for a pixel. When this field is equal to 32. The bitmap has a maximum of 2^32 colors. If the Compression field of the bitmap is set to BI_RGB, the Palette field does not contain any entries. Each dword in the bitmap array represents the relative intensities of blue, green, and red, respectively, for a pixel. The high byte in each dword is not used. If the Compression field of the bitmap is set to BI_BITFIELDS, the Palette field contains three dword color masks that specify the red, green, and blue components, respectively, of each pixel. Each dword in the bitmap array represents a single pixel. Windows NT specific: When the Compression field is set to BI_BITFIELDS, bits set in each dword mask must be contiguous and should not overlap the bits of another mask. All the bits in the pixel do not have to be used. Windows 95 specific: When the Compression field is set to BI_BITFIELDS, Windows 95 supports only the following 32bpp color mask: The blue mask is 0x000000FF, the green mask is 0x0000FF00, and the red mask is 0x00FF0000. 'the way, Windows stores bit mapped images. The BMP image data is bit packed but every line must end on a dword boundary - if thats not the case, it must be padded with zeroes. BMP files are stored bottom-up, that means that the first scan line is the bottom line. The BMP format has four incarnations, two under Windows (new and old) and two under OS/2, all are described here. BMP Contents The following table contains a description of the contents of the BMP file. For every field, the file offset, the length and the contents will be given. For a more detailed discussion, see the following chapters. Offset Field Size Contents 0000h Identifier 2 bytes The characters identifying the bitmap. The following entries are possible: `BM' - Windows 3.1x, 95, NT, ... `BA' - OS/2 Bitmap Array `CI' - OS/2 Color Icon `CP' - OS/2 Color Pointer `IC' - OS/2 Icon