Kinect图像数据源处理与应用开发
为应用添加截图功能
在开发从Kinect直接流式传输实时数据的应用后,其功能相对基础。为了增强应用的实用性,我们可以为其添加截图功能。常见的截图方法有从帧中抓取并保存数据、对UI进行快照、保存WriteableBitmap ,其中保存WriteableBitmap 是最实用的方法。
以下是添加截图功能的具体步骤:
1. 添加命名空间引用 :在代码中添加 System.IO 命名空间,以便使用保存图像文件到驱动器的方法。
2. 添加事件处理方法 :在 MainWindow.xaml.cs 中添加截图事件处理方法,代码如下:
//add to the Using section
using System.IO;
//Directly after the MainWindow_Closing method
private void ScreenshotButton_Click(object sender, RoutedEventArgs e)
{
if (this.colorBitmap != null)
{
BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(this.colorBitmap));
string photoLoc = Envir
超级会员免费看
订阅专栏 解锁全文
11

被折叠的 条评论
为什么被折叠?



