I want to use CameraCaptureTask on WP7 to get the image from the phone and manipulate it. My code is:
CameraCaptureTask cameraCaptureTask; public MainPage() { InitializeComponent(); try { cameraCaptureTask = new CameraCaptureTask(); cameraCaptureTask.Completed += new EventHandler<PhotoResult>(cameraCaptureTask_Completed); } catch (System.InvalidOperationException ex) { MessageBox.Show(ex.Message); } } private void button1_Click(object sender, RoutedEventArgs e) { try { cameraCaptureTask.Show(); } catch (System.InvalidOperationException ex) { MessageBox.Show(ex.Message); } } void cameraCaptureTask_Completed(object sender, PhotoResult e) { MessageBox.Show("event: " + e.TaskResult.ToString()); if (e.TaskResult == TaskResult.OK) { BitmapImage bmp = new BitmapImage(); bmp.SetSource(e.ChosenPhoto); image1.Source = bmp; } } }
The problem is that every time I press button1, the event is raised, but the value is TaskResult.Cancel instad OK. In addition, the camera does not display on the phone.
Any idea? Thanks
windows-phone-7
user422688
source share