Loading a Bitmap from a File

Bitmaps can be stored in multi-bitmap ( .mbm ) files, which can be built from .bmp files as part of the abld process. This topic provides an example of loading a multi-bitmap file.

Loading them has four stages:

  1. Put the name of the bitmap file into a buffer.

  2. Create a bitmap ( CFbsBitmap ).

  3. Load the bitmap using CFbsBitmap::Load() .

  4. If an error is returned, leave and ensure the bitmap is cleaned up

      
       
      
      // set the name of the multi-bitmap file containing the bitmaps
_LIT(KMBMFileName,"z:\\resource\\apps\\grbmap2.mbm");
    
// load the bitmap from an .mbm file
CFbsBitmap* bitmap = new (ELeave) CFbsBitmap();
CleanupStack::PushL(bitmap);
User::LeaveIfError(bitmap->Load(KMBMFileName, EMbmGrbmap2Smiley));
    
// EMbmGrbmap2Smiley is the ID of a bitmap in the .mbm file
...
    
// clean up
CleanupStack::PopAndDestroy();