Save a Sequence of Single Images

Short code snippet that illustrates how to save the single images of an image data stream as BMP files (consecutively numbered image sequence).

Language:.NET C#/Visual Basic
Version:3.3
Author:IC Imaging Control Support Department

Requirements:
Software:IC Imaging Control 3.3, Visual Studio™ 2010
Hardware:Camera, converter or grabber with WDM Stream Class drivers.
Download C# sampleSave Image Sequence - C#

The window of the resulting application looks as follows:

The Testdialog of IC Imaging Control,

The sample application allows a sequence of single images to be written to the hard disk.

The program starts by activating the built-in dialog that enables the end user to select a video capture device (.ShowDeviceSettingsDialog). Then, the live image 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 Next Image", .MemorySnapImage grabs an image from the image data stream and writes it into an internal ring buffer. On completion, .MemorySaveImage saves it into a BMP file:

C#
      
private void btnSaveNextImage_Click(object sender, System.EventArgs e)
{
    icImagingControl1.MemorySnapImage();

    string fileName = "Image " + imageNumber + ".bmp";
    icImagingControl1.MemorySaveImage( fileName );

    imageNumber += 1;
}