Saving an Image (BMP) Short source code snippet that illustrates how to freeze an image data stream and save the frozen image as a BMP file.
The window of the resulting application looks as follows: First of all, IC Imaging Control and a button to save an image to file are dragged onto the form. The program starts by activating a built-in dialog box that enables the end user to select a video capture device (.ShowDeviceSettingsDialog). Then, the live image data stream from the video capture device is displayed, using .LiveStart: C# private void Form1_Load(object sender, System.EventArgs e) { icImagingControl1.ShowDeviceSettingsDialog(); if( icImagingControl1.DeviceValid ) { icImagingControl1.LiveStart(); } else { Close(); } } When the user clicks "Save BMP", .MemorySnapImage grabs an image from the image data stream and writes it to the internal ring buffer. On completion, dlg.ShowDialog() activates the Windows dialog box, so the end user can save the image to disk. In the last step, .MemorySaveImage writes the buffered image to file: C# private void btnSaveBMP_Click(object sender, System.EventArgs e) { icImagingControl1.MemorySnapImage(); SaveFileDialog dlg = new SaveFileDialog(); dlg.AddExtension = true; dlg.DefaultExt = "bmp"; dlg.Filter = "BMP Images (*.bmp)|*.bmp||"; dlg.OverwritePrompt = true; if( dlg.ShowDialog() == DialogResult.OK ) { icImagingControl1.MemorySaveImage( dlg.FileName ); } } |