/** * 截屏 * @param activity * @return */ public static Bitmap screenCapture(Activity activity) { activity.getWindow().getDecorView().setDrawingCacheEnabled(true); Bitmap bmp = activity.getWindow().getDecorView().getDrawingCache(); return bmp; } /** * Bitmap对象保存为图片文件 * @param bitmap * @param filePath * @return */ public static boolean saveBitmapFile(Bitmap bitmap, String filePath){ //压缩图片大小 bitmap = Bitmap.createScaledBitmap(bitmap, 200, 200, true); File file = new File(filePath);//将要保存图片的路径 try { BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file)); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos); bos.flush(); bos.close(); return true; } catch (IOException e) { e.printStackTrace(); } return false; }
Android中截图功能(记录)
猜你喜欢
转载自blog.csdn.net/lpCrazyBoy/article/details/88101111
今日推荐
周排行