⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 symbian编程总结-图形图像篇-使用双缓存进行图形的绘制 - 技术应用 - 豆豆网.htm

📁 Symbian编程总结-图形图像篇-使用双缓存进行图形的绘制
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0050)http://tech.ddvip.com/2008-12/122844828397613.html -->
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>Symbian编程总结-图形图像篇-使用双缓存进行图形的绘制 - 技术应用 - 豆豆网</TITLE><!-- 本模板由 legmail 最后于 2007-09-19 10:36 修改 -->
<META http-equiv=Content-Type content="text/html; charset=gb2312"><LINK 
href="Symbian编程总结-图形图像篇-使用双缓存进行图形的绘制 - 技术应用 - 豆豆网_files/tech_content_new.css" 
type=text/css rel=stylesheet>
<STYLE>#legv2-21 {
	WIDTH: 45px
}
#legv2-22 {
	WIDTH: 47px
}
#legv2-25 {
	WIDTH: 74px
}
#legv2-30 {
	WIDTH: 33px
}
#legv2-16 {
	BACKGROUND: none transparent scroll repeat 0% 0%; WIDTH: 43px; TEXT-INDENT: 0px
}
.legv2 LI {
	PADDING-RIGHT: 4px; PADDING-LEFT: 0px; BACKGROUND: url(/images/index/ddvip_i_ws_010.gif) no-repeat right 8px; FLOAT: left; PADDING-BOTTOM: 0px; OVERFLOW: hidden; COLOR: #556b96; LINE-HEIGHT: 27px; PADDING-TOP: 0px; HEIGHT: 27px; TEXT-ALIGN: center
}
</STYLE>

<SCRIPT><!--document.domain = 'ddvip.com';var node = 'tech';var subid = "2008-12-05_97613";--></SCRIPT>

<META content="MSHTML 6.00.3790.4426" name=GENERATOR></HEAD>
<BODY>
<DIV id=main><!-- 页面头部 -->
<DIV class=header>
<DIV class=top_nav><A href="http://news.ddvip.com/index.html">资讯</A>| <A 
href="http://tech.ddvip.com/os/index.html">操作系统</A>| <A 
href="http://tech.ddvip.com/program/index.html">编程</A>| <A 
href="http://tech.ddvip.com/pic/index.html">平面</A>| <A 
href="http://tech.ddvip.com/mediamovice/index.html">动画</A>| <A 
href="http://tech.ddvip.com/network/index.html">网络</A>| <A 
href="http://tech.ddvip.com/safe/index.html">安全</A>| <A 
href="http://tech.ddvip.com/comm/index.html">通信</A>| <A 
href="http://tech.ddvip.com/cert/index.html">认证</A>| <A 
href="http://tech.ddvip.com/office/index.html">办公</A>| <A 
href="http://tech.ddvip.com/server/index.html"><FONT 
color=#ff0000>服务器</FONT></A>| <A 
href="http://tech.ddvip.com/db/index.html">数据库</A>| <A 
href="http://tech.ddvip.com/ent/index.html">企业应用</A>| <A 
href="http://tech.ddvip.com/soft/index.html">软件应用</A>| <A 
href="http://tech.ddvip.com/server/datasave/index.html">存储</A>| <A 
href="http://tech.ddvip.com/machine/index.html">电子机械</A>| <A 
href="http://tech.ddvip.com/chatsoft/qq.html">QQ</A>| <A 
href="http://tech.ddvip.com/soa/index.html">SOA</A> </DIV>
<DIV class=sitelogo><IMG alt=网站LOGO 
src="Symbian编程总结-图形图像篇-使用双缓存进行图形的绘制 - 技术应用 - 豆豆网_files/logo.gif"> 
<DIV class=top_ad_580x60 id=top_ad_580x60></DIV></DIV>
<DIV class=clear></DIV>
<DIV class=c_nav>
<UL class=legv2>
  <LI id=legv2-21><A 
  href="http://tech.ddvip.com/os/winvista/index.html"><STRONG>Vista</STRONG></A> 
  </LI>
  <LI id=legv2-22><A href="http://tech.ddvip.com/os/winxp/index.html">WinXP</A> 
  </LI>
  <LI id=legv2-01><A 
  href="http://tech.ddvip.com/os/windows_server/2008/index.html"><STRONG>Win2008</STRONG></A> 
  </LI>
  <LI id=legv2-02><A 
  href="http://tech.ddvip.com/os/win2003/index.html">Win2003</A> </LI>
  <LI id=legv2-25><A 
  href="http://tech.ddvip.com/os/windows_server/2000/index.html">Win2000/NT</A> 
  </LI>
  <LI id=legv2-30><A 
  href="http://tech.ddvip.com/os/windows7/index.html"><STRONG>Win7</STRONG></A> 
  </LI>
  <LI id=legv2-25><A href="http://tech.ddvip.com/linux/index.html">Linux 
  Unix</A> </LI>
  <LI id=legv2-21><A 
  href="http://tech.ddvip.com/linux/ubuntu/index.html"><STRONG>Ubuntu</STRONG></A> 
  </LI>
  <LI id=legv2-07><A href="http://tech.ddvip.com/freebsd/index.html">FreeBSD</A> 
  </LI>
  <LI id=legv2-30><A href="http://tech.ddvip.com/unix/mac/index.html">Mac</A> 
  </LI>
  <LI id=legv2-03><A 
  href="http://tech.ddvip.com/solaris/index.html"><STRONG>Solaris</STRONG></A> 
  </LI>
  <LI id=legv2-30><A 
  href="http://tech.ddvip.com/unix/aix/index.html"><STRONG>AIX</STRONG></A> 
</LI>
  <LI id=legv2-07><A 
  href="http://tech.ddvip.com/ostheory/vmware/index.html">Vmware</A> </LI>
  <LI id=legv2-16><A href="http://tech.ddvip.com/os/mobile/index.html">手机</A> 
  </LI></UL></DIV></DIV>
<DIV class=tlad id=tech_content_tl></DIV><!-- 内容部分 -->
<DIV class=content>
<DIV class=location><A href="http://www.ddvip.com/" target=_balnk>豆豆网</A> &gt; 
<A href="http://tech.ddvip.com/">技术应用</A> &gt; <A 
href="http://tech.ddvip.com/os/index.html">操作系统</A> &gt; <A 
href="http://tech.ddvip.com/os/mobile/index.html">手机操作系统</A> &gt; <A 
href="http://tech.ddvip.com/os/mobile/symbian/index.html">Symbian OS</A> &gt; 正文 
</DIV>
<DIV class=content_left>
<DIV class=article>
<DIV class=article_title>
<H1>Symbian编程总结-图形图像篇-使用双缓存进行图形的绘制</H1>
<DIV class=title_bottom>
<SCRIPT language=javascript 
src="Symbian编程总结-图形图像篇-使用双缓存进行图形的绘制 - 技术应用 - 豆豆网_files/title_bottom.js"></SCRIPT>
</DIV>
<P><A 
href="http://tech.ddvip.com/">http://tech.ddvip.com/</A>&nbsp;&nbsp;&nbsp;2008年12月05日 
&nbsp;&nbsp;&nbsp;<A href="http://bbs.ddvip.com/">社区交流</A></P></DIV>
<DIV class=article_content>
<DIV class=title_bottom_cpr>
<SCRIPT 
src="Symbian编程总结-图形图像篇-使用双缓存进行图形的绘制 - 技术应用 - 豆豆网_files/ad_title_bottom.js"></SCRIPT>
</DIV><!--ID="929"-->
<DIV class=searchhot>关键字: <A href="http://tech.ddvip.com/search.php?key=" 
target=_blank></A><A href="http://tech.ddvip.com/search.php?key=代码" 
target=_blank>代码</A> <A href="http://tech.ddvip.com/search.php?key=格式化" 
target=_blank>格式化</A> <A href="http://tech.ddvip.com/search.php?key=symbian入门" 
target=_blank>symbian入门</A> <A 
href="http://tech.ddvip.com/search.php?key=Symbian游戏编程" 
target=_blank>Symbian游戏编程</A> <A 
href="http://tech.ddvip.com/search.php?key=Nokia S60" target=_blank>Nokia 
S60</A> </DIV>
<DIV class=article_z>
<H2>Symbian编程总结-图形图像篇-使用双缓存进行图形的绘制。 </H2></DIV>
<DIV class=article_ad>
<SCRIPT language=javascript 
src="Symbian编程总结-图形图像篇-使用双缓存进行图形的绘制 - 技术应用 - 豆豆网_files/ads_250x250.js"></SCRIPT>
</DIV>
<DIV id=clickeye_content>
<DIV class=article_c id=fontsize>
<P>  <A 
href="http://file.ddvip.com/2008_12/1228448221_ddvip_3779.rar">本文示例源代码或素材下载</A></P>
<P>  所谓“双缓冲”,指的是在绘图时并不是直接绘到屏幕上,而是在内存中开辟一个缓冲区,在这个缓冲区里完成所有的绘图后,直接将其“粘贴”到屏幕上。采用双缓冲技术,由于绘图操作大部分在内存中完成,所以绘图速度没有太大的制约;此外,当进行复杂的绘图操作时,使用双缓冲技术可以有效的防止画面的闪烁。 
</P>
<P>  一、双缓存技术在J2ME中的实现 </P>
<P>  在J2ME中,实现双缓存绘制图形可以通过以下步骤实现: </P>
<P>  首先创建一个类成员变量Image对象,此Image对象的图像尺寸为屏幕尺寸大小。</P>
<P>  如:如果屏幕大小为240*320,则使用以下代码创建: 
<P><CODE>private Image img;<BR>img = Image.createImage(240, 320);</CODE></P>
<P>  创建一个类成员变量Graphics对象,此Graphics对象指向img的Graphics对象: 
<P><CODE>private Graphics g;<BR>g = img.getGraphics();</CODE></P>
<P>  以上img对象即为内存中的缓冲区,可以使用任何方法在类成员g上绘制任意的图像,而不用在canvas的repaint事件中处理复杂的绘制过程。 </P>
<P>  在canvas的repaint方法,将缓冲区图像绘制在屏幕的gc上: 
<P><CODE>protected void paint(Graphics g) {<BR>g.drawImage(img, 0, 0, 
Graphics.LEFT | Graphics.TOP);<BR>}</CODE></P>
<P>  以上就在J2ME中完成了简单的的双缓存的实现。 </P>
<P>  二、双缓存技术在Symbian中的实现 </P>
<P>  在Symbian中实现双缓冲技术有两种方法,我们先从简单的方法入手: </P>
<P>  第一种方法的实现更贴近于在J2ME中的实现。在此方法中,也得先在内存中建立一个位图缓冲区对象,然后再获取位图对象的设备上下文 dc(Device 
Context)(类似于J2ME中的Graphics),程序可以在任意的地方对内存缓冲位图的dc绘制图形。在Draw事件(相当于J2ME的 
paint事件)内,将缓冲区位图直接绘制在设备的dc上。</P>
<P>  首先在头文件中加入如下定义: 
<P><CODE>CWsBitmap* iBufBmp;<BR>CFbsBitmapDevice* iBufDevice;<BR>CBitmapContext* 
iBufGc;</CODE></P>
<P>  1) 
iBufBmp为缓冲区位图对象,为CWsBitmap类型。类CWsBitmap继承自类CFbsBitmap,我们在此使用CWsBitmap的原因为因为它比较快,引入SDK中对CWsBitmap类的说明: 
</P>
<P>  This is a bitmap to which the window server already has a handle. 
Functions</P>
<P>  which take a window server bitmap are faster than equivalent functions 
which</P>
<P>  take a CFbsBitmap. </P>
<P>  2) 
iBufDevice为CFbsBitmapDevice类型的对象,CFbsBitmapDevice的官方解释可以简单的理解为管理文字和位图的图形设备:</P>
<P>  A graphics device to which a bitmap managed by the font and bitmap server 
can be drawn. </P>
<P>  3) 
iBufGc为CBitmapContext类型的对象,即位图对象的设备上下文dc,获取了iBufGc后,可以使用CBitmapContext中的方法对位图进行绘制。 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -