private void button2_Click(object sender, 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 = capturer.Click(); Bitmap b = new Bitmap(capturer.Width, capturer.Height, capturer.Stride, PixelFormat.Format24bppRgb, m_ip); // If the image is upsidedown b.RotateFlip(RotateFlipType.RotateNoneFlipY); capturer.Dispose(); capturer = null; GC.Collect(); image.Image = b; originalImage = (Image) image.Image.Clone(); disableControl(false); button3.Visible = true; Cursor.Current = Cursors.Default; }
private void button1_Click(object sender, EventArgs e) { capturer = new Capture(cameraIndex, 320, 240, 24, image); disableControl(true); button3.Visible = false; if (originalImage != null) { originalImage.Dispose(); originalImage = null; } }
private void frmTakePhoto_FormClosing(object sender, FormClosingEventArgs e) { if (capturer != null) { capturer.Dispose(); capturer = null; } }