Game Development Reference
In-Depth Information
really worth the additional effort. Some bitmap editors allow the option to
save a 'bmp' file as either RGB or RLE and I advise choosing the RGB
alternative. I like Paint Shop Pro, which is fairly cheap but provides all the
tools you will need when manipulating bitmaps.
RGB bmp files are delightfully simple to use because the pixel data are
stored in as simple a way as possible. Before we examine the pixel data,
let's look at the file header which describes how the pixel data are
typedef struct tagBITMAPFILEHEADER {
WORD bfType;
DWORD bfSize;
WORD bfReserved1;
WORD bfReserved2;
DWORD bfOffBits;
'bfType' defines the file as a bitmap file if it contains the number 0x4D42,
which is ASCII for 'BM'. Assuming this test is passed then we can check the
size of the file using 'bfSize' and how many bytes to skip to find the pixel
data using 'bfOffBits'. Subtracting bfOffBits from 'bfSize' gives the total size
in bytes of the pixel data. If the checks are passed then we can be assured
that the next section of the file will be a BITMAPINFOHEADER.
typedef struct tagBITMAPINFOHEADER{
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
We will use the 'biWidth', 'biHeight' and 'biBitCount' members. 'biWidth'
and 'biHeight' give the sizes of the bitmap in pixels and 'biBitCount' gives
the colour depth in bits per pixel. Since 'bmp' files sometimes use a
palette to define colour values, our loader is designed to accommodate
Search Nedrilad ::

Custom Search