zoukankan      html  css  js  c++  java
  • 应用内截屏

    今天实现了在应用内截屏的方法,很简单代码如下:

    (有surfaceView不能截取)

    private boolean shot(){
        Bitmap bm = Bitmap.createBitmap(480, 854, Config.ARGB_8888);
        Canvas canvas = new Canvas(bm);
        getWindow().getDecorView().draw(canvas);
        if (Environment.getExternalStorageState().equals(
                Environment.MEDIA_MOUNTED)) {
            File file = new File("/sdcard/tt/tt.png");
            try {
                if (!file.getParentFile().exists()) {
                    file.getParentFile().mkdirs();
                    file.createNewFile();
                }
                FileOutputStream fos = new FileOutputStream(file);
                bm.compress(Bitmap.CompressFormat.PNG, 100, fos);
                fos.flush();
                fos.close();
            } catch (IOException e) {
                e.printStackTrace();
                return false;
            }
        }
        return true;
    }
    
    关于SurfaceView的截取,在surfaceView中使用双缓冲,可以截取,但貌似效率会变低,谁有好的解决方法,麻烦告诉我,谢谢~
     
  • 相关阅读:
    Codeforces 1322B
    面向对象案例
    0428面向对象2.0
    0427 面向对象初识
    0427数组相关思想
    0426数组操作
    Eclipse使用技巧
    数组汇总0426
    0424数组练习
    数组习题练习0424
  • 原文地址:https://www.cnblogs.com/ihou/p/2259865.html
Copyright © 2011-2022 走看看