_________________________________________________________________________ Structure (In Order): _________________________________________________________________________ -- File Header (14 bytes) -- Information Header (40 Bytes) -- Palette (If the image is indexed colour) -- Image Data The following will be assumed in the case of: short int = 2 bytes (16 bits) int = 4 bytes (32 bits) long int = 8 bytes (64 bits) _________________________________________________________________________ File Header: _________________________________________________________________________ typedef struct{ unsigned short int type; //Magic identifier = 0x4D42 (In hex notation) unsigned int size; //File size in bytes unsigned short int reserved1, reserved2; //Always 0 unsigned int offset; //Offset to image data in bytes //offset = FILEHEADERSIZE (14)+INFORMATIONHEADERSIZE (40) + (4* informationheader.ncolours) }FILEHEADER; Structure might be padded with 2-6 bytes - might unalign fread _________________________________________________________________________ Information Header: _________________________________________________________________________ typedef struct{ unsigned int size; //Header size in bytes int width, height; //Width and height of image unsigned short int planes; //Number of colour planes unsigned short int bits; //Bits per pixel (Can be 1, 4, 8, 24) unsigned int compression; //Compression type unsigned int imagesize; //Image size in bytes int xresolution,yresolution; //Pixel per meter unsigned int ncolours; //Number of colours unsigned int importantcolours; //Important colours }INFOHEADER; Compression types: 0 - No Compression 1 - 8 bit run length encoding 2 - 4 bit run length encoding 3 - RGB bitmap with mask 24 bit Image Data: - BGR (Instead of RGB) - 3 bytes (8*3=24) per pixel _________________________________________________________________________ _________________________________________________________________________