C#图片与byte[] 数据相互转换

C# code
///
/// 图像转换为Byte数组
///
private byte[] imageToByteArray(Image imageIn)
{
MemoryStream ms = new MemoryStream();
imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Icon);
return ms.ToArray();
}
///
/// Byte数组转换为图像
///
private Image byteArrayToImage(byte[] byteArrayIn)
{
MemoryStream ms = new MemoryStream(byteArrayIn);
Image returnImage = Image.FromStream(ms);
return returnImage;
}

你可能感兴趣的:(byte[])