Android实现截屏并将图片保存到本地

Bitmap bitmap = mSurfaceView.getDrawingCache();//这个是抓屏实现的基本原理
     if(bitmap != null)
     {
      FileOutputStream fos = null;
         try {
    fos = new FileOutputStream ("/sdcard/test.png");
    bitmap.compress(Bitmap.CompressFormat.PNG, 90, fos);//存储为PNG格式的,目前android系统支持JPEG和PNG两种格式
    fos.flush();
    fos.close();
   } catch (FileNotFoundException e) {
    e.printStackTrace();
   } catch (IOException e) {
    e.printStackTrace();
   }
         

     }

本文转载自:http://www.shouyanwang.org/thread-411-1-1.html


你可能感兴趣的:(android,null,存储)