C#图片上写文字

时间:2022-09-02 23:47:44
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Drawing; namespace BitMap
{
/// <summary>
/// Image 的摘要说明
/// </summary>
public class Image : IHttpHandler
{ public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/jpeg"; //画板
using (Bitmap bitMap = new Bitmap(100, 100))
{
//画笔
using (Graphics g = Graphics.FromImage(bitMap))
{
g.DrawString("Cupid", new Font("微软雅黑", 20), Brushes.Blue, new Point(10, 5));
bitMap.Save(context.Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
} public bool IsReusable
{
get
{
return false;
}
}
}
}