Exemplo n.º 1
0
        public static string SaveAndAddToGallery(this Bitmap bitmap, string Android_OS_Environment, string fileName, Context context)
        {
            var directory = Android.OS.Environment.GetExternalStoragePublicDirectory(Android_OS_Environment);
            var path      = System.IO.Path.Combine(directory.Path, fileName);

            //create a file to write bitmap data
            var stream = new FileStream(path, FileMode.OpenOrCreate);

            using (stream)
            {
                bitmap.Compress(Bitmap.CompressFormat.Jpeg, 100, stream);
                bitmap.AddImageToGallery(path, context);
                stream.Flush();
                stream.Close();
            }

            return(path);
        }