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

📄 j2me中使用缓存将屏幕内容存储为image-软件-j2me-天极yesky.htm

📁 j2me的一些东西。有用的东东
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<!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://soft.yesky.com/21/2433021.shtml -->
<HTML lang=zh-CN xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>J2ME中使用缓存将屏幕内容存储为Image-软件-J2ME-天极Yesky</TITLE>
<META content=J2ME中使用缓存将屏幕内容存储为Image, name=description>
<META content=J2ME中使用缓存将屏幕内容存储为Image, 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中使用缓存将屏幕内容存储为Image-软件-J2ME-天极Yesky.files/y_mobile_content.css" 
type=text/css rel=stylesheet>
<SCRIPT src="J2ME中使用缓存将屏幕内容存储为Image-软件-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中使用缓存将屏幕内容存储为Image-软件-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中使用缓存将屏幕内容存储为Image-软件-J2ME-天极Yesky.files/content_text_ad.js" 
type=text/javascript></SCRIPT>
</DIV></DIV></DIV>
<SCRIPT src="J2ME中使用缓存将屏幕内容存储为Image-软件-J2ME-天极Yesky.files/flash.js" 
type=text/javascript></SCRIPT>

<DIV id=childmenu><A href="http://soft.yesky.com/">软件频道&gt;</A><A 
href="http://design.yesky.com/">设计</A><A href="http://tools.yesky.com/">工具</A><A 
href="http://os.yesky.com/">系统</A><A href="http://dev.yesky.com/">开发</A><A 
href="http://soft.yesky.com/office/">办公</A><A 
href="http://homepage.yesky.com/">陶吧</A><A 
href="http://soft.yesky.com/security/">安全</A><A 
href="http://edu.yesky.com/">IT教育</A><A 
href="http://vista.yesky.com/">Vista频道</A>|<A 
href="http://soft.yesky.com/lesson/">软件频道产品中心</A><A 
href="http://q.yesky.com/group/search.do?cid=661">群乐</A><A 
href="http://www.mydown.com/soft/">软件下载</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> &gt; <A 
href="http://soft.yesky.com/">软件频道</A> &gt; J2ME中使用缓存将屏幕内容存储为Image</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://soft.yesky.com/21/2433021.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中使用缓存将屏幕内容存储为Image</H1></DIV>
<DIV id=conauthor><SPAN>2006-06-07 08:57 </SPAN><SPAN>作者: MINIJAVA 
</SPAN><SPAN>出处: J2ME开发网 </SPAN><SPAN>责任编辑:<A title=向本编辑提问 
href="http://comments.yesky.com/t/·&frac12;&Ouml;&Ucirc;/6,324/2433021.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>  本文介绍如何将手机屏幕的内容存储为Image对象,这里认为手机屏幕上显示的是一个Canvas。完成这一个功能的思想就是使用缓冲机制。我们不能直接获得Canvas上的像素,因此不能直接从Canvas上的内容获得Image对象。转换一下思路,如果把要绘制的Canvas上的内容首先绘制到一个Image上,而这个Image并不显示到屏幕上,只是在绘画完成后一次性的显示到屏幕上。有经验的朋友一定联想到了双缓冲机制,不过这里并不是要使用双缓冲解决闪屏的问题,而是要得到当前Canvas的内容。 
<BR><BR>  下面我们编写一个简单的Canvas类来测试一下这个想法,SimpleCanvas是Canvas的子类,为了保存Canvas的内容,我们创建一个Image,大小与Canvas的尺寸相当。<BR><BR>
<TABLE borderColor=#cccccc width="90%" align=center bgColor=#e3e3e3 border=1>
  <TBODY>
  <TR>
    <TD>class SimpleCanvas extends Canvas{<BR><BR> int w;<BR> int 
      h;<BR> private Image offImage = null;<BR> private boolean buffered = 
      true;<BR> public SimpleCanvas(boolean _buffered){<BR>  buffered = 
      _buffered;<BR>  w = getWidth();<BR>  h = 
      getHeight();<BR>  if(buffered)<BR>  offImage = 
      Image.createImage(w,h);<BR> }<BR> protected void paint(Graphics g) 
      {<BR><BR>  int color = 
      g.getColor();<BR>  g.setColor(0xFFFFFF);<BR>  g.fillRect(0,0,w,h);<BR>  g.setColor(color);<BR><BR>  Graphics 
      save = g;<BR>  if(offImage != null)<BR>   g = 
      offImage.getGraphics();<BR>   //draw the 
      offimage<BR>   g.setColor(128,128,0);<BR>   g.fillRoundRect((w-100)/2,(h-60)/2,100,60,5,3);<BR>   //draw 
      the offimage to the 
      canvas<BR>   save.drawImage(offImage,0,0,Graphics.TOP|Graphics.LEFT);<BR> }<BR><BR> public 
      Image printMe(){<BR>  return 
offImage;<BR> }<BR></TD></TR></TBODY></TABLE><BR>  可以看到paint()方法,并不是直接对Canvas操作,而是先把要画的内容绘制到一个Image上,然后再绘制到Canvas上。这样到你想抓取屏幕内容的时候就可以调用printMe()方法了,返回offImage。编写一个MIDlet测试一下这个效果。<BR><BR>
<TABLE borderColor=#cccccc width="90%" align=center bgColor=#e3e3e3 border=1>
  <TBODY>
  <TR>
    <TD>package com.j2medev;<BR><BR>import 
      javax.microedition.midlet.*;<BR>import 
      javax.microedition.lcdui.*;<BR><BR>/**<BR>*<BR>* @author mingjava<BR>* 
      @version<BR>*/<BR>public class PrintScreen extends MIDlet implements 
      CommandListener{<BR><BR> private Display display = null;<BR> private 
      SimpleCanvas canvas = new SimpleCanvas(true);<BR> private Command 
      printCommand = new Command("Print",Command.OK,1);<BR><BR> public void 
      startApp() {<BR>  if(display == null)<BR>   display = 
      Display.getDisplay(this);<BR>  canvas.addCommand(printCommand);<BR>  canvas.setCommandListener(this);<BR>  display.setCurrent(canvas);<BR> }<BR><BR> public 
      void pauseApp() {}<BR><BR> public void destroyApp(boolean unconditional) 
      {}<BR><BR> public void commandAction(Command command, Displayable 
      displayable) {<BR>  if(command == printCommand){<BR>   Form form = new 
      Form("screen");<BR>   form.append(canvas.printMe());<BR>   display.setCurrent(form);<BR>  }<BR> }<BR>}</TD></TR></TBODY></TABLE><BR>  运行PrintScreen,选择Print,即可把当前的屏幕显示到一个Form中。如下图所示:<BR><BR>
<TABLE width="90%" align=center border=0>
  <TBODY>
  <TR>
    <TD>
      <DIV align=center>
      <P><IMG onmousewheel="return bbimg(this)" height=221 
      src="J2ME中使用缓存将屏幕内容存储为Image-软件-J2ME-天极Yesky.files/e6ac951quug8.png" 
      width=176 onload=javascript:resizepic(this) 
  border=0></P></DIV></TD></TR></TBODY></TABLE><BR><A 
href="http://soft.yesky.com/lesson/237/2428237.shtml"><IMG alt=点击查看迅雷被封杀事件专题 
src="J2ME中使用缓存将屏幕内容存储为Image-软件-J2ME-天极Yesky.files/2n0m32x643a8.jpg" 
border=0></A> </DIV><!--广告代码开始-->
<SCRIPT>
var ad_cid;
if (window.location.search.substring(1) != "")
{
ad_cid = window.location.search.substring(1);
} else {
ad_cid = 324;
}
</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;
document.getElementById("span_ad2").innerHTML="";

⌨️ 快捷键说明

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