ImageUtil.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:RunHDU 作者:
/**
 * 对Activity截图
 *
 * @param activity
 * @return Bitmap对象。
 */
public static Bitmap takeScreenShot(Activity activity) {
    View view = activity.getWindow().getDecorView();
    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache();
    Bitmap b1 = view.getDrawingCache();
    Rect frame = new Rect();
    activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
    int statusBarHeight = frame.top;
    int width = activity.getWindowManager().getDefaultDisplay().getWidth();
    int height = activity.getWindowManager().getDefaultDisplay()
            .getHeight();
    Bitmap b = Bitmap.createBitmap(b1, 0, statusBarHeight, width, height - statusBarHeight);
    view.destroyDrawingCache();
    return b;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号