BMP Image

From XentaxWiki
(Redirected from BMPImage)
Jump to: navigation, search

BMP


Format Specifications

// BMP file format (image)

// little endian

// header - 14 bytes
2 bytes (char) - magic // "BM"
4 bytes (uint32) - size of the BMP file
4 bytes - reserved
4 bytes (uint32) - offset of image data

// DIB header --> Info header (40 bytes) OR Core header (12 bytes) etc.
// There are several types of DIB headers. Not all of them are documented though.
// See more details in notes section.
// The one described below is BITMAPINFOHEADER, used in Windows apps.

// Info header
4 bytes (uint32) - size of info header   // "40"
4 bytes (uint32) - bitmap width in pixels
4 bytes (uint32) - bitmap height in pixels
2 bytes (uint16) - number of color planes   // must be "1"
2 bytes (uint16) - number of bits per pixel // "1" - monochrome pelette, num_colors=1
                                            // "4" - 4bit palettized, num_colors=16
                                            // "8" - 8bit palettized, num_colors=256
                                            // "16" - 16bit RGB, num_colors=65536
                                            // "24" - 24bit RGB, num_colors=16M
                                            // "32" - 32bit RGB
4 bytes (uint32) - compression type  // "0" - BI_RGB, no compression
                                     // "1" - BI_RLE8, 8bit RLE encoding
                                     // "2" - BI_RLE4, 4bit RLE encoding
                                     // "3" - BI_BITFIELDS, Huffman 1D 
                                     // "4" - BI_JPEG, RLE-24
                                     // "5" - BI_PNG 
                                     // "6" - BI_ALPHABITFIELDS 
                                     // "11" - BI_CMYK 
                                     // "12" - BI_CMYKRLE8 
                                     // "13" - BI_CMYKRLE4 
4 bytes (uint32) - compressed image size   // can be 0 if image is uncompressed
4 bytes (int32) - preferred horizontal resolution (pixels per metre)
4 bytes (int32) - preferred vertical resolution (pixels per metre)
4 bytes (uint32) - number of used colors in palette  // "0" for default 2^n
4 byte (uint32) - number of important colors  // 0=all colors 
                                               // ignored in most cases


// bit masks (optional)   
x bytes - extra bit masks   // occurs only for "3" and "6" 
                            // bitfields compression types
                            // and ONLY when info header is present

// color table / palette (optional, but mandatory for color depths <= 8 bits )
// e.g. Palette can have 756 bytes in RGB24 format when Core Header is present and image is 8bpp type
// e.g. Palette can have 1024 bytes in RGBA32 format
x bytes - palette data

// pixel array
x bytes - image data

MultiEx BMS Script

Not written yet.

Notes and Comments

  • Generic Bitmap *.bmp Image.
  • There are different kinds of DIB headers available in this format:
    BITMAPCOREHEADER (12 bytes)
    OS22XBITMAPHEADER (64 bytes)
    OS22XBITMAPHEADER (16 bytes)
    BITMAPINFOHEADER (40 bytes)
    BITMAPV2INFOHEADER (52 bytes)
    BITMAPV3INFOHEADER (65 bytes)
    BITMAPV4HEADER (108 bytes)
    BITMAPV5HEADER (124 bytes)
    but the most common ones are BITMAPCOREHEADER and BITMAPINFOHEADER used mostly in Windows applications.

Games

List of games using this file format:

Compatible Programs

See Also