×
Namespaces

Variants
Actions

Reading MBM MIF images

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: symbianyucca (20 Mar 2007)
Last edited: hamishwillee (11 Jan 2012)

Class CMBM_MIF_Reader 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.

Link against: aknicon.lib

MBM_MIF_Reader.cpp

#include <aknsutils.h> 
#include "MBM_MIF_Reader.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;
 
// we should validate icon ID in case of MIF-file
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>
 
// forward declaration
class CFbsBitmap;
 
class CMBM_MIF_Reader : public CBase
{
public:
CMBM_MIF_Reader();
~CMBM_MIF_Reader();
 
void LoadImageL(const TDesC& aFileName, TInt aImg, TInt aMsk,const TSize& aSize);
 
// accessors
CFbsBitmap* Bitmap();
CFbsBitmap* Mask();
 
private:
CFbsBitmap* iFrameMsk;
CFbsBitmap* iFrameImg;
};
This page was last modified on 11 January 2012, at 09:37.
54 page views in the last 30 days.