Symbian编程总结-图形图像篇-直接屏幕访问
2008-11-11 02:45
393 查看
本文章由杨芹勍原创,如需转摘请注明出处。谢谢!
在Symbian OS中绘制图形减少闪烁的方法有两种:
使用双缓存进行图形的绘制(点击这里进入相关文章)
使用CDirectScreenAccess类对屏幕进行直接绘制。
CDirectScreenAccess类在SDK种的解释如下:
Direct screen access is a way of drawing to the screen without using the window server. As this avoids client-server communication, it is much faster, and may be useful for games and video. Note that some interaction with the window server is needed in order to prevent the application from drawing over other application's data.
此外,使用CDirectScreenAccess还可以截获系统的通知消息(如菜单弹出、电话拨入、信息收到等)的对话框弹出事件,从而避免不必要的刷新工作。
一、CDirectScreenAccess的简单使用
CDirectScreenAccess使用起来非常简单,下面的几格步骤将介绍CDirectScreenAccess的使用方法:
在Carbide C++中使用向导生成GUI应用程序
在View类中创建成员变量CDirectScreenAccess* iDSA;
在View类中创建私有方法void DrawGraphics();代码如下:
void CTestDirectDrawAppView::DrawGraphics()
{
CFbsBitGc* gc = iDSA->Gc();
TRgb colorRed= AKN_LAF_COLOR(35);
gc->SetPenColor(colorRed);
gc->DrawRect(TRect(0, 0, 100, 100));
iDSA->ScreenDevice()->Update();
}
在View类的ConstructL方法里加入以下代码:
CEikonEnv* env = CEikonEnv::Static();
iDSA = CDirectScreenAccess::NewL(env->WsSession(), *(env->ScreenDevice()), this->Window(), *this);
iDSA->StartL();
DrawGraphics();
在View类中创建以下两个私有方法:
void Restart(RDirectScreenAccess::TTerminationReasons aReason);
void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
实现如下:
void CTestDirectDrawAppView::Restart(RDirectScreenAccess::TTerminationReasons aReason)
{
iDSA->StartL();
DrawGraphics();
}
void CTestDirectDrawAppView::AbortNow(RDirectScreenAccess::TTerminationReasons aReason)
{
iDSA->Cancel();
}
点击此处下载源代码
二、分析实现过程
1、普通的绘制过程
2、当有系统对话框通知时的绘制过程
在Symbian OS中绘制图形减少闪烁的方法有两种:
使用双缓存进行图形的绘制(点击这里进入相关文章)
使用CDirectScreenAccess类对屏幕进行直接绘制。
CDirectScreenAccess类在SDK种的解释如下:
Direct screen access is a way of drawing to the screen without using the window server. As this avoids client-server communication, it is much faster, and may be useful for games and video. Note that some interaction with the window server is needed in order to prevent the application from drawing over other application's data.
此外,使用CDirectScreenAccess还可以截获系统的通知消息(如菜单弹出、电话拨入、信息收到等)的对话框弹出事件,从而避免不必要的刷新工作。
一、CDirectScreenAccess的简单使用
CDirectScreenAccess使用起来非常简单,下面的几格步骤将介绍CDirectScreenAccess的使用方法:
在Carbide C++中使用向导生成GUI应用程序
在View类中创建成员变量CDirectScreenAccess* iDSA;
在View类中创建私有方法void DrawGraphics();代码如下:
void CTestDirectDrawAppView::DrawGraphics()
{
CFbsBitGc* gc = iDSA->Gc();
TRgb colorRed= AKN_LAF_COLOR(35);
gc->SetPenColor(colorRed);
gc->DrawRect(TRect(0, 0, 100, 100));
iDSA->ScreenDevice()->Update();
}
在View类的ConstructL方法里加入以下代码:
CEikonEnv* env = CEikonEnv::Static();
iDSA = CDirectScreenAccess::NewL(env->WsSession(), *(env->ScreenDevice()), this->Window(), *this);
iDSA->StartL();
DrawGraphics();
在View类中创建以下两个私有方法:
void Restart(RDirectScreenAccess::TTerminationReasons aReason);
void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
实现如下:
void CTestDirectDrawAppView::Restart(RDirectScreenAccess::TTerminationReasons aReason)
{
iDSA->StartL();
DrawGraphics();
}
void CTestDirectDrawAppView::AbortNow(RDirectScreenAccess::TTerminationReasons aReason)
{
iDSA->Cancel();
}
点击此处下载源代码
二、分析实现过程
1、普通的绘制过程
2、当有系统对话框通知时的绘制过程
相关文章推荐
- Symbian编程总结-图形图像篇-直接屏幕访问
- Symbian编程总结-图形图像篇-使用双缓存进行图形的绘制
- Symbian编程总结-图形图像篇-使用双缓存进行图形的绘制
- Symbian编程总结-图形图像篇-使用双缓存进行图形的绘制
- Symbian编程总结-图形图像篇-RPG地图绘制引擎
- Symbian编程总结-图形图像篇-打开非Bitmap类型的图像(转)
- Symbian编程总结-图形图像篇-打开非Bitmap类型的图像
- VB编程的一些小技巧 - vb直接访问dx7屏幕内存的例子
- Java编程思想——第六章 访问权限控制 学习总结
- Symbian编程总结-关键篇-活动对象正解(3)-活动对象的工作原理
- Symbian编程总结-基础篇-集合与缓冲区(1)-RArray和RPointerArray
- Symbian编程总结-基础篇-活动对象正解(3)-活动对象的工作原理
- Symbian编程总结-基础篇-活动对象正解(4)-异步函数的同步调用
- iOS 图形编程总结
- Symbian编程总结-网络与通信-套接字(1)-套接字体系结构与相关API
- Symbian编程总结-网络与通信-使用CEComFilter捕获系统HTTP请求
- Symbian http 编程总结
- VS2010/MFC编程入门之四十九(图形图像:CDC类及其屏幕绘图函数)
- 如何通过直接访问屏幕内存来直接绘制屏幕并更新
- Symbian编程总结-深入篇-瘦模板正解