using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.IO;
using System.Web;
namespace Microsoft.Form.Base
{
class ImageToByte
{
///
/// 图片转换成字节流
///
/// 要转换的Image对象
/// 转换后返回的字节流
public static byte[] ImgToByt(Image img)
{
MemoryStream ms = new MemoryStream();
byte[] imagedata = null;
img.Save(ms, System.Drawing.Imaging.ImageFormat.Png );
imagedata = ms.GetBuffer();
return imagedata;
}
///
/// 字节流转换成图片
///
/// 要转换的字节流
/// 转换得到的Image对象
public static Image BytToImg(byte[] byt)
{
MemoryStream ms = new MemoryStream(byt);
Image img = Image.FromStream(ms);
return img;
}
//
///
/// 根据图片路径返回图片的字节流byte[]
///
/// 图片路径
/// 返回的字节流