This page was last modified 09:28, 24 April 2007.
Reading MBM MIF images
From Forum Nokia Wiki
CMBM_MIF_Reader implementation illustrates how to load MBM and MIF images in S60 3rd Edition devices.
Note that IsMifFile-function used to determine if the file if MBM or MIF uses only the file extension to determine the file type, not the actual file content, thus MIF files should always have .mif extension and mbm files .mbm extension.
The ValidateLogicalAppIconId-function is used to map the zero-based index numbers to the actual index numbers used with the mif file, thus you can use zero-based index similarly as with the mbm files.
Also note that some native S60 controls will resize icons automatically, and when the icons are used with these types of controls the aSize argument should indicate size equal to TSize(0,0), which would then allow these controls to do their own resizing.
MBM_MIF_Reader.cpp
#include <cntfield.h> #include <cntdef.h> #include <cntitem.h> #include <cntfldst.h> #include <cntdb.h> #include <COEMAIN.H> #include <aknsutils.h> CMBM_MIF_Reader::CMBM_MIF_Reader() { } CMBM_MIF_Reader::~CMBM_MIF_Reader() { delete iFrameImg; delete iFrameMsk; } void CMBM_MIF_Reader::LoadImageL(const TDesC& aFileName, TInt aImg, TInt aMsk,const TSize& aSize) { delete iFrameImg; iFrameImg = NULL; delete iFrameMsk; iFrameMsk = NULL; TInt MaskId(aMsk); TInt UseIndex(aImg); if(AknIconUtils::IsMifFile(aFileName)) { AknIconUtils::ValidateLogicalAppIconId (aFileName, UseIndex, MaskId); } AknIconUtils::CreateIconL(iFrameImg, iFrameMsk, aFileName, UseIndex, MaskId); AknIconUtils::SetSize(iFrameImg,aSize,EAspectRatioPreserved); AknIconUtils::SetSize(iFrameMsk,aSize,EAspectRatioPreserved); } CFbsBitmap* CMBM_MIF_Reader::Bitmap() { return iFrameImg; } CFbsBitmap* CMBM_MIF_Reader::Mask() { return iFrameMsk; }
MBM_MIF_Reader.h
#include <e32base.h> #include <coecntrl.h> #include <w32std.h> #include <e32std.h> #include <cntdef.h> #include <cntdb.h> class CMBM_MIF_Reader : public CBase { public: CMBM_MIF_Reader(); void LoadMBML(const TDesC& aFileName, TInt aImg, TInt aMsk,const TSize& aSize); ~CMBM_MIF_Reader(); CFbsBitmap* Bitmap(); CFbsBitmap* Mask(); private: CFbsBitmap* iFrameMsk; CFbsBitmap* iFrameImg; };
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| creating an mbm dynamically | chandrasekharan | General Symbian C++ | 7 | 2007-10-30 14:35 |
| mbm file creation | bballbeng | General Symbian C++ | 1 | 2006-08-03 16:22 |
| good material dealing with images | deepthis | Symbian Media (Graphics & Sounds) | 8 | 2005-09-21 17:22 |
| How to display application Icon | rahul.cogent | Symbian Media (Graphics & Sounds) | 1 | 2007-05-30 07:17 |
| 给列表添加图标时一运行到这个语句(icons->AppendL)就退到开始 | hst_little | Symbian | 11 | 2007-04-28 07:26 |
