我使用以下代码使用 Windows Phone 8 中的 PhotoCaptureDevice 选项拍摄快照。
if (PhotoCaptureDevice.AvailableSensorLocations.Contains(CameraSensorLocation.Back) ||
PhotoCaptureDevice.AvailableSensorLocations.Contains(CameraSensorLocation.Front))
{
// Initialize the camera, when available.
if (PhotoCaptureDevice.AvailableSensorLocations.Contains(CameraSensorLocation.Back))
{
// Use the back camera.
System.Collections.Generic.IReadOnlyList<Windows.Foundation.Size> SupportedResolutions =
PhotoCaptureDevice.GetAvailableCaptureResolutions(CameraSensorLocation.Back);
Windows.Foundation.Size res = SupportedResolutions[0];
d = await PhotoCaptureDevice.OpenAsync(CameraSensorLocation.Back, res);
}
else
{
// Otherwise, use the front camera.
System.Collections.Generic.IReadOnlyList<Windows.Foundation.Size> SupportedResolutions =
PhotoCaptureDevice.GetAvailableCaptureResolutions(CameraSensorLocation.Front);
Windows.Foundation.Size res = SupportedResolutions[0];
d = await PhotoCaptureDevice.OpenAsync(CameraSensorLocation.Front, res);
}
await d.SetPreviewResolutionAsync(new Windows.Foundation.Size(640, 480));
await d.SetCaptureResolutionAsync(new Windows.Foundation.Size(640, 480));
d.SetProperty(KnownCameraGeneralProperties.EncodeWithOrientation,
d.SensorLocation == CameraSensorLocation.Back ?
d.SensorRotationInDegrees : -d.SensorRotationInDegrees);
_device = d;
}
最后,我将此设备设置为视频画笔的来源。但是当应用程序通过按住返回键进入此状态时,我来自休眠状态,它显示空白页面并且不显示任何相机。你能请任何人帮助我吗?