我正在实现一个保存功能以将自定义可绘制视图保存为图像。问题是创建了 JPG 图像,但它不包含任何内容,最后程序“不幸停止工作”谁能帮助我,这是我的代码;
    Bitmap b = drawView.getDrawingCache();
    File storage =Environment.getExternalStorageDirectory();
File file = new File(storage,spinner.getSelectedItem().toString()+".jpg");
    FileOutputStream fos;
              try {
               fos = new FileOutputStream(file);
               b.compress(CompressFormat.JPEG, 95,fos);
               fos.flush();
               fos.close();
              } catch (FileNotFoundException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
              } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
                drawView.destroyDrawingCache();