private async Task CapturePhoto() { var lowLagCapture = await _mediaCapture.PrepareLowLagPhotoCaptureAsync(ImageEncodingProperties.CreateJpeg()); var capturedPhoto = await lowLagCapture.CaptureAsync(); var softwareBitmap = capturedPhoto.Frame.AsStream(); CapturePhotoService.ImageCaptureHandler(Xamarin.Forms.ImageSource.FromStream(() => softwareBitmap)); await lowLagCapture.FinishAsync(); }
private async void OnCameraViewTapped(object sender, EventArgs e) { if (_uiCameraView.IsPreviewing) { var imageData = await CapturePhoto(); CapturePhotoService.ImageCaptureHandler(ImageSource.FromStream(() => new MemoryStream(imageData))); SetNeedsDisplay(); _uiCameraView.CaptureSession.StopRunning(); _uiCameraView.IsPreviewing = false; } else { _uiCameraView.CaptureSession.StartRunning(); _uiCameraView.IsPreviewing = true; } }
private static void OnPhoto(object sender, ImageSource imageData) { Device.BeginInvokeOnMainThread(() => { CapturePhotoService.ImageCaptureHandler(imageData); }); }