Acquiring an Image Short source code snippet that illustrates how to snap and display a single image using IC Imaging Control.
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# sample | Acquiring an image - C#

The resulting window of the sample application looks as follows:

First of all, an IC Imaging Control window and picture box are dragged onto the form. The picture box will be used to display the snapped image.

The program starts by calling the built-in dialog box that enabled the user to select a video capture device. This is done by calling .ShowDeviceSettingsDialog. Once a valid video capture device has been selected, it's live image data stream 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 the "Capture" button, .MemorySnapImage snaps an image from the image data stream and copies it into the internal ring buffer.

Now, it is possible to access this image by calling .ImageActiveBuffer. This property contains the last snapped image buffer. The property .ImageActiveBuffer.Bitmap is passed to pictureBox1.Image on the application's form. The snapped image is now displayed in the picture box.

    C#

    private void button1_Click(object sender, System.EventArgs e)
    {
        icImagingControl1.MemorySnapImage();
        pictureBox1.Image = icImagingControl1.ImageActiveBuffer.Bitmap;
    }