Android截屏(fb0)
来源:互联网 发布:sql随机生成6位数字 编辑:程序博客网 时间:2024/05/22 06:58
1.申请获取root权限,这一步很重要,不然会没有作用
private void getPermession() { try { Process process = Runtime.getRuntime().exec("su"); // 获取输出流 OutputStream outputStream = process.getOutputStream(); DataOutputStream dataOutputStream = new DataOutputStream(outputStream); String cmd = "su \nchmod 777 /dev/graphics/fb0 \n"; dataOutputStream.writeBytes(cmd); dataOutputStream.flush(); dataOutputStream.close(); outputStream.close(); } catch (IOException e) { e.printStackTrace(); }}
2.手机分辨率
private void getPhoneProfile() { DisplayMetrics dm = new DisplayMetrics(); Display display = this.getWindowManager().getDefaultDisplay(); display.getMetrics(dm); screenWidth = dm.widthPixels; // 屏幕宽(像素,如:480px) screenHeight = dm.heightPixels; // 屏幕高(像素,如:800p) int pixelformat = display.getPixelFormat(); PixelFormat localPixelFormat1 = new PixelFormat(); PixelFormat.getPixelFormatInfo(pixelformat, localPixelFormat1); deepth = localPixelFormat1.bytesPerPixel;// 位深 Log.e(TAG, "getFB0: "+ deepth); piex = new byte[screenHeight * screenWidth*deepth] ;// 像素 colors = new int[screenHeight * screenWidth];}
3.读取文件内容
private Bitmap getFB0() { Bitmap bitmap = null; try { FileInputStream buf = null; fbFile = new File(FB0FILE1); buf = new FileInputStream(fbFile);// 读取文件内容 dStream=new DataInputStream(buf); dStream.readFully(piex); dStream.close(); // 将rgb转为色值,解析fb0 for (int m = 0; m < colors.length; m++) { int b = (piex[m * 4] & 0xFF); int g = (piex[m * 4 + 1] & 0xFF); int r = (piex[m * 4 + 2] & 0xFF); int a = (piex[m * 4 + 3] & 0xFF); colors[m] = (a << 24) + (r << 16) + (g << 8) + b; if (m < 10) { Log.e(TAG, "getFB0: " + piex[m * 4]); Log.e(TAG, "getFB0: " + piex[m * 4+ 1]); Log.e(TAG, "getFB0: " + piex[m * 4+ 2]); Log.e(TAG, "getFB0: " + piex[m * 4+ 3]); Log.e(TAG, "getFB0: " + b); Log.e(TAG, "getFB0: " + g); Log.e(TAG, "getFB0: " + r); Log.e(TAG, "getFB0: " + a); } } // 得到屏幕bitmap bitmap = Bitmap.createBitmap(colors, screenWidth, screenHeight, Bitmap.Config.RGB_565); } catch (IOException e) { e.printStackTrace(); } return bitmap;}
4.保存截图
public static void savePic(Bitmap b,String strFileName){ FileOutputStream fos = null; try { fos = new FileOutputStream(strFileName); if (null != fos) { b.compress(Bitmap.CompressFormat.PNG, 50, fos); fos.flush(); fos.close(); } } catch (FileNotFoundException e) { } catch (IOException e) { }}
遗留问题
fdb0解析成bitmap不满足需求,需要对手机的系统配置分析之后对应解析fdb0
0 0
- Android截屏(fb0)
- Android fb0 截屏实现
- Android 截屏(只需要引用jar包,需要root),利用/dev/graphics/fb0命令行实现
- 整理:android 读取 屏幕 图形 fb0
- Android读取/dev/graphics/fb0 屏幕截图
- (frame buffer -> fb0)屏幕设备内存映射操作(1)
- (frame buffer -> fb0)屏幕设备内存映射操作(2)
- (frame buffer -> fb0)屏幕设备内存映射操作(3)
- android上用C语言读取fb0实现截屏,并保存为rgb565的bmp
- android通过读取/dev/graphics/fb0文件解析出系统界面的图片
- android上用C语言读取fb0实现截屏,并保存为rgb565的bmp .
- Android平台截图研究 FrameBuffer(/dev/graphics/fb0) 文件内容研究!(含源码工程)
- android上用C语言读取fb0实现截屏,并保存为rgb565的bmp
- android_系统provider/文件描述符/H264/openGl/读取fb0截屏
- /dev/fb0入门练习
- fb0初始化和设置
- /dev/fb0入门练习
- Android平台截图研究 FrameBuffer(/dev/graphics/fb0) 文件内容研究!(含源码工程)
- VirtualApp出现无法编译问题整理
- Implement Stack using Queues
- 欢迎使用CSDN-markdown编辑器
- sspanel按月结算,修改go版代码【mysql api】
- Small Game
- Android截屏(fb0)
- 支持向量分类机---乳腺癌的诊断
- CSU - 1161 Sums
- NOIP2012 提高组 复赛 day1 game
- JVM——自定义类加载器
- 在Centos搭建Django测试环境
- 移动WEB开发框架
- C#入门10.2——接口的实现和继承(1)
- Python爬虫实战之爬取糗事百科段子