
| 語言: | Visual Basic 6 |
| 版本: | 3.0.3 |
| 发布于: | 2006年8月20日 |
| 作者: | IC Imaging Control 技術支持部 |
| 需求: | IC Imaging Control 3.0 或更高版本 由WDM數據流類驅動程序驅動的相機、視頻轉換器或圖像採集卡 |
| |
下面的示例程序(Visual Basic™6)對上一節介紹的程序進一步做了擴展, 它將演示如何直接在程序中,而不是通過濾鏡的內置對話框,調節標記過度曝光或曝光不足的像素時的各個參數。
程序窗口如圖所示:

首先在Form1中聲明一個FrameFilter型的變量filter。 這個變量含有幀濾鏡,用於與之交換數據。
Dim filter As FrameFilter 'This variable will hold the Clipping filter
濾鏡提供了下列參數:閾值("Threshold"),參數"ClipAboveThreshold",標記像素時的色彩和模式("FillMode" und "FillColor")。 閾值可通過一個scrollbar sldThreshold控制。一個像素是否被標記通過兩個radio button rbClipAbove和rbClipBelow控制。 程序開始後首先調用兩個在主窗體中初始化控件的函數。
InitControls UpdateControls
函數InitControls初始化scrollbar sldThreshold的最小值與最大值。
Private Sub InitControls() sldThreshold.Min = 0 sldThreshold.Max = 255 End Sub
函數UpdateControls將濾鏡的參數"Enable"、"Threshold"及"ClipAboveThreshold"賦予 複選框 cbEnable、scrollbar sldThreshold 及 radio buttons rbClipAbove und rbClipBelow。
Private Sub UpdateControls() ' Update the "Enable" checkbox. If filter.Parameter("Enable") Then cbEnable.Value = Checked Else cbEnable.Value = Unchecked End If ' Update the radio buttons. If filter.Parameter("ClipAboveThreshold") Then rbClipAbove.Value = True rbClipBelow.Value = False Else rbClipAbove.Value = False rbClipBelow.Value = True End If ' Update the slider. sldThreshold.Value = filter.Parameter("Threshold") txThreshold.Text = sldThreshold.Value End Sub
sldThreshold的事件處理程序將其當前值賦予濾鏡的參數 "Threshold",並使用這個值更新顯示文字 txThreshol。
Private Sub sldThreshold_Scroll() filter.Parameter("Threshold") = sldThreshold.Value txThreshold.Text = sldThreshold.Value End Sub
Radio button rbClipAbove 的事件處理程序將True值賦予濾鏡參數"ClipAboveThreshold", 反選radio button rbClipBelow。rbClipBelow的事件處理程序工作原理相同。
Private Sub rbClipAbove_Click() filter.BeginParameterTransfer filter.Parameter("ClipAboveThreshold") = True filter.EndParameterTransfer rbClipBelow.Value = False End Sub
責任聲明
IC Imaging Control源代碼庫中的所有代碼均只用於教學目的,The Imaging Source Europe GmbH作為IC Imaging Control的開發製造商,不對任何由於使用本文或其中源代碼所產生的後果承擔責任。