async void TakePhotoAsync() { try { var photo = await MediaPicker.CapturePhotoAsync(); var stream = await photo.OpenReadAsync(); avatar.Source = ImageSource.FromStream(() => stream); var img = App.firebase.storage.Child("images").Child(App.firebase.currentUser.LocalId + ".png").PutAsync(await photo.OpenReadAsync()); img.Progress.ProgressChanged += (s, e) => Console.WriteLine($"Progress: {e.Percentage} %"); var img_url = await img; var res = await App.firebase.auth.UpdateProfileAsync(App.firebase.userLink.FirebaseToken, App.firebase.userLink.User.DisplayName, img_url); App.firebase.currentUser = res.User; var page = Application.Current.MainPage.Navigation.NavigationStack.Last() as SlideMenu.SlideMenu; page.refresh(); Console.WriteLine($"CapturePhotoAsync COMPLETED: {img_url}"); } catch (Exception ex) { Console.WriteLine($"CapturePhotoAsync THREW: {ex}"); } }
private async void ButtonSelectFile_Clicked(object sender, EventArgs e) { try { ButtonUploadFile.IsEnabled = false; FileResult photo; if (MediaPicker.IsCaptureSupported) { photo = await MediaPicker.CapturePhotoAsync(); } else { photo = await MediaPicker.PickPhotoAsync(); } if (photo == null) { return; } _selectedFile = photo; LabelFileName.Text = $"{_selectedFile.FileName} file selected. Ready to upload!"; ButtonUploadFile.IsEnabled = true; } catch (Exception ex) { Console.WriteLine($"Ops something went wrong: {ex.Message}"); ButtonUploadFile.IsEnabled = false; } }
private async void Button_Clicked_1(object sender, EventArgs e) { var result = await MediaPicker.CapturePhotoAsync(); if (result != null) { var stream = await result.OpenReadAsync(); resultImage.Source = ImageSource.FromStream(() => stream); } //try //{ // var photo = await MediaPicker.CapturePhotoAsync(); // await LoadPhotoAsync(photo); // Console.WriteLine($"CapturePhotoAsync COMPLETED: {PhotoPath}"); //} //catch (FeatureNotSupportedException fnsEx) //{ // Console.WriteLine($"CapturePhotoAsync THREW: {fnsEx.Message}"); //} //catch (PermissionException pEx) //{ // Console.WriteLine($"CapturePhotoAsync THREW: {pEx.Message}"); //} //catch (Exception ex) //{ // Console.WriteLine($"CapturePhotoAsync THREW: {ex.Message}"); //} }
async private void TapGestureRecognizer_Tapped(object sender, EventArgs e) { string answer = await DisplayActionSheet("Đổi ảnh đại diện bằng ?", "Hủy", null, "Camera", "Chọn ảnh"); if (answer == "Chọn ảnh") { var result = await MediaPicker.PickPhotoAsync(new MediaPickerOptions { Title = "Please pick a photo" }); if (result != null) { var stream = await result.OpenReadAsync(); resultImage.Source = ImageSource.FromStream(() => stream); } } else if (answer == "Camera") { var result = await MediaPicker.CapturePhotoAsync(new MediaPickerOptions { Title = "Please pick a photo" }); if (result != null) { var stream = await result.OpenReadAsync(); resultImage.Source = ImageSource.FromStream(() => stream); } } }
public static async Task <FileInfo> TakePhotoAsync() { try { var photo = await MediaPicker.CapturePhotoAsync(); var file = await LoadPhotoAsync(photo); Console.WriteLine($"CapturePhotoAsync COMPLETED: {file}"); return(file); } catch (FeatureNotSupportedException) { // Feature is now supported on the device } catch (PermissionException) { // Permissions not granted } catch (Exception ex) { Console.WriteLine($"CapturePhotoAsync THREW: {ex.Message}"); } return(null); }
private async Task Scan() { var status = await Permissions.CheckStatusAsync <Permissions.Camera>(); if (status != PermissionStatus.Granted) { status = await Permissions.RequestAsync <Permissions.Camera>(); } if (status != PermissionStatus.Granted) { return; } try { var photo = await MediaPicker.CapturePhotoAsync(); using (var stream = await photo.OpenReadAsync()) { var scanResults = await _ocrService.ProcessImage(stream); _currentImageService.ScanResult = scanResults; await _navigationService.NavigateAsync(nameof(ScanPreviewPage)); } //await LoadPhotoAsync(photo); //Console.WriteLine($"CapturePhotoAsync COMPLETED: {PhotoPath}"); } catch (Exception ex) { Console.WriteLine($"CapturePhotoAsync THREW: {ex.Message}"); } }
public async Task <string> TakePhotoFullPathAsync() { string fullPath = ""; try { var photo = await MediaPicker.CapturePhotoAsync(new MediaPickerOptions { Title = $"xamarin.{DateTime.Now.ToString("dd.MM.yyyy_hh.mm.ss")}.png" }); var newFile = Path.Combine(FileSystem.AppDataDirectory, photo.FileName); using (var stream = await photo.OpenReadAsync()) { using (var newStream = File.OpenWrite(newFile)) { await stream.CopyToAsync(newStream); } } fullPath = photo.FullPath; } catch (Exception ex) { await UserDialogs.Instance.AlertAsync(ex.Message); } return(fullPath); }
/// <summary> /// Take Photo async /// </summary> /// <returns></returns> public async Task <PhotoItemModel> TakeAPhotoAsync() { var photo = await MediaPicker.CapturePhotoAsync().ConfigureAwait(false); var photoModel = await LoadPhotoAsync(photo).ConfigureAwait(false); return(photoModel); }
public async Task CapturePhoto() { FileResult result = await MediaPicker.CapturePhotoAsync(new MediaPickerOptions { Title = "Zrób zdjęcie" }); await EmbedMedia(result, true); }
/// <summary> /// pick the photo from the camera /// </summary> private async void executeCamera() { try { var photo = await MediaPicker.CapturePhotoAsync(new MediaPickerOptions { Title = $"photo.{DateTime.Now:dd.MM.yyyy_hh.mm.ss}.png" }); await SaveAndReturn(photo); } catch (Exception) { } }
async void Button_Clicked(System.Object sender, System.EventArgs e) { var result = await MediaPicker.CapturePhotoAsync(new MediaPickerOptions { Title = "Please pick a photo" }); var stream = await result.OpenReadAsync(); resultImage.Source = ImageSource.FromStream(() => stream); }
async Task TakePhotoAsync() { if (MediaPicker.IsCaptureSupported) { Image = await MediaPicker.CapturePhotoAsync(); } else { await PageDialog.DisplayAlertAsync("ERROR", "Dispositivo no tiene camara disponible", "OK"); } }
async void Button1_Clicked(System.Object sender, System.EventArgs e) { var result = await MediaPicker.CapturePhotoAsync(); if (result != null) { var stream = await result.OpenReadAsync(); resultImage.Source = ImageSource.FromStream(() => stream); } }
async Task TakePhotoAsync() { try { var photo = await MediaPicker.CapturePhotoAsync(); await LoadPhotoAsync(photo); } catch (Exception ex) { } }
async void TakePhotoButtonClicked(object sender, EventArgs e) { var photoResult = await MediaPicker.CapturePhotoAsync(); if (photoResult != null) { var streamResult = await photoResult.OpenReadAsync(); IM_USER_IMAGE.Source = ImageSource.FromStream(() => streamResult); } }
private async void _TakePhoto() { string newPath = await Files.SaveNewPhoto(await MediaPicker.CapturePhotoAsync()); if (newPath == null) { return; } Card.ImagePath = newPath; Card.CroppedImage = null; }
public static async Task <LocalPhoto> TakePhoto(bool capture) { var photo = capture ? await MediaPicker.CapturePhotoAsync() : await MediaPicker.PickPhotoAsync(); var file = await SavePhoto(photo); return(new LocalPhoto() { NewFile = file, PhotoFile = photo }); }
async Task TakePhotoAsync() { try { var photo = await MediaPicker.CapturePhotoAsync(); await LoadPhotoAsync(photo); Console.WriteLine("Photo Path: " + PhotoPath); } catch (Exception e) { Console.WriteLine("Error: " + e.Message); } }
async void OnClick_TakePicture(object sender, EventArgs e) { var result = await MediaPicker.CapturePhotoAsync(); if (result != null) { await LoadPhotoAsync(result); // var stream = await result.OpenReadAsync(); pictureImage.Source = ImageSource.FromStream(() => stream); //await DisplayAlert("Alert", PhotoPath, "OK"); } }
async Task TakePhotoAsync() { try { var photo = await MediaPicker.CapturePhotoAsync(); await LoadPhotoAsync(photo); Console.WriteLine($"CapturePhotoAsync COMPLETED: {PhotoPath}"); } catch (Exception ex) { Console.WriteLine($"CapturePhotoAsync THREW: {ex.Message}"); } }
private async void OnCameraBtnClicked(object sender, EventArgs e) { _photo = await MediaPicker.CapturePhotoAsync(); if (_photo != null) { var stream = await _photo.OpenReadAsync(); PhotoImage.Source = ImageSource.FromStream(() => { return(stream); }); } SaveBtn.IsEnabled = true; }
private async void TakingPictures() { var result = await MediaPicker.CapturePhotoAsync(); if (result != null) { var stream = await result.OpenReadAsync(); var newFile = Path.Combine(FileSystem.AppDataDirectory, result.FileName); var newStream = File.OpenWrite(newFile); await stream.CopyToAsync(newStream); PathPicture = result.FullPath; } }
async Task TakePhotoAsync() { try { photo = await MediaPicker.CapturePhotoAsync(); ImageInfoStack.IsVisible = true; Console.WriteLine($"CapturePhotoAsync COMPLETED: {photo}"); } catch (Exception ex) { Console.WriteLine($"CapturePhotoAsync THREW: {ex.Message}"); } }
private async void BtnTakePic_Clicked(object sender, EventArgs e) { var result = await MediaPicker.CapturePhotoAsync(new MediaPickerOptions { Title = "Please take a photo", }); if (result != null) { PicturePath = result.FullPath; var stream = await result.OpenReadAsync(); resultImage.Source = ImageSource.FromStream(() => stream); } }
private async void TakeAPhotoAsync(object sender, EventArgs e) { if (MediaPicker.IsCaptureSupported) { var photo = await MediaPicker.CapturePhotoAsync(); if (photo != null) { var stream = await photo.OpenReadAsync(); image.Source = ImageSource.FromStream(() => { return(stream); }); FilePath = photo.FullPath; FileStream = stream; } } }
private async Task TakePhoto() { if (!this.NeuronService.Contracts.FileUploadIsSupported) { await this.UiDispatcher.DisplayAlert(AppResources.TakePhoto, AppResources.TakingAPhotoIsNotSupported); return; } FileResult capturedPhoto = await MediaPicker.CapturePhotoAsync(); if (!(capturedPhoto is null)) { await AddPhoto(capturedPhoto.FullPath, true); } }
public MainPageViewModel(INavigationService navigationService) { this.navigationService = navigationService; TakePhotoCommand = new DelegateCommand(async() => { try { FileResult photo = await MediaPicker.CapturePhotoAsync(); await LoadPhotoAsync(photo); } catch (Exception ex) { Console.WriteLine($"CapturePhotoAsync THREW: {ex.Message}"); } }); }
/// <inheritdoc /> async Task <IReadOnlyCollection <byte> > IPhotoCapturingService.CapturePhotoAsync() { var fileResult = await MediaPicker.CapturePhotoAsync(); if (fileResult is null) { return(ArraySegment <byte> .Empty); } var fileStream = await fileResult.OpenReadAsync(); var memoryStream = new MemoryStream(); await fileStream.CopyToAsync(memoryStream); return(memoryStream.ToArray()); }
private async void TakePicture() { try { var photo = await MediaPicker.CapturePhotoAsync(); if (photo != null) { Upload(photo); } } catch (Exception ex) { DisplayException(ex); } }
public async Task <System.IO.Stream> TakePhotoAsync() { try { var photo = await MediaPicker.CapturePhotoAsync(); var stream = await photo.OpenReadAsync(); return(stream); } catch (Exception ex) { Console.WriteLine($"There was error during making a photo: {ex.Message}"); return(null); } }