The Journey  
The Game

The Paper - Page 14 - Bitmap Handling

The Workflow of C++ Game-Development on a Series 60 Platform device

Andreas Jakl, Revision 1.0, July 2004

4.5 Bitmap handling

Series 60 provides tools to easily put multiple bitmap files into .mbm files and to access those from within the application. While being quite straightforward to use, they have several disadvantages:

  • The pictures are stored as RLE compressed bitmaps, a compression algorithm which does not create the smallest possible files.
  • Bitmaps using 256 colors automatically get a standard palette assigned and do not keep their own. It is possible to specify an extra palette file with a list of the colors, which is then global to the whole .mbm file. However, standard graphical applications can not export the color palette of an image into the format required by the conversion utility from Symbian.

4.5.1 Creating the .mbm file

Still, if only a few bitmaps are required, this method is simple to use and getting the bitmaps from within the application does not take much time. It is possible to specify the parameters for the creation of the .mbm file in the .mmp file. However, you have more control over the process and its re-creation, if you write your own batch file. Call this file dobitmaps.bat and place it together with the bitmaps in the \data\ directory or your project.

Initially, the bmconv utility is called. The first parameter specifies that a header file called journey.mbg should be generated, containing an enumeration of the bitmaps stored in the .mbm file. The second parameter defines the name of the .mbm file to create. After that, add the individual bitmaps that should be part of the file. /c12bmpFileName.bmp specifies a 12-bit color bitmap. /c8bmpFileName.bmp an 8-bit file with the standard palette, unless an extra palette file is specified with /pPaletteFile . Masks should be 2-bit files ( /2bmpFileName.bmp ), using only black and white.

    bmconv /hjourney.mbg journey.mbm /c12InterfaceTop.bmp ->
        /c12InterfaceBottom.bmp /c8areaStreets.bmp

The two files are generated in the current directory and have to be copied to the right paths so that they can be found from within the application.

    copy journey.mbm Q:\Epoc32\Release\armi\UREL\journey.mbm
    copy journey.mbm Q:\Epoc32\Wins\c\system\Apps\Journey\ ->

    copy journey.mbg Q:\Epoc32\Include\journey.mbg

4.5.2 Loading and displaying bitmaps

Getting the bitmaps out of .mbm files is easy and fast. The header file created by the conversion utility has to be included; it contains an enumeration of the bitmaps that are inside the .mbm file. Open it to see how your bitmaps are called. Add the following two lines to the class where you want to load and display bitmaps:

    #include <journey.mbg>      // Bitmap enumeration
    _LIT(KJourneyMbm, "Journey.mbm");

To be able to display them on the screen, you have to create a bitmap object out of them. The Nokia graphics examples that come with the Symbian OS SDK for Series 60 use a collection of functions in the file bitmapmethods.cpp . The function CreateBitmapL creates an instance of the CFbsBitmap* class that we need. It then also adapts the color-depth to the display-depth of the device. Doing this only once when loading the image is useful because otherwise it would have to be converted every time it is displayed.

    TFileName fullName;
    AppendFullPath(KJourneyMbm, fullName);
    // Load the bitmap
    CFbsBmp* iBmp = NBitmapMethods::CreateBitmapL(fullName,

Once the file is loaded, displaying it is easy. To use it in the Draw() method of a control, you just have to copy the bitmap to the screen using BitBlt() . If you want to update the display with the new graphics in another place of your application, you have to force a redraw. The following code defines the redraw rectangle with the size of the picture and a fixed position. Next, this rectangle is invalidated, telling the Symbian OS window server that its content is outdated. Right after this, the program starts a redraw of the area and then copies the bitmap to the screen. Finally, it tells the window server that redrawing is finished.

    TPoint bmpPos(10, 29);
    TRect redrawRect(bmpPos, iCurLocationBmp->SizeInPixels());

    CWindowGc& gc = SystemGc();

    // Draw it onto the screen
    gc.BitBlt(bmpPos, iBmpIntroScreen);


For games which require a frequently updated graphical view, it is recommended to use a background buffer bitmap of the size of the screen where all the drawing goes to. Only once a loop in the game is finished, this bitmap is copied to the screen. To get the best performance, it is possible to bypass the Symbian OS window server by using Direct Screen Access . An example demonstrating this technique is available for download at Forum Nokia 10.

< Localization Contents Conclusion >
© 2004 Andreas Jakl. All Rights Reserved.
Privacy Statement | Contact and Imprint
The Journey