错误"参数无效同时将字节转换为图像 [英] Error" Parameter is not valid " while converting Bytes into Image
本文介绍了错误"参数无效同时将字节转换为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将字节转换为图像,但出现错误
I am converting bytes into an image but I get an error
参数无效
我正在粘贴我的代码.请检查代码并建议我做对还是错.
I am pasting my code. Kindly check the code and suggested that was I am doing right or wrong.
Image arr1 = byteArrayToImage(Bytess);
这是函数.
public static Image byteArrayToImage(byte[] byteArrayIn)
{
if (null == byteArrayIn || byteArrayIn.Length == 0)
return null;
MemoryStream ms = new MemoryStream(byteArrayIn);
try
{
Process currentProcess1 = Process.GetCurrentProcess();
Image returnImage = Image.FromStream(ms);
return returnImage;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
我应用了许多技术和解决方案,但对我不起作用
I applied many techniques and solutions but it did not work for me
您的回答将不胜感激.
谢谢
推荐答案
试试这个
public Image byteArrayToImage(byte[] byteArrayIn)
{
System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter();
Image img = (Image)converter.ConvertFrom(byteArrayIn);
return img;
}
这篇关于错误"参数无效同时将字节转换为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文