c++mobilesymbiancarbide

Symbian C++ - Load and display image from .mbm file


I have a .mbm file that I copy to my device using this line in the .pkg file

"$(EPOCROOT)epoc32\data\z\resource\apps\MyApp.mbm" -"!:\resource\apps\MyApp.mbm"

Then in the draw function of my container I do this..

_LIT(KMBMFile , "\\resource\\apps\\MyApp.mbm" );
CFbsBitmap* iBitmap;

iBitmap->Load(KMBMFile, 0);
gc.BitBlt(Rect().iTl, iBitmap);

However the line iBitmap->Load(KMBMFile, 0); raises a KERN-EXEC:0 PANIC

"This panic is raised when the Kernel cannot find an object in the object index for the current process or current thread using the specified object index number (the raw handle number)."

Can anyone spot where I am going wrong?

Thanks!


Solution

  • You were dereferencing an uninitialized pointer, you could also use this:

    // remember to include the EIK environemnt include file
    #include <eikenv.h>
    
    _LIT(KMBMFile , "\\resource\\apps\\MyApp.mbm" );
    CFbsBitmap* iBitmap;
    
    iBitmap = iEikonEnv->CreateBitmapL( KMBMFile, 0 );
    gc.BitBlt( Rect().iTl, iBitmap );