面对在录制视频时拍摄屏幕截图的问题

时间:2012-07-28 08:53:09

标签: java android

我正在尝试录制视频时拍摄屏幕截图。我可以拍摄截图并将其保存到我的SD卡中。但它在Sd卡上显示空白图像。有人可以帮我摆脱这个吗?

我使用下面的代码捕获屏幕截图:

        View v1 = cameraView; // CameraView is object of SurfaceView

        v1.setDrawingCacheEnabled(true);
        Bitmap bm = Bitmap.createBitmap(v1.getDrawingCache());
        OutputStream outStream = null;
        File file = new File(Environment.getExternalStorageDirectory(),        "test12345658.jpeg");
        try {
         outStream = new FileOutputStream(file);
         bm.compress(Bitmap.CompressFormat.JPEG, 100, outStream);
         outStream.flush();
         outStream.close();

         Log.i("Hub", "OK, Image Saved to SD");
         Log.i("Hub", "height = "+ bm.getHeight() + ", width = " + bm.getWidth());

        } catch (FileNotFoundException e) {

         e.printStackTrace();
         Log.i("Hub", "FileNotFoundException: "+ e.toString());

        } catch (IOException e) {

         e.printStackTrace();
         Log.i("Hub", "IOException: "+ e.toString());
        }

0 个答案:

没有答案
相关问题