Image与byte互相转换
public class ChangeImage { /// <summary> /// 将Image转换为byte[] /// </summary> /// <param name="image">Image</param> /// <returns>byte[]</returns> public static byte[] ConvertImage(Image image) { MemoryStream ms = new MemoryStream(); image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] bytes = ms.ToArray(); ms.Close(); return bytes; } /// <summary> /// 将byte[]转换为Image /// </summary> /// <param name="bytes">字节数组</param> /// <returns>Image</returns> public Image ReadImage(byte[] bytes) { MemoryStream ms = new MemoryStream(bytes); Image img = Image.FromStream(ms, true); ms.Close(); return img; } }