Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/386.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 面临录制视频时截图的问题_Java_Android - Fatal编程技术网

Java 面临录制视频时截图的问题

Java 面临录制视频时截图的问题,java,android,Java,Android,我正在录制视频时尝试截屏。我可以把截图保存到我的SD卡上。但它在Sd卡上显示空白图像。谁能帮我摆脱这一切 我正在使用以下代码捕获屏幕截图: View v1 = cameraView; // CameraView is object of SurfaceView v1.setDrawingCacheEnabled(true); Bitmap bm = Bitmap.createBitmap(v1.getDrawingCache());

我正在录制视频时尝试截屏。我可以把截图保存到我的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());
        }
请看这里: