zoukankan      html  css  js  c++  java
  • 屏幕截取-2种模式

    /**
         * 获取当前屏幕截图,包含状态栏
         */
        public static Bitmap snapShotWithStatusBar(Activity activity){
            View view = activity.getWindow().getDecorView();
            view.setDrawingCacheEnabled(true);
            view.buildDrawingCache();
            Bitmap bmp = view.getDrawingCache();
            int width = getScreenWidth(activity);
            int height = getScreenHeight(activity);
            Bitmap bp = null;
            bp = Bitmap.createBitmap(bmp, 0, 0, width, height);
            view.destroyDrawingCache();
            return bp;
        }
     
        /**
         * 获取当前屏幕截图,不包含状态栏
         *
         */
        public static Bitmap snapShotWithoutStatusBar(Activity activity){
            View view = activity.getWindow().getDecorView();
            view.setDrawingCacheEnabled(true);
            view.buildDrawingCache();
            Bitmap bmp = view.getDrawingCache();
            Rect frame = new Rect();
            activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
            int statusBarHeight = frame.top;
            int width = getScreenWidth(activity);
            int height = getScreenHeight(activity);
            Bitmap bp = null;
            bp = Bitmap.createBitmap(bmp, 0, statusBarHeight, width, height
                    - statusBarHeight);
            view.destroyDrawingCache();
            return bp;
        }
  • 相关阅读:
    003.iSCSI客户端管理
    002.iSCSI服务端配置
    001.iSCSI简介
    004.RAID删除
    003.RAID管理
    002.RAID创建
    001.RAID简介
    001.hadoop及hbase部署
    001.Parted工具使用
    007.LVM查看命令
  • 原文地址:https://www.cnblogs.com/hacjy/p/5142795.html
Copyright © 2011-2022 走看看