图像获取: 保存图像 (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.