async Task CaptureScreenshot() { var screenshot = await Screenshot.CaptureAsync(); await MediaGallery.SaveAsync(MediaFileType.Image, await screenshot.OpenReadAsync(), "bethesdaMobile.png"); await PopupNavigation.Instance.PushAsync(new DialogAlertCustom("Sukses", "Bukti Pendaftaran Berhasil Disimpan,Silahkan Cek Di Gallery")); }
async void Save(MediaFileType type, string name) { var status = await PermissionHelper.CheckAndReques <SaveMediaPermission>( "The application needs permission to save media files", DisplayAlertAsync); if (status != PermissionStatus.Granted) { await DisplayAlertAsync("The application did not get the necessary permission to save media files"); return; } try { using var stream = EmbeddedResourceProvider.Load(name); if (FromStream) { await MediaGallery.SaveAsync(type, stream, name); } else if (FromByteArray) { using var memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); await MediaGallery.SaveAsync(type, memoryStream.ToArray(), name); } else if (FromCacheDirectory) { var filePath = await FilesHelper.SaveToCacheAsync(stream, name); await MediaGallery.SaveAsync(type, filePath); } await DisplayAlertAsync("Save Completed Successfully"); } catch (Exception ex) { await DisplayAlertAsync(ex.Message); } }
private async void OnSaveImageClick(object sender, EventArgs args) { var screenshot = await Screenshot.CaptureAsync(); await MediaGallery.SaveAsync(MediaFileType.Image, await screenshot.OpenReadAsync(), "myScreenshot.png"); }