
This chapter shows you how to adjust image settings such as brightness, contrast, saturation, etc.
The source code for the VB.NET and C# versions of this sample application can be found in the directories samples\VB71\Adjusting Image Settings, samples\c#\Adjusting Image Settings.
Create a new project and add IC Imaging Control to the form. Before you run the program, select the video device, input and video format as shown in the FirstSteps chapter. Alternatively, run the program without selecting a device. In this case, the program shows the device selection dialog provided by IC Imaging Control. If you close this dialog without having made a selection, the program will display an error message and terminate.
Add a Label control and a Slider to the form. Set the Label control's Caption property to "Brightness".

Image Settings such as brightness are provided through the VCDRangeProperty. To enable easy access to the range properties, this sample uses the VCDSimpleProperty class. This class is stored in the samples\VB71\common and samples\c#\common directory.
Open the "Solution Explorer" and right click on the project. In the context menu that appears, click "Add" and then click "Add Existing Item" in the next sub menu. The "Add Existing Item" dialog is shown:

If you are working with Visual Basic, ™, change to the samples/VB71/common. Select the files VCDPropertyID.vb, VCDSimpleModule.vb and VCDSimpleProperty.vb. Now click the "Open" button. The three files are now inserted into your project and are ready for use.
If you are working with C#, change to the samples/c#/common directory. Select the files VCDPropertyID.cs, VCDSimpleModule.cs and VCDSimpleProperty.cs. Now click the "Open" button. The three files are now inserted into your project and are ready for use.
The VCDSimpleProperty and the VCD identifiers are declared in the namespace VCDHelpers.
First of all add a new variable to your form:
[VB.NET]
Private VCDProp As VCDSimpleProperty
[C#]
private VCDSimpleProperty VCDProp;
You then need to initialize the VCDProp variable to get access to the properties of the video capture device.
[VB.NET]
VCDProp = VCDHelpers.VCDSimpleModule.GetSimplePropertyContainer(IcImagingControl1.VCDPropertyItems)
[C#]
VCDProp = VCDHelpers.VCDSimpleModule.GetSimplePropertyContainer(icImagingControl1.VCDPropertyItems);
Then the slider is initialized, so that it has the correct value for minimum and maximum.
After initializing the range, the VCDProp.RangeValue(VCDID_Brightness) return value is used to initialize the thumb position of the slider. A call to the LiveStart method starts the live image display.
[VB.NET]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not IcImagingControl1.DeviceValid Then IcImagingControl1.ShowDeviceSettingsDialog() If Not IcImagingControl1.DeviceValid Then MsgBox("No device was selected") Me.Close() Exit Sub End If End If If IcImagingControl1.DeviceValid = True Then IcImagingControl1.LiveStart() ' Initialize the VCDProp class to access the properties of our ICImagingControl ' object VCDProp = VCDSimpleModule.GetSimplePropertyContainer(IcImagingControl1.VCDPropertyItems) ' Setup the range of the brightness slider. Slider1.Minimum = VCDProp.RangeMin(VCDIDs.VCDID_Brightness) Slider1.Maximum = VCDProp.RangeMax(VCDIDs.VCDID_Brightness) ' Set the slider to the current brightness value. Slider1.Value = VCDProp.RangeValue(VCDIDs.VCDID_Brightness) End If End Sub
[C#]
private void Form1_Load(object sender, System.EventArgs e) { if( !icImagingControl1.DeviceValid ) { icImagingControl1.ShowDeviceSettingsDialog(); if( !icImagingControl1.DeviceValid ) { MessageBox.Show( "No device was selected.","Adjusting Image Setting", MessageBoxButtons.OK,MessageBoxIcon.Information); this.Close(); return; } } if( icImagingControl1.DeviceValid == true) { icImagingControl1.LiveStart(); VCDProp = VCDSimpleModule.GetSimplePropertyContainer(icImagingControl1.VCDPropertyItems); // Setup the range of the brightness slider. Slider1.Minimum = VCDProp.RangeMin(VCDIDs.VCDID_Brightness); Slider1.Maximum = VCDProp.RangeMax(VCDIDs.VCDID_Brightness); // Set the slider to the current brightness value. Slider1.Value = VCDProp.RangeValue[VCDIDs.VCDID_Brightness]; } }
Finally, only a single line of code is required to adjust the brightness setting when the slider is moved:
[VB.NET]
Private Sub Slider1_Scroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles Slider1.Scroll VCDProp.RangeValue(VCDIDs.VCDID_Brightness) = Slider1.Value End Sub
[C#]
private void Slider1_Scroll(object sender, System.EventArgs e) { VCDProp.RangeValue[VCDIDs.VCDID_Brightness] = Slider1.Value; }
You are now ready to run the program, and move the slider's thumb with the mouse to adjust brightness. All image settings are handled in the same way, so once you know how to adjust brightness, you also know how to handle contrast, hue, zoom, and all the other settings.