安装在Android机器上的截图程序实现,需要root

来源:互联网 发布:诺基亚c1软件下载 编辑:程序博客网 时间:2024/04/28 21:21


原文:http://blog.csdn.net/ericahdu/article/details/5790055

首先声明这边搞出来的不是jpg也不是png,是rgb16文件,有很多工具可以直接打开看到图片的,大家也可以自己写个程序把它转成图片

 

其实/dev/graphics/fb0文件就是rgb16文件,如果你有busybox,那么直接用process调用shell把它copy出来就行了,没必要往下看,如果没有,那么我这边提供了一个解决办法:

 

用cat命令读取fb0文件

[java] view plaincopy
  1. Process p = Runtime.getRuntime().exec("cat /dev/graphics/fb0");  
 

然后提取它的返回值

[java] view plaincopy
  1. InputStream inputStream = p.getInputStream();  
 

把返回的inputStream保存成文件,用下面这个函数

 

[java] view plaincopy
  1. public boolean copy(InputStream is, String fileTo) {    
  2.      try {    
  3.          InputStream in = is;    
  4.          FileOutputStream out = new FileOutputStream(fileTo);    
  5.          byte[] bt = new byte[1024];    
  6.          int count;    
  7.          while ((count = in.read(bt)) > 0) {    
  8.              out.write(bt, 0, count);    
  9.          }    
  10.          in.close();    
  11.          out.close();    
  12.          return true;    
  13.      } catch (IOException ex) {    
  14.          return false;    
  15.      }    
  16.  }  
 

这样就能把fb0文件拷贝出来了,你自己再写个rgb16到jpg的转换就可以了,有了root,其实很简单,^_^

0 0