Example #1
0
partial         void SaveImage(SurfaceSaver surfaceSaver, RenderTarget2D target)
        {
            var filename = $"output-{DateTime.Now:yyyyMMdd-HHmmss}.png";
            var path = filename;

            var dir = AndroidEnvironment.GetExternalStoragePublicDirectory(
                AndroidEnvironment.DirectoryPictures).AbsolutePath;
            path = Path.Combine(dir, filename);

            using (var stream = File.OpenWrite(path))
                surfaceSaver.SaveAsPng(rtarget, stream);

            MediaScannerConnection.ScanFile(ApplicationContext, new String[] { path },
                new String[] { MimeTypeMap.Singleton.GetMimeTypeFromExtension("png") }, null);

            confirmMsgText = $"Image saved to photo gallery";
            confirmMsgOpacity = 1;
        }
Example #2
0
partial         void SaveImage(SurfaceSaver surfaceSaver, RenderTarget2D target)
        {
            using (var stream = new MemoryStream())
            {
                surfaceSaver.SaveAsPng(rtarget, stream);
                stream.Flush();
                stream.Seek(0, SeekOrigin.Begin);

                using (var imgData = Foundation.NSData.FromStream(stream))
                using (var img = UIKit.UIImage.LoadFromData(imgData))
                {
                    img.SaveToPhotosAlbum(null);
                }

                confirmMsgText = $"Image saved to photo gallery";
                confirmMsgOpacity = 1;
            }
        }