可以在ASP.NET一般处理程序(即ashx文件)中写以下代码:
Bitmap MyMap = new Bitmap(HttpContext.Current.Server.MapPath("../../Images/pg3.bmp"));
Graphics MyG = Graphics.FromImage(MyMap);
Point p0= new Point(10, 80);
Pen p = new Pen(Color.Black, 3); //定义能力类型坐标
MyG.DrawString(“hello world!!!”,f , new SolidBrush(Color.Red), p0);
context.Response.Clear();
context.Response.ContentType = "Image/Gif";
MyMap.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
MyMap.Dispose();
MyG.Dispose();
context.Response.End();
html页面显示ashx接口中输出的图片信息,代码如下:
<img src="ManagerDo/GetImages/GetEnglishAbility.ashx" width="210px" height="180px" />