关于android截图的一些方法
这里只记录一些链接,对于我的需求,只需要,
public static String createScreenShot(View v) { //测试截屏功能 SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd_HH-mm-ss",Locale.US); String dirPath=Mapplication.SDPATH+Constants.QZ_PATH; File dirFile=new File(dirPath); if(!dirFile.exists()) { dirFile.mkdir(); } String fname = Mapplication.SDPATH+Constants.QZ_PATH+sdf.format(new Date())+ ".png"; v.setDrawingCacheEnabled(true); v.buildDrawingCache(); Bitmap bitmap = v.getDrawingCache(); if(bitmap != null) { Bitmap bmpall=Bitmap.createBitmap(Mapplication.screen[0],CommonFun.dip2px(Mapplication.getContext(), 250),Config.ARGB_8888); Canvas canvas=new Canvas(bmpall); Bitmap bmp1 = BitmapFactory.decodeResource(Mapplication.getContext().getResources(),R.drawable.pb_score_bg); canvas.drawBitmap(bmp1,0,0,null);
canvas.drawBitmap(bitmap,0,0,null);
System.out.println("bitmap got!"); try{ FileOutputStream out = new FileOutputStream(fname); bmpall.compress(Bitmap.CompressFormat.PNG,100, out); System.out.println("file" + fname + "output done."); return fname; }catch(Exception e) { e.printStackTrace(); return ""; } }else{ System.out.println("bitmap s NULL!"); return ""; } }
用view getdrawingcache来截图(需求是只需要截特定的一部分),但是这样的图是没有背景的,所以 Canvas canvas=new Canvas(bmpall); Bitmap bmp1 = BitmapFactory.decodeResource(Mapplication.getContext().getResources(),R.drawable.pb_score_bg); canvas.drawBitmap(bmp1,0,0,null);
canvas.drawBitmap(bitmap,0,0,null); 是用canvas来绘制背景和图,,测试Ok
其他的截图文章:http://veikr.com/201202/android_screen_shot.html http://blog.csdn.net/jokers_i/article/details/39549633
http://blog.csdn.net/xu_fu/article/details/39268771 http://blog.csdn.net/woshinia/article/details/11520403
关于android截图的一些方法的更多相关文章
- 【转】 Android Studio SVN 使用方法
Android Studio SVN 使用方法 如何安装配置SVN 请直接参考<SVN在Android Studio中的配置> http://www.cnblogs.com/songmen ...
- Android截图命令screencap与视频录制命令screenrecord
Android截图命令screencap 查看帮助命令 bixiaopeng@bixiaopeng ~$ adb shell screencap -v screencap: invalid optio ...
- 【Android】一种提高Android应用进程存活率新方法
[Android]一种提高Android应用进程存活率新方法 SkySeraph Jun. 19st 2016 Email:skyseraph00@163.com 更多精彩请直接访问SkySeraph ...
- Android经典完美退出方法
Android经典完美退出方法,使用单例模式创建一个Activity管理对象,该对象中有一个Activity容器(具体实现自己处理,使用LinkedList等)专门负责存储新开启的每一个Activit ...
- Android获取系统时间方法的总结
Android获取系统时间方法的方法有很多种,常用的有Calendar.Date.currentTimeMills等方法. (1)Calendar Calendar获取系统时间首先要用Calendar ...
- 删除Android自带软件方法及adb remount 失败解决方案
删除Android自带软件方法 1.在电脑上打开cmd,然后输入命令 adb remount adb shell su 2.接着就是Linux命令行模式了,输入 cd system/app 3然后输入 ...
- PhoneGap 在 Android 上的插件开发方法介绍
移动应用开发已经成为软件开发的一个重要方向,但是移动开发面临的一个重要问题就是跨平台的问题.PhoneGap 作为一个多平台的软件开发框架,提供了一次编写多个平台的运行.目前已经支持多达 6 个移动平 ...
- Android之完美退出方法
为什么要写这篇文章? 网上有很多种退出方法,可实际上很多方法都不通用(在某个版本下可用,到了另一个版本就不行),或者方法的实际效果根本就和其描述不符(也不知道那些发帖的人测没测试过). 但我们的需求又 ...
- (转)Android之常用功能方法大集合
这些,都是Andorid中比较常用的方法和功能,在网上搜集整理一下记录之,以备不时之需.由于经过多次转载,源文作者不确凿,在此申明,敬请见谅.不得不赞,非常实用. 1.判断sd卡是否存在 boolea ...
随机推荐
- 架设lamp服务器后,发现未按照 Apache xsendfile模块,
今天在架设lamp服务器后,发现apache 未按照xsendfile模块,于是查找资料按照如下: 安装apache xsendfile模块yum install mod_xsendfile
- Install Debian note
environment: already install xp,win7 and win8PE, left 87G space to install Debian, this space not fo ...
- Search Insert Position
int searchInsert(int* nums, int numsSize, int target) { ; ); ; int mid; while(low<=high){ mid=(lo ...
- HackerRank-Longest Subarray
give an array and target value, find the max length of the subarray which sum of the elements is les ...
- wget: unable to resolve host address 解决办法
vim /etc/resolv.conf 加上下面两句: nameserver 8.8.8.8 #google域名服务器nameserver 8.8.4.4 #google域名服务器
- 真机测试-Please enter a different string错误解决
错误原因是这个bundle ID已经被占用了,这是想到的是要重置测试证书,那么则需要去修改Bundle identifier,因为测试证书是以Bundle identifier为基准的,修改后运行,重 ...
- CANVAS 水波动态背景
参考:https://github.com/cyclegtx/wave_background 做的水波背景,以后可能会用到哈! 效果如下: 代码如下: <!DOCTYPE html> &l ...
- Cannot get a connection, pool exhausted解决办法
http://blog.163.com/it_message/blog/static/8892051200908102032653/ 连接池(Tomcat+oracle),运行一段时间后就会出现 Ca ...
- [系统集成] 部署 mesos-exporter 和 prometheus 监控 mesos task
前几天我在mesos平台上基于 cadvisor部署了 influxdb 和 grafana,用于监控 mesos 以及 docker app 运行信息,发现这套监控系统不太适合 mesos + do ...
- 02shell编程环境的搭建
02shell编程环境的搭建 [02]Shell编程 02shell编程环境的搭建 在不同的操作系统上搭建shell编程环境 Linux Windows Mac 编辑器的选择 系统环境的搭建 注: 选 ...