Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


How to load 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. 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();