예제 #1
0
파일: Game.cs 프로젝트: RUSshy/ultraviolet
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;
        }
예제 #2
0
파일: Game.cs 프로젝트: RUSshy/ultraviolet
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;
            }
        }