[android]代码库
public static byte[] getCurScreenPic(Activity activity) {
// 1.构建Bitmap
WindowManager windowManager = activity.getWindowManager();
Display display = windowManager.getDefaultDisplay();
int w = display.getWidth();
int h = display.getHeight();
Bitmap Bmp = Bitmap.createBitmap(w, h, Config.ARGB_8888);
// 2.获取屏幕
View decorview = activity.getWindow().getDecorView();
decorview.setDrawingCacheEnabled(true);
Bmp = decorview.getDrawingCache();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Bmp.compress(Bitmap.CompressFormat.PNG, 90, baos);
byte[] b = baos.toByteArray();
try {
baos.flush();
baos.close();
} catch (IOException e) {
e.printStackTrace();
}
return b;
}
by: 发表于:2017-10-24 09:18:32 顶(0) | 踩(0) 回复
??
回复评论