byte[] byteimg = File.ReadAllBytes(@"\zk.jpg");
/// <summary>
/// 将图片转为字符数组
/// </summary>
/// <param name="img"></param>
/// <returns></returns>
public byte[] ImageToByte(System.Drawing.Image img)
{
MemoryStream ms = new MemoryStream();
byte[] imagedata = null;
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
imagedata = ms.GetBuffer();
return imagedata;
}
/// <summary>
/// 将字符数组转为图片
/// </summary>
/// <param name="byt"></param>
/// <returns></returns>
public System.Drawing.Image ByteToImage(byte[] byt)
{
MemoryStream ms = new MemoryStream(byt);
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
return img;
}