C# 位图->;图像窗口窗体应用程序

C# 位图->;图像窗口窗体应用程序,c#,emgucv,C#,Emgucv,我无法将System.Drawing.Image转换为Emgu.CV.Image。 我可以在formapplication中加载我的图像 string im_name = str[index]; Emgu.CV.Image<Bgr, Byte> img = new Image<Bgr, byte>(im_name); string im_name=str[index]; Emgu.CV.Image img=新图像(im_名称); 但是这段代码给了我无效参数的错误 Sy

我无法将System.Drawing.Image转换为Emgu.CV.Image。 我可以在formapplication中加载我的图像

string im_name = str[index];
Emgu.CV.Image<Bgr, Byte> img = new Image<Bgr, byte>(im_name);
string im_name=str[index];
Emgu.CV.Image img=新图像(im_名称);
但是这段代码给了我无效参数的错误

System.Drawing.Image img_btmap = System.Drawing.Image.FromFile( im_name);

Emgu.CV.Image<Bgr, Byte> img1 = new Image<Bgr, byte>(img_btmap);
System.Drawing.Image img\u btmap=System.Drawing.Image.FromFile(im\u名称);
Emgu.CV.Image img1=新图像(img_btmap);
有人知道为什么??? 关于

将行更改为:

System.Drawing.Bitmap img_btmap = new System.Drawing.Bitmap(im_name);
Emgu.CV.Image
构造函数需要从Image类继承的位图类

请确保稍后处理img_btmap,否则可能会导致文件被锁定

编辑:确保正确处理的最简单方法是使用
使用
块,如下所示:

using (System.Drawing.Bitmap img_btmap = new System.Drawing.Bitmap(im_name))
{
   //.....rest of code comes here.....
}

想详细告诉我们错误吗?是的,或者只是图像(字符串)构造函数。你是对的,我已经用[System.Drawing.Bitmap img_btmap=new System.Drawing.Bitmap(im_name);]完成了它,它可以工作,但我希望得到其他解释,因为MessageBox已经将图像显示为位图。thanx但如何处理和删除文件lock@sayyad位图是图像,但图像不是位图,这就是它以前不工作的原因,请参见我的编辑-“危险”是在垃圾收集发生之前锁定图像文件(例如,您无法删除它)。