📄 在j2me-midp中实现图像旋转-开发者网络-j2me-天极yesky.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0038)http://dev.yesky.com/221/2504221.shtml -->
<HTML lang=zh-CN xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>在J2ME/MIDP中实现图像旋转-开发者网络-J2ME-天极Yesky</TITLE>
<META content=在J2ME/MIDP中实现图像旋转, name=description>
<META content=在J2ME/MIDP中实现图像旋转, name=keywords>
<META content="天极Yesky | 全球中文IT第一门户" name=author>
<META content="天极Yesky | 全球中文IT第一门户" name=Copyright>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META http-equiv=Content-Language content=zh-CN><LINK media=all
href="在J2ME-MIDP中实现图像旋转-开发者网络-J2ME-天极Yesky.files/y_mobile_content.css"
type=text/css rel=stylesheet>
<SCRIPT src="在J2ME-MIDP中实现图像旋转-开发者网络-J2ME-天极Yesky.files/showlay.js"></SCRIPT>
<META content="MSHTML 6.00.2900.3132" name=GENERATOR></HEAD>
<BODY><!--页面头部--><!--头部-->
<DIV id=topmenu><A href="http://www.yesky.com/">Yesky首页</A>| <A
href="http://product.yesky.com/">产品报价</A>| <A
href="http://cseek.yesky.com/">行情</A>| <A href="http://mobile.yesky.com/">手机</A>
| <A href="http://digital.yesky.com/">数码</A> | <A
href="http://notebook.yesky.com/">笔记本</A> | <A
href="http://pc.yesky.com/">台式机</A> | <A href="http://diy.yesky.com/">DIY硬件</A>
| <A href="http://oa.yesky.com/">外设</A> | <A href="http://net.yesky.com/">网络</A>
| <A href="http://dh.yesky.com/">数字家庭</A> | <A
href="http://lab.yesky.com/">评测</A> | <A href="http://soft.yesky.com/">软件</A> |
<A href="http://e.yesky.com/">e时代</A> | <A href="http://game.yesky.com/">游戏</A>
| <A href="http://pic.yesky.com/">图片</A> | <A
href="http://desktop.yesky.com/">壁纸</A> | <A href="http://q.yesky.com/">群乐</A> |
<A href="http://my.yesky.com/">社区</A> | <A href="http://blog.yesky.com/">博客</A>
| <A href="http://www.mydown.com/">下载</A></DIV>
<DIV id=topbox>
<DIV class=tleft><A href="http://www.yesky.com/"><IMG alt=天极Yesky_全球中文IT第一门户
src="在J2ME-MIDP中实现图像旋转-开发者网络-J2ME-天极Yesky.files/logo.gif" border=0></A></DIV>
<DIV class=tad><SPAN id=ad1></SPAN></DIV>
<DIV id=search>
<DIV>
<FORM name=searchform action=http://search.chinabyte.com/search method=get
target=_blank><INPUT id=searchzz onmouseover=this.focus() onfocus=this.select()
name=q><INPUT type=hidden value=GB2312 name=encoding><INPUT type=hidden
value=connect name=dir><INPUT type=hidden value=20002 name=cid><INPUT id=search_btn type=submit value=天极搜索> </FORM></DIV>
<DIV class=tdq>
<DIV class=rightarea><A href="http://bj.yesky.com/">北京</A> <A
href="http://hd.yesky.com/">上海</A> <A href="http://gd.yesky.com/">广东</A> <A
href="http://xa.yesky.com/">西安</A><BR><A href="http://cq.yesky.com/">重庆</A> <A
href="http://cd.yesky.com/">成都</A> <A href="http://sy.yesky.com/">沈阳</A> <A
href="http://js.yesky.com/">江苏</A> </DIV>
<DIV class=rightarea_right><A
href="http://my.yesky.com/">用户<BR>登录</A></DIV></DIV></DIV>
<DIV class=tright>
<DIV class=box1>
<SCRIPT src="在J2ME-MIDP中实现图像旋转-开发者网络-J2ME-天极Yesky.files/content_text_ad.js"
type=text/javascript></SCRIPT>
</DIV></DIV></DIV>
<SCRIPT src="在J2ME-MIDP中实现图像旋转-开发者网络-J2ME-天极Yesky.files/flash.js"
type=text/javascript></SCRIPT>
<DIV id=childmenu><A href="http://soft.yesky.com/">软件频道></A><A
href="http://dev.yesky.com/">程序开发></A><A
href="http://dev.yesky.com/devjava/">Java</A><A
href="http://dev.yesky.com/ysdevvb">VB</A><A
href="http://dev.yesky.com/ysdevvc">VC</A><A
href="http://dev.yesky.com/ysdevdelphi">Delphi</A><A
href="http://dev.yesky.com/ysdevc">C/C++</A><A
href="http://dev.yesky.com/web/">Web开发</A><A
href="http://dev.yesky.com/msdn/">微软专栏</A><A
href="http://dev.yesky.com/devydkf/">移动</A><A
href="http://dev.yesky.com/devsjk/">数据库</A><A
href="http://dev.yesky.com/ysdevcxrs">程序人生</A><A
href="http://dev.yesky.com/ysdevrjgc">软件工程</A>|<A
href="http://soft.yesky.com/lesson/">产品中心</A><A
href="http://www.mydown.com/soft/develop/news.shtml">下载</A><A
href="http://q.yesky.com/group/179"><FONT
color=#ff0000>群乐:大家耍QQ</FONT></A></DIV><!--导航条-->
<DIV id=location>
<DIV class=loleft>您现在的位置: <A href="http://www.yesky.com/">天极Yesky</A> > <A
href="http://soft.yesky.com/">软件频道</A> > <A
href="http://dev.yesky.com/">开发者网络</A> > 在J2ME/MIDP中实现图像旋转</DIV>
<DIV class=adright><SPAN id=ad2></SPAN></DIV></DIV><!--内容块开始-->
<DIV id=conbox><!--左边开始-->
<DIV id=conleft>
<DIV id=contopla1>
<DIV id=__001>
<DIV class=qkong></DIV>
<DIV class=qw1>全文</DIV>
<DIV class=zkong>
<DIV class=kl></DIV>
<DIV class=bj><A href="http://dev.yesky.com/221/2504221.shtml#pls"
target=_self>评论</A></DIV>
<DIV class=kr></DIV>
<SCRIPT type=text/javascript>
var titiepic ="#";
if (titiepic!="#")
{
document.write("<div class=\"kl\"></div><div class=\"bj\"><a href=\"#\" target=\"_blank\">图片</a></div><div class=\"kr\"></div>");
}
</SCRIPT>
</DIV></DIV></DIV>
<DIV class=topadbg><SPAN id=ad10></SPAN></DIV><A name=top></A>
<DIV id=contitle>
<H1>在J2ME/MIDP中实现图像旋转</H1></DIV>
<DIV id=conauthor><SPAN>2006-07-27 07:00 </SPAN><SPAN>作者: 王伟 李春雷
</SPAN><SPAN>出处: 计算机与信息技术 </SPAN><SPAN>责任编辑:<A title=向本编辑提问
href="http://comments.yesky.com/t/·½ÖÛ/6,324/2504221.shtml" target=_blank>方舟</A>
</SPAN></DIV>
<DIV class=topadbg><SPAN id=ad9></SPAN></DIV>
<DIV id=conneirong><SPAN id=ad3></SPAN>
<DIV class=guanggao><SPAN id=contentAdv></SPAN></DIV> <B>摘 要</B>
图形图像的旋转在移动应用程序开发,特别是游戏开发过程中有着现实的需求。但J2ME对此提供的支持却十分有限,如MIDP2.0仅支持图像成90度整数倍的旋转。针对这种情况,
本文提出了一种实现图像任意角度旋转的方案并提供了算法实现。然后对算法的应用问题进行了探讨,分析了算法的局限性。最后介绍了在j2me中实现旋转的另外两种参考性方案。<BR><BR> <B>关键词</B>
J2ME;CLDC;MIDP;Sprite;图像旋转<BR><BR> <B>J2ME概述</B><BR><BR> J2ME是标准版java(J2SE)面向手机、PDA等各类移动和嵌入式设备的缩减版本,是一种获得众多厂商的支持和广泛使用的移动设备开发平台。图一展示了J2ME技术的体系结构。它分为三层:虚拟机层,配置层,和简表层。<BR><BR> 配置层(Configuration)通过对功能的描述,把千差万别的嵌入式设备进行了功能的说明和分类。它把运算功能有限、内存较小、电力有限的设备,定义在CLDC(有限连接设备配置)规范中,这类设备有PDA
、手机等;把运算能力相对较佳、内存相对较大、电力供应比较充足的设备,定义在CDC(连接设备配置)规范之中,这类设备有电<A class=bluekey
href="http://product.yesky.com/catalog/5381/"
target=_blank>冰箱</A>、机顶盒、车载计算设备等。<BR><BR> 虚拟机层(Virtual
Machine)基于宿主操作系统,按照某一种配置,实现了Java虚拟机。CDC配置对应的虚拟机叫CVM,CLDC对应的虚拟机叫做KVM。<BR><BR> 简表层(Profile)建立在配置层之上,提供了面向用户的更高层次的功能,如用户接口,网络,数据存储等。基础规范(Foundation
Profile)和个人规范(Personal
Profile)是CDC之上的两个重要的规范,移动信息设备规范(MIDP)和PDA规范(PDAP)是CLDC之上的两个重要的规范。当前,无线应用程序的开发主要是在MIDP之上进行的。<BR><BR> 配置层和简表层共同构成了J2ME的运行环境。如CLDC/MIDP架构构筑了手机应用程序的开发和运行环境。本文所实现的图像旋转算法便是基于这种架构的。<BR><BR>
<TABLE width="90%" align=center>
<TBODY>
<TR>
<TD>
<DIV align=center><IMG
src="在J2ME-MIDP中实现图像旋转-开发者网络-J2ME-天极Yesky.files/d96bcn6927v5.jpg"
border=0>e <BR>图一 J2ME
体系结构</DIV></TD></TR></TBODY></TABLE><BR> 需要注意的是,这些规范也是在不断发展的。如早期很多的设备的计算能力非常有限,CLDC1.0就只支持整型数值。后来数随着设备运算能力的提高,CLDC1.0发展到CLDC1.1,就加如了对浮点运算的支持。对MIDP规范也一样,从1.0发展到2.0,它通过扩充类和接口的功能,加强了对游戏开发的支持,增加了图像处理功能(旋转要用到),增强了对网络功能的支持,如串口、套接字、https等。<BR><BR> <B>2D旋转的数据基础</B><BR><BR> 考虑笛卡儿直角坐标系中单个点旋转的情况。如图二示,这里点P(x,y)到原点O绕O点逆时针旋转角度θ后到点P′(x′,y′)。由三角函数的几何意义,有x
= r*cos α ,y = r*si n α和x′ = r*cos(α +θ) , y′ = r*sin(α + θ),推出:<BR><BR>
<TABLE borderColor=#cccccc width="90%" align=center bgColor=#e7e9e9 border=1>
<TBODY>
<TR>
<TD>x′ = x * cos θ – y * sin θ<BR>y′ = y * cos θ + x * sin
θ</TD></TR></TBODY></TABLE><BR> 当把旋转点一般化为Q(x0,y0),得到:<BR><BR>
<TABLE borderColor=#cccccc width="90%" align=center bgColor=#e7e9e9 border=1>
<TBODY>
<TR>
<TD>x′ = x0 + (x - x0) cos θ - (y - y0) sin θ <BR>y′ = y0 + (y - y0) cos θ
+ (x - x0) sin θ
</TD></TR></TBODY></TABLE><BR> 在开发时,我们使用设备坐标系,它以屏幕的左上角为坐标原点,y轴方向向下。此时,我们不妨视θ为饶旋转点顺时针旋转的角度,这样,上面的公式依然成立。
<BR><BR>
<TABLE width="90%" align=center>
<TBODY>
<TR>
<TD>
<DIV align=center><IMG
src="在J2ME-MIDP中实现图像旋转-开发者网络-J2ME-天极Yesky.files/75b689v5vi89.jpg"
border=0><BR>图二 2D点的旋转</DIV></TD></TR></TBODY></TABLE><BR>
<DIV id=numpage>共3页。 <A href="http://dev.yesky.com/221/2504221.shtml"
target=_self><SPAN>1</SPAN></A> <A
href="http://dev.yesky.com/221/2504221_1.shtml" target=_self>2</A> <A
href="http://dev.yesky.com/221/2504221_2.shtml" target=_self>3</A> <A
href="http://dev.yesky.com/221/2504221_2.shtml" target=_self><FONT
face=Webdings>:</FONT></A></DIV></DIV><!--广告代码开始-->
<SCRIPT>
var ad_cid;
if (window.location.search.substring(1) != "")
{
ad_cid = window.location.search.substring(1);
} else {
ad_cid = 412;
}
</SCRIPT>
<!--小通栏:c-scolumn顶部500*90--><SPAN id=span_ad1>
<SCRIPT language=JavaScript>
document.write("<script src=\"http://vd.yesky.com/html/"+ad_cid+"/"+ad_cid+"_c-scolumn.js\"><\/script>");</SCRIPT>
</SPAN>
<SCRIPT language=JavaScript>
document.getElementById("ad1").innerHTML=document.getElementById("span_ad1").innerHTML;
document.getElementById("span_ad1").innerHTML="";
</SCRIPT>
<!--c-pip文章正文中间240*200--><SPAN id=span_ad3>
<SCRIPT language=JavaScript>
document.write("<script src=\"http://vd.yesky.com/html/"+ad_cid+"/"+ad_cid+"_c-pip.js\"><\/script>");</SCRIPT>
</SPAN>
<SCRIPT>
if(document.getElementById("contentAdv")) {
document.getElementById("contentAdv").innerHTML=document.getElementById("span_ad3").innerHTML;
document.getElementById("span_ad3").innerHTML="";
} else {
document.getElementById("ad3").innerHTML=document.getElementById("span_ad3").innerHTML;
document.getElementById("span_ad3").innerHTML="";
}</SCRIPT>
<!--c-text-1“您现在的位置”右侧文字--><SPAN id=span_ad2>
<SCRIPT language=JavaScript>
document.write("<script src=\"http://vd.yesky.com/html/"+ad_cid+"/"+ad_cid+"_c-text-1.js\"><\/script>");</SCRIPT>
</SPAN>
<SCRIPT language=JavaScript>
document.getElementById("ad2").innerHTML=document.getElementById("span_ad2").innerHTML;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -