【发布时间】:2017-09-08 09:17:52
【问题描述】:
我尝试与Image 合作。它运行良好,但有时我得到“参数无效”异常。我不知道为什么会出现这个问题,请帮助我:
byte[] img = (byte[])PatientData.Rows[index - 1]["Anh"];
MemoryStream ms = new MemoryStream(img);
imgBox.Image.Dispose();
imgBox.Image = Image.FromStream(ms);
using (Bitmap abc = new Bitmap(imgBox.Image)) //Parameter is not valid (Sometimes)
{
using (Image<Gray, byte> xyz = new Image<Gray, byte>(abc))
{
if(Global.xrayPic != null)
{
Global.xrayPic.Dispose();
Global.xrayPic = xyz.Clone();
}
}
}
当我检查它时,我意识到abc == null 的值,它导致了这个异常。我该如何解决这种情况?
【问题讨论】:
-
这个错误发生在哪一行?
-
@Jerodev : 它已经在代码中注释了
-
可能是
imgBox.Image的大小问题 -
您是否能够使用某些始终触发此异常的特定图像可靠地重现它?
-
@Rahul 为什么 imgBox.Image 的大小会影响这种情况?
标签: c# image exception bitmap memorystream