private void Device_NewFrame(object sender, NewFrameEventArgs eventArgs) { if (cap) { Wallpaper.Set((Bitmap)eventArgs.Frame.Clone()); cap = false; } }
private void Form1_Load(object sender, EventArgs e) { try { filterInfoCollection = new FilterInfoCollection(FilterCategory.VideoInputDevice); foreach (FilterInfo filterInfo in filterInfoCollection) { comboBox1.Items.Add(filterInfo.Name); } comboBox1.SelectedIndex = 0; device = new VideoCaptureDevice(filterInfoCollection[comboBox1.SelectedIndex].MonikerString); device.Start(); device.NewFrame += Device_NewFrame; } catch { pictureBox2.Image = (Bitmap)Properties.Resources.trololoo; Wallpaper.Set((Bitmap)pictureBox2.Image.Clone()); } }
private void takePhotoBtn_Click(object sender, EventArgs e) { pictureBox2.Image = (Bitmap)pictureBox1.Image.Clone(); Wallpaper.Set((Bitmap)pictureBox2.Image.Clone()); }