/** * 截屏工具. */ public class CutScreenUtile { /** * 截取全屏 * @param aty * @return */ public static Bitmap cutScreen(Activity aty){ return cutScreen(aty,0,0,0,0); } /** * 指定位置截取屏幕 * @param aty * @param x * @param y * @param width * @param height * @return */ public static Bitmap cutScreen(Activity aty,int x,int y,int width,int height){ View view = aty.getWindow().getDecorView(); view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap bitmap = null; if(width != 0 && height != 0){ bitmap = Bitmap.createBitmap(view.getDrawingCache(),x,y,width,height); }else { bitmap = view.getDrawingCache(); } // view.setDrawingCacheEnabled(false); return bitmap; } }
截屏/截取屏幕指定区域
最新推荐文章于 2024-08-05 04:08:09 发布