2012-03-25 23 views
0

Ich habe ein Problem beim Speichern der Leinwand Bild gezeichnet. Hier ist der Code:android leinwand zeichnung

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

Was ist das Problem? Wo ist die Stack-Spur? Was ist MyView? Wird das Feld "myBitmap" beim Erstellen initialisiert? (PS .: Bitte verwenden Sie die Logarithmus-Methode mit drei Argumenten: 'Log.i (" DAVE "," stacktrace follows ", e);' –

Antwort

0

sollten Sie die FileOutputStream schließen, wenn Sie es nicht brauchen.

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

hinzufügen fos.close() und prüfen, ob sich etwas ändert.

PS. Veröffentlichen Sie den Inhalt Ihres Logcats immer.