Exemplo n.º 1
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            await CrossMedia.Current.Initialize();

            Image image = new Image();

            if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
            {
                //DisplayAlert("No Camera", ":( No camera available.", "OK");
                return;
            }

            var file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions {
                Directory          = "Test",
                SaveToAlbum        = true,
                CompressionQuality = 75,
                CustomPhotoSize    = 50,
                PhotoSize          = PhotoSize.MaxWidthHeight,
                MaxWidthHeight     = 2000,
                DefaultCamera      = CameraDevice.Front
            });

            if (file == null)
            {
                return;
            }

            Stream stream;

            image.Source = ImageSource.FromStream(() => {
                stream = file.GetStream();
                return(stream);
            });

            await viewModel.SaveImageCommand(image, file.GetStream());
        }