Grand Prix Legends BMAP Section Format by P.A.Flack 1998
contact: phil@flack99.freeserve.co.uk
last revised 21/Dec/'98
BMAP's, or Bitmaps, are used to store all images in GPL.  They are subsections of .MIP, .PBF, etc. files but can usually be used on their own.  There are a few things to watch out for when reading and displaying them - these are detailed at the bottom of this page.

The Header:

Bytes Values Notes
0-3 
4-7 
8-11
"PAMB" 
0x00000000 
data size
Section Type (BMAP) 

size of following data

After the header section comes the real header section:
 

Bytes Values Notes
0-3 
4-7
8-11 
12 
13-16 
17-20 
21-24 
25 
26
27
"DHMB" 
0x00000000 
data size 
image type
actual width 
actual height 
bytes per row 
unknown
padding 
padding
Section Type (Bitmap Header)

size of following data
Specifies type of BMAP (see later) 
width of image in pixels (actual, see later)
height of image in pixels
number of bytes per row (often unexpected size, see later)
can't find a reason for this - only seen as 0
padding 0x20 byte
padding 0x20 byte

If the image type is 2, a CMAP follows.  Then the DATA section follows (||ATAD||0000||SIZE||data...)
where data... is the pixel values.

BMAP Type
There are 6 different BMAP types:

Type Pixel format Other
0
1
2
3
4
5
4bit, external CMAP
4bit, external CMAP
4bit, internal CMAP
16bit, rgb 565
16bit, prgb 1555
16bit, argb 4444
CMAP from preceeding section is used: All Opaque
": One Transparent colour
Following the BMHD is a CMAP: Varying transparencies
rgb format 5r 6g 5b
rgb format 5r 5g 5b (1st bit (msb) can be ignored - maybe transparency)
argb format 4a 4r 4g 4b (a=alpha=translucency)
I.e. to get the alpha value of type 5, alpha=(colour >> 12) & 0x0f;

Bytes per Row
This value gives the number of bytes that must be read *height to read the image in from file correctly.  It is not necessarily the same as width*bpp/8 (i.e. width*2 for 16bit pixels).  If the image type is 4bit, then each byte contains two pixels (first pixel is byte/16, second pixel is byte%16).  To display each line, read in bytesperrow pixels into a buffer; working left to right display each half-pixel in turn, ensuring that the position the pixel is drawn is <= imagewidth.  This ensures that the trailing pixels are ignored.  The same goes for 16bit pixels, but this time two bytes need to be read for each pixel.



contact: phil@flack99.freeserve.co.uk
last revised 21/Dec/'98