C#图片上写文字

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;
            }
        }
    }
}

  

posted @ 2014-06-29 22:43  ICupid  阅读(894)  评论(0编辑  收藏  举报