CameraCaptureTask的用法
2010-08-31 11:41
316 查看
首先要引用相关的名字空间:using Microsoft.Phone.Tasks;
然后在Page里定义一个变量:CameraCaptureTask cameraCaptureTask;
然后要在Page的Constructor里添加实例化和关联Completed事件处理方法:
cameraCaptureTask = new CameraCaptureTask();
cameraCaptureTask.Completed += new EventHandler<PhotoResult>(cameraCaptureTask_Completed);
如下代码所示:
代码
void cameraCaptureTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
BitmapImage bmp = new BitmapImage();
bmp.SetSource(e.ChosenPhoto);
//save the captured photo to settings
(Application.Current as App).photoTaked = new BitmapImage();
(Application.Current as App).photoTaked = bmp;
//MessageBox.Show(e.OriginalFileName);
}
else
{
(Application.Current as App).photoTaked = null;
}
}
然后是在调用摄像头的地方加入show()方法:
void retake_Click(object sender, EventArgs e)
{
cameraCaptureTask.Show();
}
然后在Page里定义一个变量:CameraCaptureTask cameraCaptureTask;
然后要在Page的Constructor里添加实例化和关联Completed事件处理方法:
cameraCaptureTask = new CameraCaptureTask();
cameraCaptureTask.Completed += new EventHandler<PhotoResult>(cameraCaptureTask_Completed);
如下代码所示:
代码
void cameraCaptureTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
BitmapImage bmp = new BitmapImage();
bmp.SetSource(e.ChosenPhoto);
//save the captured photo to settings
(Application.Current as App).photoTaked = new BitmapImage();
(Application.Current as App).photoTaked = bmp;
//MessageBox.Show(e.OriginalFileName);
}
else
{
(Application.Current as App).photoTaked = null;
}
}
然后是在调用摄像头的地方加入show()方法:
void retake_Click(object sender, EventArgs e)
{
cameraCaptureTask.Show();
}
相关文章推荐
- Windows Phone开发(23):启动器与选择器之CameraCaptureTask和PhotoChooserTask
- Windows Phone开发(23):启动器与选择器之CameraCaptureTask和PhotoChooserTask
- Windows Phone开发(23):启动器与选择器之CameraCaptureTask和PhotoChooserTask .
- Windows Phone开发(23):启动器与选择器之CameraCaptureTask和PhotoChooserTask
- Windows Phone开发(23):启动器与选择器之CameraCaptureTask和PhotoChooserTask
- WP7 真机调试PhotoChooserTask和CameraCaptureTask
- WP7 真机调试PhotoChooserTask和CameraCaptureTask
- Windows Phone开发(23):启动器与选择器之CameraCaptureTask和PhotoChooserTask 转:http://blog.csdn.net/tcjiaan/article/details/7396621
- 【windows phone】启动器与选择器之CameraCaptureTask和PhotoChooserTask【转】
- Windows Phone开发(23):启动器与选择器之CameraCaptureTask和PhotoChooserTask
- WP7 真机调试PhotoChooserTask和CameraCaptureTask时无反应
- 启动器和选择器学习-----(2)选择器之照相机(CameraCaptureTask)与照片(PhotoChooserTask)
- WP7备注(9)(CameraCaptureTask+PhotoChooserTask+PictureCollection)
- WP7 真机调试PHOTOCHOOSERTASK和CAMERACAPTURETASK
- CTaskDialog 的用法 例子 Visual C++ MFC 2010
- M6: 使用摄像头(CameraCaptureUI)
- WINDOWS TASKKILL命令用法详解
- smarty内置函数capture用法分析
- vtkResetCamera 用法
- FutureTask的用法及两种常用的使用场景