如何使用前置摄像头在Windows手机上拍照?

时间:2013-05-20 07:28:19

标签: windows-phone-8

我有两个关于如何在Windows Phone 8上访问相机的问题:

  1. 如何访问前置摄像头拍照?
  2. 如何访问主摄像头的闪光灯/手电筒?

1 个答案:

答案 0 :(得分:0)

这个article from MSDN有一个例子,即访问前后摄像头,以及访问闪存,假设您使用C#(因为您没有指定)。这是创建捕获设备标题下的代码段:

System.Collections.Generic.IReadOnlyList<Windows.Foundation.Size> SupportedResolutions = 
   PhotoCaptureDevice.GetAvailableCaptureResolutions(CameraSensorLocation.Front);
Windows.Foundation.Size res = SupportedResolutions[0];
this.captureDevice = await PhotoCaptureDevice.OpenAsync(CameraSensorLocation.Front, res);

要访问相机的闪光灯,请参阅指定相机属性标题下的代码段:

cam.SetProperty(KnownCameraPhotoProperties.FlashMode, FlashState.On);
cam.SetProperty(KnownCameraGeneralProperties.PlayShutterSoundOnCapture, true);
cam.SetProperty(KnownCameraGeneralProperties.AutoFocusRange, AutoFocusRange.Infinity);

希望这有帮助!