BMP

From FSDeveloper Wiki
Jump to: navigation, search


In this article we will focus on the Flight Simulator flavored version of BMP used for textures, an extension of the BMP or Bitmap File Format, a well known image format mainly used on Microsoft Windows operating systems. These files are usually generated with ImageTool that comes with the SDK.

There are two differences with a standard BMP :

  • the header have an "FS70" extension;
  • the pixels may be stored in various DXT format.

Standard Header Structure

Here is the equivalent C++ structure of the header. It start with magic signature :

 struct BITMAPMAGIC {
   BYTE Magic[2];        //Magic is always {'B', 'M'}
 };

It is immedialty followed (without padding) by the file header :

 struct BITMAPFILEHEADER {
   DWORD Size;        //The total size of the file
   WORD Creator1;    //Application depend
   WORD Creator2;    //Application depend
   DWORD Offset;      //Offset tot eh pixel data
 };

Then follows the bitmap infos :

 struct BITMAPINFO {
   BITMAPINFOHEADER Header;
   RGBQUAD          Colors[1];
 }

where BITMAPINFOHEADER is :

 struct BITMAPINFOHEADER {
   DWORD Size;             //The size of this header (40)
   LONG  Width;            //The width of the image in pixel
   LONG  Height;           //The height of the image in pixel
   WORD  Planes;           //The number of planes (1)
   WORD  BitCount;         //The number of bits-per-pixel
   DWORD Compression;      //The type of compression
   DWORD SizeImage;        //The size of the image in bytes
   LONG  XPelsPerMeter;    //The horizontal resolution
   LONG  YPelsPerMeter;    //The vertical resolution
   DWORD ClrUsed;          //The number of color indexes actually used
   DWORD ClrImportant;     //The number of color indexes required
 };

and RGBQUAD is

 struct RGBQUAD {
   BYTE Blue;
   BYTE Green;
   BYTE Red;
   BYTE Reserved;
 };

and contains a possible palette. So far, we are on familiar ground. For more details you may found the following links usefull :

[MSDN] [WikiPedia]

FSX Header Structure

After the standard header a FS70 extension is found :

 struct BITMAPFSXHEADER {
   BYTE Format[4];         //Format is always {'F', 'S', '7', '0'}. 
   DWORD Version;	   //Version is always 20  
   BYTE Reserved;
   BYTE Alpha;             //Set to 1 if the BMP has an alpha layer
   BYTE Reserved;
   BYTE Reserved;
   BYTE HasBorder;         //Set to 1 is the BMP has a 1 pixel border
   WORD NbMips;            //The number of mips
   DWORD Reserved;
 };

Some of the Reserved fields may have meanings that are not discovered yet.

Pixel Data

Right after the FS70 header the pixel section stored uncompressed (packed in rows) or in compressed format.

For an uncompressed format the expected size of this section is ImageHeight * ImageWidth * BitsPerPixel / 32 * 4.


Related

Internal

External