windows-phone-8 - 使用照片捕获设备捕获照片时方向错误

标签 windows-phone-8 camera windows-phone

我已经实现了自己的取景器和相机逻辑来捕捉图像。除了一些奇怪的方向问题外,一切都很好。使用我的应用程序拍摄的照片可以是纵向或横向模式。当我通过内置照片应用程序浏览照片时,方向符合预期。当我在手机连接 vi USB 的情况下从 PC 浏览图片时,缩略图总是横向的,但是当我打开文件时,照片正确地处于纵向模式。当我将应用程序中的图像绑定(bind)到 Telerik PanAndZoom 图像时,方向又是错误的。

这是我的初始化代码。

Windows.Foundation.Size best;
            //   Initialize the camera, when available.
            if (PhotoCaptureDevice.AvailableSensorLocations.Contains(CameraSensorLocation.Back))
            {
                // Use the back camera.
                best = FindBestResolutuion(CameraSensorLocation.Back, AspectRatio.R_16_9);
                _captureDevice = await PhotoCaptureDevice.OpenAsync(CameraSensorLocation.Back, best);
                _captureDevice.SetProperty(KnownCameraPhotoProperties.FlashMode, 
            }
            else if (PhotoCaptureDevice.AvailableSensorLocations.Contains(CameraSensorLocation.Front))
            {
                // Otherwise, use the front camera.
                best = FindBestResolutuion(CameraSensorLocation.Front);
                _captureDevice = await PhotoCaptureDevice.OpenAsync(CameraSensorLocation.Front, best);
            }
            if (Math.Round(best.Width / best.Height, 1) == 1.3)
                _detecteAspectRatio = AspectRatio.R_4_3;
            else
                _detecteAspectRatio = AspectRatio.R_16_9;


            SetOrientation(this.Orientation);
            //Set the VideoBrush source to the camera.

            viewfinderBrush.SetSource(_captureDevice);

这是捕获的代码。

    if (!_capturing)
        {
            _capturing = true;
            _captureMemoryStream = new MemoryStream();
            _thumbnailMemoryStream = new MemoryStream();
            CameraCaptureSequence sequence = _captureDevice.CreateCaptureSequence(1);
            sequence.Frames[0].CaptureStream = _captureMemoryStream.AsOutputStream();
            sequence.Frames[0].ThumbnailStream = _thumbnailMemoryStream.AsOutputStream();
            await _captureDevice.PrepareCaptureSequenceAsync(sequence);
            await sequence.StartCaptureAsync();
            _capturing = false;

            _captureDevice.SetProperty(KnownCameraPhotoProperties.LockedAutoFocusParameters, AutoFocusParameters.None);
            //Set the stream position to the beginning.
            _captureMemoryStream.Seek(0, SeekOrigin.Begin);
            await _viewModel.CurrentSession.SavePictureAsync(_captureMemoryStream);

        }

有什么想法吗?

最佳答案

好的,我自己发现了问题。在我的旋转逻辑中,我使用了错误的属性来告诉捕获设备如何处理手机的当前方向。 我用过:

_captureDevice.SetProperty(KnownCameraGeneralProperties.SpecifiedCaptureOrientation, rotation);

正确的是:

_captureDevice.SetProperty( KnownCameraGeneralProperties.EncodeWithOrientation, rotation);

关于windows-phone-8 - 使用照片捕获设备捕获照片时方向错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20259229/

相关文章:

Android 无法使用前置摄像头录制视频,MediaRecorder 启动失败 : -19

java - Android MediaRecorder 崩溃

c# - 如何在 Wp7 应用程序中处理 Web 浏览器的前后导航

c# - 在 Windows Phone 8.1 运行时获取音乐文件太慢

ios - 相机对焦 ios

c# - 在 WP7 中预初始化 BackgroundAudioPlayer?

windows - Windows Phone 8 应用程序能否在 Windows 10 Mobile 上运行

c# - 我们可以提交基于html的windows phone 8 app吗?

c# - 如何使 Windows Phone 8 模拟器与 Windows 8.1 兼容?

windows-phone-7 - Windows Phone 7 项目无法正确更新