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.FillRectangle(Brushes.Cornsilk, 0, 0, bitMap.Width, bitMap.Height);

                    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;

            }

        }

    }

}

  

你可能感兴趣的:(C#)