原文:wpf mediakit 摄像头截图

在用VideoCaptureElement的过程中,不知道怎么获得摄像头的截图,纠结了整整一天,

最终在下面的网站上找到了答案,哈哈。(困的都不清醒的大脑,让我耐下心来看英文,上天还是很优待我的)

例子截图:

XAML:

<Window x:Class="Fish.AccountBook.View.Test.CameraWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="CameraWindow" Height="200" Width="300"
xmlns:WPFMediaKit="clr-namespace:WPFMediaKit.DirectShow.Controls;assembly=WPFMediaKit">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<Button Name="button1" Content="截图" Height="23" Width="75" Click="button1_Click" />
</StackPanel>
<WPFMediaKit:VideoCaptureElement x:Name="m_VideoCaptureElement" Grid.Row="1" />
</Grid>
</Window>

CS:

    public partial class CameraWindow : Window
{
public CameraWindow()
{
InitializeComponent(); string[] inputNames = MultimediaUtil.VideoInputNames;
m_VideoCaptureElement.VideoCaptureSource = inputNames[0];
} private void button1_Click(object sender, RoutedEventArgs e)
{
RenderTargetBitmap bmp = new RenderTargetBitmap((int)m_VideoCaptureElement.ActualWidth, (int)m_VideoCaptureElement.ActualHeight, 96, 96, PixelFormats.Rgb24);
bmp.Render(m_VideoCaptureElement);
BitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bmp));
string now = DateTime.Now.Year + "" + DateTime.Now.Month + "" + DateTime.Now.Day + "" + DateTime.Now.Hour + "" + DateTime.Now.Minute + "" + DateTime.Now.Second;
string filename = "D:\\" + now + "pic.jpg";
FileStream fstream = new FileStream(filename, FileMode.Create);
encoder.Save(fstream);
fstream.Close(); }
}

参考:http://wpfmediakit.codeplex.com/

参考:http://wpfmediakit.codeplex.com/discussions/287507

最新文章

  1. MariaDB的GTID复制和多源复制
  2. wex5 实战 用户点评与提交设计技巧
  3. iOS阶段学习第27天笔记(UIButton-UIImageView的介绍)
  4. Linux基础入门(20135207 王国伊)
  5. 2016.03.31,英语,《Vocabulary Builder》Unit 08
  6. POJ3273Monthly Expense(二分)
  7. bigData Ecosystem Unscramble
  8. Linux 学习之防火墙配置
  9. xshell 图形化连接ubuntu
  10. 编译安装httpd 2.4
  11. express学习(三)—— cookie和session
  12. 用golang写了个统计各单位报送的信息数量的微服务
  13. JSON 是个什么??!!!
  14. MySQL及navicat for mysql中文乱码
  15. 『PyTorch x TensorFlow』第六弹_从最小二乘法看自动求导
  16. hdu1686 Oulipo KMP/AC自动机
  17. 全网最详细的CentOS7里如何安装MySQL(得改为替换安装MariaDB)(图文详解)
  18. Vue.js $nextTick
  19. StringBuilder的实现与技巧ZZ
  20. GitLab 502问题的解决

热门文章

  1. LeetCode 之二叉树中序遍历(使用栈实现)
  2. Oracle EBS PO 接收事务处理查不到对应的数据
  3. [SQL Server]利用索引改善sql语句
  4. 如何通过rman的增量备份恢复dataguard中standby端的数据
  5. swift中,Optional、?与!之间的关系
  6. mysql 8.0.11 安装(windows)
  7. matlab 函数句柄@的介绍_什么是函数句柄(转)
  8. 笔记--Yarn
  9. etcd 删除
  10. 20145203Java实验报告四:Android开发基础