更新时间:2023-01-30 16:14:41
您在使用 Windows 窗体吗?并且您必须将字节数组转换为图像才能在图片框中显示.
Are you using Windows Forms? And you must Convert Byte array to Image for displaying it in Picture Box.
public Image byteArrayToImage(byte[] byteArrayIn)
{
MemoryStream ms = new MemoryStream(byteArrayIn);
Image returnImage = Image.FromStream(ms);
return returnImage;
}
你是如何将图像转换为字节数组的.我希望这个问题不存在.您可以使用:
And how did you convert Image to byte array. I hope that problem not there. You can use:
private byte[] ImageToByteArray(string ImageFile)
{
FileStream stream = new FileStream(
ImageFile, FileMode.Open, FileAccess.Read);
BinaryReader reader = new BinaryReader(stream);
// Convert image to byte array.
byte[] photo = reader.ReadBytes((int)stream.Length);
return photo;
}