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从图像中提取我想要的部分。如果你想让我把旧的寄出去,我会的!!