嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
打开电脑摄像头或者外接usb摄像头
public partial class MainForm : Form
{
private USBCamera uc = null;
private bool m_bPlay = false;
public MainForm()
{
InitializeComponent();
}
private void MainForm_Load(object sender, EventArgs e)
{
this.uc = new USBCamera();
}
private void buttonPlay_Click(object sender, EventArgs e)
{
this.uc.RealPlay(this.pictureBoxPlay.Handle);
this.m_bPlay = true;
}
private void buttonSnap_Click(object sender, EventArgs e)
{
if (m_bPlay == false)
{
MessageBox.Show("请先打开视频!");
return;
}
Image objImage = this.uc.CapturePicture();
this.pictureBoxImage.Image = this.uc.CapturePicture();
SaveFileDialog sfdlg = new SaveFileDialog();
sfdlg.Filter = "*.jpg|*.png";
if (sfdlg.ShowDialog() == DialogResult.OK)
{
objImage.Save(sfdlg.FileName);
}
}
private void buttonStopPlay_Click(object sender, EventArgs e)
{
this.uc.StopRealPlay();
this.m_bPlay = false;
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
this.uc.StopRealPlay();
this.m_bPlay = false;
}
private void buttonStart_Click(object sender, EventArgs e)
{
this.timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (m_bPlay == false)
{
return;
}
string strPath = Application.StartupPath;
Image objImage = this.uc.CapturePicture();
objImage.Save(strPath "\\" DateTime.Now.ToString("yyyyMMddHHmmss") ".jpg");
}
private void buttonStop_Click(object sender, EventArgs e)
{
this.timer1.Stop();
}
}