//需要引入的命名空间
using System;
using System.IO;
using System.Drawing;
using System.Runtime.Serialization.Formatters.Binary; //引入供序列化Image对象使用
//以下为转换方法
//将Image转换为byte[]
public byte[] ConvertImage(Image image)
{
FileStream fs=new FileStream("imagetemp",FileMode.Create,FileAccess.Write,FileShare.None);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs,(object)image);
fs.Close();
fs=new FileStream("imagetemp",FileMode.Open,FileAccess.Read,FileShare.None);
using System;
using System.IO;
using System.Drawing;
using System.Runtime.Serialization.Formatters.Binary; //引入供序列化Image对象使用
//以下为转换方法
//将Image转换为byte[]
public byte[] ConvertImage(Image image)
{
FileStream fs=new FileStream("imagetemp",FileMode.Create,FileAccess.Write,FileShare.None);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs,(object)image);
fs.Close();
fs=new FileStream("imagetemp",FileMode.Open,FileAccess.Read,FileShare.None);