Android - Surface View ScreenShot

时间:2015-06-06 15:07:57

标签: android imageview surfaceview

我有截图代码可以正常使用图像,现在我添加了表面视图和图像。但拍摄的图像和图纸。但是在表面视图上没有任何东西。请帮助我这方面

这是截图代码

public Bitmap takeScreenshot() {

       View rootView = null;
       rootView = getWindow().getDecorView().getRootView();
       rootView.setDrawingCacheEnabled(false);
       rootView.buildDrawingCache();
       rootView.setDrawingCacheEnabled(true);
       return rootView.getDrawingCache();
    }

     public void saveBitmap(Bitmap bitmap) {

        File imagePath = new     File(Environment.getExternalStorageDirectory() + "/" + new   SimpleDateFormat("yyyyMMddhhmmss'.jpg'").format(new Date()) );
        FileOutputStream fos =null;
        try {
            fos = new FileOutputStream(imagePath);
            bitmap.compress(CompressFormat.JPEG, 100, fos);
            fos.flush();
            fos.close();
            new   AlertDialog.Builder(DrawingActivity.this).setTitle("Info!").setMessage("New   Image Saved").setPositiveButton(android.R.string.ok, null).setCancelable(false).create().show();
        } catch (FileNotFoundException e) {
            Log.e("GREC", e.getMessage(), e);
        } catch (IOException e) {
            Log.e("GREC", e.getMessage(), e);
        }
    }

0 个答案:

没有答案