Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在使用图形时获取未处理的异常_C#_Visual Studio_Emgucv - Fatal编程技术网

C# 在使用图形时获取未处理的异常

C# 在使用图形时获取未处理的异常,c#,visual-studio,emgucv,C#,Visual Studio,Emgucv,运行此代码时,我得到未处理的异常: using (Graphics g = Graphics.FromImage(target)) { g.DrawImage(imageInput, new Rectangle(0, 0, target.Width, target.Height), rect, GraphicsUnit.Pixel); } 它说: System.ArgumentNullException:'该值不能为null。参数 姓名:image 有什

运行此代码时,我得到未处理的异常:

using (Graphics g = Graphics.FromImage(target))
 {
   g.DrawImage(imageInput, new Rectangle(0, 0, target.Width, target.Height),
               rect, GraphicsUnit.Pixel);
 }
它说:

System.ArgumentNullException:'该值不能为null。参数 姓名:image


有什么建议吗?

您需要提供源图像
imageInput
不能为空。

这是因为
imageInput
null
<代码>参数名称:图像是重要部分。如果您查看的文档,您将看到它采用了一个
image
参数。这是传递给
DrawImage
的第一个参数,它对应于
imageInput


因此,您需要初始化
imageInput

我已经初始化了:
imageInput=newimage(Openfile.FileName);imageBox1.Image=imageInput
@Chaima Soltani和什么图像格式是
imageInput
?该构造函数(
新映像(Openfile.FileName);
)是否生成有效的.NET映像,因为它不是标准映像<代码>图像这里不是.NET
系统.Drawing.Image
(抽象)类。已完成:
imageInput=新图像(Openfile.FileName);imageBox1.Image=imageInput这里的目标是什么?无法根据您发布的代码做出决定,您是否可以发布相关代码和完整的例外情况请谢谢您的帮助我更改了代码。我使用ROI从图像中提取我想要的部分。如果你想让我把旧的寄出去,我会的!!