Computer Labs: The BMP file format 2o MIEIC Pedro F. Souto (
[email protected]) November 26, 2018 Digital Image File Formats XPM as we have defined has some limitations I Good only for indexed modes I It is not standard I Need to manually edit the XPMs bmp has been used by many LCOM projects in recent years I It is relatively simple, and you can use some libraries available on the Web to load bmp files I It is supported by some well know graphics editors, e.g. GIMP Example: Using C Arrays to Store XPMs static char *pic1[] = { "32 13 4", /* number of columns and rows, in pixels, and colors */ ". 0", /* ’.’ denotes color value 0 */ "x 2", /* ’x’ denotes color value 2 */ "o 14", /* .. and so on */ "+ 4", "................................", /* the map */ "..............xxx...............", "............xxxxxxx.............", ".........xxxxxx+xxxxxx..........", "......xxxxxxx+++++xxxxxxx.......", "....xxxxxxx+++++++++xxxxxxx.....", "....xxxxxxx+++++++++xxxxxxx.....", "......xxxxxxx+++++xxxxxxx.......", ".........xxxxxx+xxxxxx..........", "..........ooxxxxxxxoo...........", ".......ooo...........ooo........", ".....ooo...............ooo......", "...ooo...................ooo...." }; Question How many elements does an XPM array have? The BMP File Structure Bitmap File Header File metadata: Bitmap Info Header/DIB Header Pixmap and pixel format metadata I There are several versions, the most recent one is v5 Color Table/RGB Quad Array i.e. color palette I Used mainly for indexed color representations Pixel Array the pixmap Other structures with extra information or for padding are optional. Image with the BMP file fomat , via Wikipedia Bitmap File Header typedef struct tagBITMAPFILEHEADER { WORD bfType; // this is 2 bytes DWORD bfSize; // this is 4 bytes WORD bfReserved1; WORD bfReserved2; DWORD bfOffBits; }; Type Must be ’B”M’, in ASCII I But there other format versions Size Size of file OffBits Pixmap array offset (in file) Bitmap Info Header I Contains metadata about: Pixmap e.g.