I try to work with Image
. It worked well but sometimes I got “Parameter is not valid” exception. I don't know why that problem occurs, please help me:
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();
}
}
}
And when I checked it, I realize that the value of abc
== null and it leads to this exception. How can I solve this situation?
The problem could be that the method
throws an ArgumentException on invalid picture data and null.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.