圖像獲取: 保存圖像 (BMP)

下面這個示例程序將介紹如何使用IC Imaging Control停止圖像數據流,將定格的圖像保存為一個BMP文件。
語言:.NET C#/Visual Basic
版本:3.0.3
发布于:2005年4月7日
作者:IC Imaging Control 技術支持部
需求:IC Imaging Control >2.1
由WDM數據流類驅動程序驅動的相機、視頻轉換器或圖像採集卡

示例程序窗口如下圖所示:

The Testdialog of IC Imaging Control,

首先,向程序窗體中放置IC Imaging Control控件和一個用於保存圖像的按鈕。

程序開始後首先調用內置對話框(.ShowDeviceSettingsDialog)用於選擇視頻設備。 而後通過.LiveStart顯示設備傳來的現場畫面數據流:

[C#]
private void Form1_Load(object sender, System.EventArgs e)
{
    icImagingControl1.ShowDeviceSettingsDialog();
    if( icImagingControl1.DeviceValid )
    {
        icImagingControl1.LiveStart();
    }
    else
    {
        Close();
    }
}

用戶點擊"Save BMP"後,.MemorySnapImage就會從現場視頻數據流中抓取一幀圖像 並將其寫入環形緩存。之後dlg.ShowDialog()調用Windows保存文件對話框。 最後.MemorySaveImage將緩存中的圖像寫入文件:

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

    SaveFileDialog dlg = new SaveFileDialog();
    dlg.AddExtension = true;
    dlg.DefaultExt = "bmp";
    dlg.Filter = "BMP Images (*.bmp)|*.bmp||";
    dlg.OverwritePrompt = true;

    if( dlg.ShowDialog() == DialogResult.OK )
    {
        icImagingControl1.MemorySaveImage( dlg.FileName );
    }
}

相關源代碼示例

責任聲明
IC Imaging Control源代碼庫中的所有代碼均只用於教學目的,The Imaging Source Europe GmbH作為IC Imaging Control的開發製造商,不對任何由於使用本文或其中源代碼所產生的後果承擔責任。

该网站为The Imaging Source网络的一部分。其它的站点包括 公司, Imaging, 天文相機, Astronomy Cameras Blog, Blog caméras d'astronomie, 天文相機有獎競答, TX Text Control, LiveDocx, phpLiveDocxForum.