Simple BitMap (SBM) is an image format designed for easy reading and writing. There is no compression, no re-ordering of colour values and no complex header.

SBM files have a 5 byte header:

OffsetSizeDescription
02Image Width
22Image Height
41BPP

Image data follows the header at offset 5. The image data will be either 24 bit (RGB) or 32 bit (RGBA) as specified by the header.
An quick consistency check for SBM files is to read the header and check the filesize is equal to (Width*Height*(BPP/8))+5.


Example SBM Loader

     int LoadSBM(char *filename)
      {
       int Width,Height,BPP;
     
        // Check file consistency
        if((Width*Height*(BPP/8))!=FileSize)
         {
          cerr<<"Bad file"<<endl;
          return -1;
         }

      }
    
Home