Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

在S60加载Bitmap和Mask的效率

From Wiki
Jump to: navigation, search
Article Metadata

文章
翻译:
hoolee
最后由 hamishwillee 在 22 Dec 2011 编辑
_LIT(KYourMifFile, “resource\\apps\\yourmif.mif”);

//yourmif.mif contains svgs

include <yourmif.mbg>  in  .cpp file

// In header file

CFbsBitmap* iFocusBitmap;
CFbsBitmap* iBitmapMask;

// anywhere in .cpp file

if(iFocusBitmap == NULL)
{
// load the image and mask
AknIconUtils::CreateIconL( iFocusBitmap,
iBitmapMask,
KYourMifFile,
EMbmYourMif_focus,
EMbmYourMif_mask );
}
TSize size(Rect().Width()*10/100,Rect().Height()*10/100);
AknIconUtils::SetSize(iFocusBitmap,size,EAspectRatioNotPreserved);
AknIconUtils::SetSize(iBitmapMask,size,EAspectRatioNotPreserved );

// In the destructor

delete  iFocusBitmap;
delete iBitmapMask;

AknIconUtils::SetSize初始化给定尺寸的图标,参数aBitmap是CAknBitmap的示例,如AknIconUtils方式生成。如果不是CAknBitmap,这个方法无效。注意这里调用设置的是bitmap和mask(如果它存在的话),如果不调用SetSize方法,那么位图将无法被绘制到屏幕上。

尽管CreateIconL有重载方法只加载单个图片,但上述方法在加载和修改尺寸方面更有效率。

This page was last modified on 22 December 2011, at 04:46.
94 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×