Windows phone 8相机未初始化 [英] Windows phone 8 Camera is not initialize
本文介绍了Windows phone 8相机未初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好问候
我试图用以下代码初始化相机没有初始化。
hello greetings
I am trying to initialize camera with the following code is not getting initialize.
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
// Initialize the camera, when available.
camera = new PhotoCamera();
// Event is fired when the PhotoCamera object has been initialized.
camera.Initialized += new EventHandler<CameraOperationCompletedEventArgs>(cam_Initialized);
//Set the VideoBrush source to the camera.
viewfinderBrush.SetSource(camera);
}
void cam_Initialized(object sender, CameraOperationCompletedEventArgs e)
{
if (e.Succeeded)
{
this.Dispatcher.BeginInvoke(delegate()
{
MessageBox.Show("Camera initialized.");
});
}
}
protected override void OnOrientationChanged(OrientationChangedEventArgs e)
{
if (camera != null)
{
// LandscapeRight rotation when camera is on back of phone.
int landscapeRightRotation = 180;
// Change LandscapeRight rotation for front-facing camera.
if (camera.CameraType == preferences.CameraDevice.Value) landscapeRightRotation = -180;
// Rotate video brush from camera.
if (e.Orientation == PageOrientation.LandscapeRight)
{
// Rotate for LandscapeRight orientation.
viewfinderBrush.RelativeTransform =
new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = landscapeRightRotation };
}
else
{
// Rotate for standard landscape orientation.
viewfinderBrush.RelativeTransform =
new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = 0 };
}
}
base.OnOrientationChanged(e);
}
提前谢谢
Thank you in advance
推荐答案
先检查一下,然后与你的代码进行比较..
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202956%28v=vs.105%29.aspx?cs-save-lang=1&cs -lang = csharp#code-snippet-3 [ ^ ]
Check this one first and then compare with your code..
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202956%28v=vs.105%29.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-3[^]
这篇关于Windows phone 8相机未初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文