【C#】Image和Byte[]互转

 

/// <summary>
/// Image转成byte[]
/// </summary>
private byte[] ImageToByte(Image image)
{
    MemoryStream ms = new MemoryStream();
    image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
    return ms.ToArray();
}

/// <summary>
/// byte[]转成Image
/// </summary>
private Image ByteToByte(byte[] imgByte)
{
    return Image.FromStream(new MemoryStream(imgByte));
}

 

相关推荐
©️2020 CSDN 皮肤主题: 精致技术 设计师:CSDN官方博客 返回首页