
The figure shows the format of the bitmap file: we can see that we have a 54 bytes
header, 1024 bytes for the palette and last the image data. This image data is large than the size
of the image; so if we have an 800x600x256 image, the data use nearly 500Kb! Here are the
description of the header:| Variable | Description |
| WORD type | The signature of the file format. Must be BM |
| DWORD size | Size of the file |
| DWORD reserved | ... |
| DWORD offset | Offset of the data from this position. Must be 40 |
| DWORD headersize | The size of the rest of the header |
| DWORD width | Width of the image |
| DWORD height | Height of the image |
| WORD planes | Planes of the bitmap |
| WORD bitsperpixel | number of bits per pixel |
| DWORD compression | Type of compression used |
| DWORD sizeimage | Size of the image data |
| DWORD xpixelpermeter | Number of horizontal pixel per meter |
| DWORD ypixelpermeter | Number of vertical pixel per meter |
| DWORD colorsused | Number of colors used |
| DWORD colorsimportant | Number of colors considered important |
4 - (width % 4)
bytes of each lines. See the demo program for the code.
Another file format is the ZSoft .PCX, simple to use and a bit compressed. The file start with a
header of 128 bytes that contains all the necessary informations for using the images, comprised
the palette for the EGA. After the header we have the image, compressed with the method called
run length encoded, where instead of storing a sequence of equals byte is stored the count
of repetitions and next the value of the byte. At least there are the VGA palette, stored with the
RGB format. For more informations email me and
I'll send you a more detailed description. There are the format of the header:| Variable | Description |
| BYTE manufacturer | Costant flag 10 = ZSoft .PCX |
| BYTE version | Version information |
| BYTE encoding | 1= .PCX run length encoding |
| BYTE bitsperpixel | Number of bits/pixel per plane |
| WORD xmin | Picture dimensions |
| WORD ymin | ... |
| WORD xmax | ... |
| WORD ymax | ... |
| WORD hres | Horizontal resolution of creating device |
| WORD vres | Vertical resolution of creating device |
| char colormap[48] | Color palette setting (EGA) |
| BYTE reserved | |
| BYTE nplanes | Number of colors planes |
| WORD bytesperline | Number of bytes per scan line per color plane (always even for .PCX files) |
| WORD paletteinfo | How to interpret palette 1=color/BW 2=grayscale |
| char filler[58] | Blank to fill out 128 bytes header |