/// <summary> /// Takes an HDR photo to a StorageFile and adds rotation metadata to it /// </summary> /// <returns></returns> private async Task TakeHdrPhotoAsync() { try { Debug.WriteLine("Taking HDR photo..."); // Read the current orientation of the camera and the capture time var photoOrientation = ConvertOrientationToPhotoOrientation(GetCameraOrientation()); var fileName = String.Format("SimplePhoto_{0}_HDR.jpg", DateTime.Now.ToString("HHmmss")); // Create a context object, to identify the capture in the OptionalReferencePhotoCaptured event var context = new AdvancedCaptureContext() { CaptureFileName = fileName, CaptureOrientation = photoOrientation }; // Start capture, and pass the context object var capture = await _advancedCapture.CaptureAsync(context); Debug.WriteLine("HDR photo taken! {0}", fileName); using (var frame = capture.Frame) { await ReencodeAndSavePhotoAsync(frame, fileName, photoOrientation); } } catch (Exception ex) { // File I/O errors are reported as exceptions Debug.WriteLine("Exception when taking an HDR photo: {0}", ex.ToString()); } }
/// <summary> /// Takes an Advanced Capture photo to a StorageFile and adds rotation metadata to it /// </summary> /// <returns></returns> private async Task TakeAdvancedCapturePhotoAsync() { // Lock the UI as a simple way to prevent reentrancy PhotoButton.IsEnabled = false; CycleModeButton.IsEnabled = false; try { Debug.WriteLine("Taking Advanced Capture photo..."); // Read the current orientation of the camera and the capture time var photoOrientation = ConvertOrientationToPhotoOrientation(GetCameraOrientation()); var fileName = String.Format("AdvancedCapturePhoto_{0}.jpg", DateTime.Now.ToString("HHmmss")); // Create a context object, to identify the capture later on var context = new AdvancedCaptureContext { CaptureFileName = fileName, CaptureOrientation = photoOrientation }; // Start capture, and pass the context object to get it back in the OptionalReferencePhotoCaptured event var capture = await _advancedCapture.CaptureAsync(context); using (var frame = capture.Frame) { var file = await _captureFolder.CreateFileAsync(fileName, CreationCollisionOption.GenerateUniqueName); Debug.WriteLine("Advanced Capture photo taken! Saving to " + file.Path); await ReencodeAndSavePhotoAsync(frame, file, photoOrientation); var navigation = NavigationService.GetForFrame(this.Frame); navigation.Navigate(typeof(ImageViewer), file.Path); } } catch (Exception ex) { // File I/O errors are reported as exceptions Debug.WriteLine("Exception when taking an Advanced Capture photo: " + ex.ToString()); } finally { // Re-enable the buttons to reflect the current state of the app UpdateUi(); } }
/// <summary> /// Takes an HDR photo to a StorageFile and adds rotation metadata to it /// </summary> /// <returns></returns> private async Task TakeHdrPhotoAsync() { try { Debug.WriteLine("Taking HDR photo..."); // Read the current orientation of the camera and the capture time var photoOrientation = ConvertOrientationToPhotoOrientation(GetCameraOrientation()); var fileName = String.Format("SimplePhoto_{0}_HDR.jpg", DateTime.Now.ToString("HHmmss")); // Create a context object, to identify the capture in the OptionalReferencePhotoCaptured event var context = new AdvancedCaptureContext() { CaptureFileName = fileName, CaptureOrientation = photoOrientation }; // Start capture, and pass the context object var capture = await _advancedCapture.CaptureAsync(context); using (var frame = capture.Frame) { var file = await _captureFolder.CreateFileAsync(fileName, CreationCollisionOption.GenerateUniqueName); Debug.WriteLine("HDR photo taken! Saving to " + file.Path); await ReencodeAndSavePhotoAsync(frame, file, photoOrientation); } } catch (Exception ex) { // File I/O errors are reported as exceptions Debug.WriteLine("Exception when taking an HDR photo: " + ex.ToString()); } }
/// <summary> /// Takes an Advanced Capture photo to a StorageFile and adds rotation metadata to it /// </summary> /// <returns></returns> private async Task TakeAdvancedCapturePhotoAsync() { // Lock the UI as a simple way to prevent reentrancy PhotoButton.IsEnabled = false; CycleModeButton.IsEnabled = false; try { Debug.WriteLine("Taking Advanced Capture photo..."); // Read the current orientation of the camera and the capture time var photoOrientation = ConvertOrientationToPhotoOrientation(GetCameraOrientation()); var fileName = String.Format("AdvancedCapturePhoto_{0}.jpg", DateTime.Now.ToString("HHmmss")); // Create a context object, to identify the capture later on var context = new AdvancedCaptureContext {CaptureFileName = fileName, CaptureOrientation = photoOrientation}; // Start capture, and pass the context object to get it back in the OptionalReferencePhotoCaptured event var capture = await _advancedCapture.CaptureAsync(context); using (var frame = capture.Frame) { var file = await _captureFolder.CreateFileAsync(fileName, CreationCollisionOption.GenerateUniqueName); Debug.WriteLine("Advanced Capture photo taken! Saving to " + file.Path); await ReencodeAndSavePhotoAsync(frame, file, photoOrientation); } } catch (Exception ex) { // File I/O errors are reported as exceptions Debug.WriteLine("Exception when taking an Advanced Capture photo: " + ex.ToString()); } finally { // Re-enable the buttons to reflect the current state of the app UpdateUi(); } }