private async void UploadPictureButton_Clicked(Object sender, EventArgs e) { if (!CrossMedia.Current.IsPickPhotoSupported) { await DisplayAlert("No upload", "Picking a photo is not supported.", "OK"); return; } var file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions { PhotoSize = PhotoSize.Medium }); if (file == null) { return; } medFile = file; ImageStreamUtils isu = new ImageStreamUtils(); imgData = isu.GetImageStreamAsBytes(file.GetStream()); Image1.Source = ImageSource.FromStream(() => file.GetStream()); }
private async void TakePictureButton_Clicked(Object sender, EventArgs e) { await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported) { await DisplayAlert("No Camera", "No camera available.", "OK"); return; } var file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions { SaveToAlbum = true, PhotoSize = PhotoSize.Medium, Name = "test.jpg" }); if (file == null) { return; } medFile = file; ImageStreamUtils isu = new ImageStreamUtils(); imgData = isu.GetImageStreamAsBytes(file.GetStream()); Image1.Source = ImageSource.FromStream(() => file.GetStream()); }