private async void GetPixelMapFromGallery() { if (!CrossMedia.Current.IsPickPhotoSupported) { await DisplayAlert("Photos Not Supported", ":( Permission not granted to photos.", "OK"); return; } var file = await CrossMedia.Current.PickPhotoAsync(); if (file == null) { return; } switch (Device.RuntimePlatform) { case Device.Android: Source = AndroidHelper.GetPixelMap(file.GetStream()); break; case Device.iOS: Source = iOSHelper.GetPixelMap(file.Path); break; } MyImage.Source = LoadFromPixel(Source); }
private async void Button_Clicked(object sender, EventArgs e) { box.IsVisible = true; stackloading.IsVisible = true; loading.IsVisible = true; loading.IsRunning = true; var status = await CheckAndRequestPermissionAsync(new Permissions.StorageRead()); if (status != PermissionStatus.Granted) { // Notify user permission was denied return; } var status1 = await CheckAndRequestPermissionAsync(new Permissions.StorageWrite()); if (status1 != PermissionStatus.Granted) { // Notify user permission was denied return; } await CrossMedia.Current.Initialize(); var file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions { CompressionQuality = 75, PhotoSize = PhotoSize.Large }); if (file != null) { switch (Device.RuntimePlatform) { case Device.Android: Source = AndroidHelper.GetPixelMap(file.GetStream()); break; case Device.iOS: Source = iOSHelper.GetPixelMap(file.Path); break; } convert(); } else { box.IsVisible = false; loading.IsVisible = false; loading.IsRunning = false; stackloading.IsVisible = false; } }