2012-09-12 42 views

回答

1

要在Windows Phone 8中使用相机,您需要使用PhotoCamera对象。最好在你的OnNavigatedTo创建这个对象,像这样:

protected override void OnNavigatedTo (System.Windows.Navigation.NavigationEventArgs e) 
{ 
    if (PhotoCamera.IsCameraTypeSupported(CameraType.Primary) == true) 
    { 
     cam = new PhotoCamera(CameraType.Primary); 
     cam.CaptureImageAvailable += new EventHandler<Microsoft.Devices.ContentReadyEventArgs>(cam_CaptureImageAvailable); 
     viewfinderBrush.SetSource(cam); 
    } 
    else 
    { 
     txtMessage.Text = "A Camera is not available on this device."; } 
    } 
} 
// dispose when we leave 
protected override void OnNavigatingFrom (System.Windows.Navigation.NavigatingCancelEventArgs e) 
{ 
    if (cam != null) 
    { 
     cam.Dispose(); 
    } 
} 

要真正从摄像机捕获图像,那么你可以调用CaptureImage凸轮对象方法。