1 protected void Page_Load(object sender, EventArgs e)
2 {
3 Image img = new Bitmap(Server.MapPath("/Libs/imgs/btn.png"));
4 Response.Write("<img src='data:image/jpeg;base64," + ImageToBase(img, System.Drawing.Imaging.ImageFormat.Jpeg) + "' />");
5 }
6 public string ImageToBase(Image image, System.Drawing.Imaging.ImageFormat format)
7 {
8 using (MemoryStream ms = new MemoryStream())
9 {
10 // Convert Image to byte[]
11 image.Save(ms, format);
12 byte[] imageBytes = ms.ToArray();
13
14 // Convert byte[] to Base64 String
15 string base64String = Convert.ToBase64String(imageBytes);
16 return base64String;
17 }
18 }
中山赢友网络科技有限公司(http://www.winu.net/)承接IOS、Android、Window Phone 8+、Window 10 App应用开发,IOS、Android、Window Phone 8+游戏开发,.NET/PHP软件系统开发,HTML5网站、游戏、微官网开发。欢迎致电:0760-88809987、18676265646 陈先生。