D'économie d'image Bitmap d'un Fichier - Xamarin, Monodroid

Je suis en train d'enregistrer une image bitmap à un répertoire (galerie) à l'intérieur de mon téléphone. L'application est en cours d'élaboration dans Xamarin sorte que le code est en C#.

Je ne peux pas semblent comprendre comment faire un répertoire, et enregistrer une image Bitmap. Des suggestions?

public void createBitmap(View view){ 
    view.DrawingCacheEnabled = true; 
    view.BuildDrawingCache (true); 
    Bitmap m_Bitmap = view.GetDrawingCache(true);

    String storagePath = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
    Java.IO.File storageDirectory = new Java.IO.File(storagePath);
    //storageDirectory.mkdirs ();


    //save the bitmap
    //MemoryStream stream = new MemoryStream ();
    //m_Bitmap.Compress (Bitmap.CompressFormat.Png, 100, stream);
    //stream.Close();


    try{

        String filePath = storageDirectory.ToString() + "APPNAME.png";
        FileOutputStream fos = new FileOutputStream (filePath);
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        m_Bitmap.Compress (Bitmap.CompressFormat.Png, 100, bos);
        bos.Flush();
        bos.Close();
    } catch (Java.IO.FileNotFoundException e) {
        System.Console.WriteLine ("FILENOTFOUND");
    } catch (Java.IO.IOException e) {
        System.Console.WriteLine ("IOEXCEPTION");
    }

OriginalL'auteur Coova | 2014-09-22