the cutting room mirror

Format:BMP

The BMP, or Bitmap Format, is a file format created by Microsoft in the early 1990s. The file is split into 3 chunks - the usual File Header chunk, the optional Palette Chunk, and the required bitmap chunk.

A file header stores information about files, in this case the Image Size. Below is easy-to-read code made in QBasic and a translated version of how the code would be in human readable form when loading a 256-Colo(u)r (8BPP) file.

QB Code

Human Readable Form

TYPE BMPHeaderType       
        id AS STRING * 2      'Should be "BM"
        size AS LONG          'Size of the data
        rr1 AS INTEGER        '
        rr2 AS INTEGER        '
        offset AS LONG        'Position of start of pixel data
        horz AS LONG          '
        wid AS LONG           'Image width
        hei AS LONG           'Image height
        planes AS INTEGER     '
        bpp AS INTEGER        'Should read 8 for a 256 colo(u)r image
        pakbyte AS LONG       '
        imagebytes AS LONG    'Width*Height
        xres AS LONG          '
        yres AS LONG          '
        colch AS LONG         '
        ic AS LONG            '
        pal AS STRING * 1024  'The Palette
END TYPE

The Palette (Can Be Stored in ".PAL")#

Determining BPP and Palette Byte Size#

BPP

Colo(u)r Count

1

2

2

4

4

16

8

256

Data Structure#

Being padded by 4 bytes, it would be stored as BGR (Blue, Green, Red).

Bitmap Structure#

The image is stored upside-down and each scanline is padded by 4 bytes.

For more detailed specification, see the Bitmap File Specification.