private void button1_Click(object sender, System.EventArgs e) { Cursor.Current = Cursors.WaitCursor; // Release any previous buffer if (m_ip != IntPtr.Zero) { Marshal.FreeCoTaskMem(m_ip); m_ip = IntPtr.Zero; } // capture image m_ip = cam.Click(); Bitmap b = new Bitmap(cam.Width, cam.Height, cam.Stride, PixelFormat.Format24bppRgb, m_ip); // If the image is upsidedown b.RotateFlip(RotateFlipType.RotateNoneFlipY); pictureBox1.Image = b; Cursor.Current = Cursors.Default; }
private void button1_Click(object sender, System.EventArgs e) { string csPictureSavePath = ""; csPictureSavePath = textBox_default_file_path.Text; if (common.DoesDirectoryExist(csPictureSavePath) == false) { string csError = ""; common.CreateDirectory("c:\\pbapps\\mugshot\\", ref csError); } Cursor.Current = Cursors.WaitCursor; // Release any previous buffer if (m_ip != IntPtr.Zero) { Marshal.FreeCoTaskMem(m_ip); m_ip = IntPtr.Zero; } // capture image m_ip = cam.Click(); Bitmap b = new Bitmap(cam.Width, cam.Height, cam.Stride, PixelFormat.Format24bppRgb, m_ip); // If the image is upsidedown b.RotateFlip(RotateFlipType.RotateNoneFlipY); pictureBox1.Image = b; string csPictureFileName = ""; //mmddyyhhmmss.jpg DateTime d = DateTime.Now; string dateString = d.ToString("MMddyy_HHmmss"); csPictureFileName = dateString + ".jpg"; string csPictureFullFilename = csPictureSavePath + "\\" + csPictureFileName; pictureBox1.Image.Save(csPictureFullFilename, ImageFormat.Jpeg); listBox2.Items.Add(csPictureFullFilename); Cursor.Current = Cursors.Default; }