symbian 显示位图和SVG图
2010-08-31 00:09:00 来源:WEB开发网{
EMbmGraphic_bmpImage1,
EMbmGraphic_bmpImage2,
EMbmGraphic_bmpImage2_mask
};
在用完后要删除位图对象
//在析构函数中删除
delete iBackgroundImage;
delete iImage2;
delete iImage2mask;
//加载SVG图
//声明部分
CFbsBitmap* iSoundSvg; //图片会把SVG图转换成位图,如果要实现矢量拉伸,需要重新加载
CFbsBitmap* iSoundSvgMask;
//实现部分
#include
#include
_LIT(KSvgPath, "\resource\apps\graphic_svg.mif");
//加载svg矢量图
TFileName svgFile (KSvgPath);
User::LeaveIfError (CompleteWithAppPath (svgFile));
AknIconUtils::CreateIconL(iSoundSvg, iSoundSvgMask, svgFile, EMbmGraphic_svgSound,EMbmGraphic_svgSound_mask);
//iSoundSvg=AknIconUtils::CreateIconL(svgFile,EMbmGraphic_svgSound);
AknIconUtils::SetSize(iSoundSvg, TSize(50,50), EAspectRatioNotPreserved);
AknIconUtils::SetSize(iSoundSvgMask, TSize(50,50), EAspectRatioNotPreserved);
//用后同样要删除
delete iSoundSvg;
delete iSoundSvgMask;
图片的显示过程:
//Draw()函数中实现
在设备绘图上下文类CWindowGc中绘制图形,CWindowGc是图形上下文CGraphicesContext类的派生类
//清空窗口上的内容
gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.SetBrushColor( KRgbGray );
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
gc.DrawRect( aRect );
gc.SetBrushStyle( CGraphicsContext::ENullBrush );
//绘制客户区背景
//gc.BitBlt( Rect().iTl,iBackgroundImage );
gc.DrawBitmap(aRect,iBackgroundImage); //通过拉伸的方式放缩要目标矩形中
//在客户区的第一行绘制位图图标
更多精彩
赞助商链接