2012-03-25 137 views
0

我在保存繪製的畫布圖像時遇到問題。代碼如下:安卓畫布繪圖

public void save_it(File file) 
{ 
    String fname = file.getAbsolutePath(); 
    MyView mv =new MyView(this); 
    FileOutputStream fos = null; 
    try{ 
     fos = new FileOutputStream(fname); 
     mv.myBitmap.compress(CompressFormat.JPEG, 100, fos); 
     Toast.makeText(this,"Image Saved", 2000).show(); 
    } 
    catch(Exception e){ 
     Toast.makeText(this,"Error Saving Image", 2000).show(); 
     Log.i("DAVE","stacktrace is " + e); 
    } 
+0

有什麼問題?堆棧跟蹤在哪裏?什麼是「MyView」?它的'myBitmap'字段是否在施工時被初始化? (P.S .:請使用三參數Log方法:'Log.i(「DAVE」,「stacktrace following」,e);' – 2012-03-25 15:54:19

回答

0

如果您不需要它,您應該關閉FileOutputStream

mv.myBitmap.compress(CompressFormat.JPEG, 100, fos);

之後添加fos.close(),並檢查是否有新的變化。

PS。始終發佈你的logcat的內容。