
| Language: | .NET C#/Visual Basic |
| Version: | 3.0.3 |
| Released on: | April 9, 1965 |
| Author: | IC Imaging Control Support Department |
| Requirements: | IC Imaging Control >2.1 Camera, converter or grabber with WDM Stream Class drivers. |
| |

This problem is solved using a special frame filter that saves images to JPEG files. The frame filter is included in the sample's setup file. Following functionallity is implemented in the sample:
Most of the listed tasks are explained in the other samples of the code library. Thus only the use of the "Save Image" frame filter will be explained. First of all a variable of type TIS.Imaging.FrameFilter is to be declared on top of the form. This variable is named SnapImageFilter and will be used for accessing the frame filter for image saving.
[VB.NET] Dim SnapImageFilter As TIS.Imaging.FrameFilter
The "Save Image" filter will be loaded in the Form1_load sub. After it has been tried to load the filter, the content of SnapImageFilter is checked whether it is Nothing. If SnapImageFilter is Nothing, the filter has not been loaded. This happens, if the filter file SaveImageFrameFilter.FTF is not located in the application's path or in the IC Imaging Control's OCX path. The IC Imaging Control's OCX path is usualy the Common Files\ICImagingControl3 directory. The sample setup, which can be downloaded from the link above, installs the filter to the correct location.
If the SnapImageFilter has been loaded successfully, it is inserted into the device path of IC Imaging Control.
[VB.NET] SnapImageFilter = IcImagingControl1.FrameFilterCreate("Save Image", "") If SnapImageFilter Is Nothing Then MessageBox.Show("Failed to load the Snap Image filter", "Filter Loading", MessageBoxButtons.OK, MessageBoxIcon.Warning) Else IcImagingControl1.DeviceFrameFilters.Add(SnapImageFilter) End If
The images should be saved using a button on the application's form. Thus a button handler is to be inserted into the source code. There are some checks performed in the button handler btnSnapImage_Click before the image is saved:
The parameter "ImageName" of the SnapImageFilter must be set to a valid file name. This causes the SnapImageFilter to save an image. Since this is a parameter transfer between the application's thread and the IC Imaging Control video thread, this must be set into BeginParameterTransfer and EndParameterTransfer calls. The SnapImageFilter will capture the next incoming image after the parameter "ImageName" has been set.
[VB.NET] Private Sub btnSnapImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSnapImage.Click With IcImagingControl1 If .DeviceValid = True Then If .LiveVideoRunning = True Then If Not SnapImageFilter Is Nothing Then ImageCounter = ImageCounter + 1 Dim ImageFileName As String ImageFileName = String.Format("Image{0}.jpg", ImageCounter) SnapImageFilter.BeginParameterTransfer() ' Passing the image name to the SnapImageFilter will snap the image SnapImageFilter.SetStringParameter("ImageName", ImageFileName) SnapImageFilter.EndParameterTransfer() End If End If End If End With End Sub
Disclaimer
The source code that appears in the IC Imaging Control Source Code Library is indented for educational purposes only. The Imaging Source Europe GmbH, the manufacturer of IC Imaging Control, does not assume any kind of warranty expressed or implied, resulting from the use of the content of this page.