Symbian 实现基于传统架构场景切换动画
2010-03-07 19:40:00 来源:WEB开发网CFbsBitmapDevice * iDevice = CFbsBitmapDevice::NewL(iBitmap);
CleanupStack: ushL(iDevice);
// 创建位图设备的绘图上下文
CFbsBitGc * gc = NULL;
User: eaveIfError(iDevice->CreateContext(gc));
CleanupStack: ushL(gc);
// SetGc()函数所使用的绘图上下文必须是指向窗口的,因此,必须对gc做一下映射(mapping)
CWindowToBitmapMappingGc *wbgc = CWindowToBitmapMappingGc::NewL(*iScreenDevice,*gc) ;
CleanupStack: ushL(wbgc);
// 这个是自己定义的函数,对每个控件以及它的所有子控件设置GC
SetGc(iScreen,wbgc);
// 调用重绘,此时,控件绘制到了位图上
iScreen->DrawNow();
// 绘制完之后,设置回原来的GC
SetGc(iScreen,NULL);
CleanupStack: opAndDestroy(wbgc);
CleanupStack: opAndDestroy(gc);
CleanupStack::PopAndDestroy(iDevice);
CleanupStack::Pop(iBitmap);
}
/**
* 为每一控件以及它的所有子控件重新设置gc
*/
void SetGc(CCoeControl * iControl,CWindowToBitmapMappingGc* wsgc){
iControl ->SetGc(wsgc);
TInt count = iControl->CountComponentControls();
if(count == 0){
return;
}
for(TInt index = 0; index < count; ++index){
SetGc(iControl->ComponentControl(index),wsgc);
}
}
/**
* 将一个界面绘制到位图上
*/
void DrowScreenInBitmap(CCoeControl* iScreen,CFbsBitmap * iBitmap){
CleanupStack::PushL(iBitmap);
// 获得屏幕设备
CWsScreenDevice * iScreenDevice = CEikonEnv::Static()->ScreenDevice();
//建立位图设备
CFbsBitmapDevice * iDevice = CFbsBitmapDevice::NewL(iBitmap);
CleanupStack::PushL(iDevice);
// 创建位图设备的绘图上下文
CFbsBitGc * gc = NULL;
User: eaveIfError(iDevice->CreateContext(gc));
更多精彩
赞助商链接