// wf1.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Drawing;
using System.Drawing.Imaging;

public partial class wf1 : System.Web.UI.Page
{
    private const int    IMAGE_WIDTH  = 320;
    private const int    IMAGE_HEIGHT = 240;
    private const string IMAGE_FORMAT = "image/gif";

    private Bitmap     _bitmap;
    private Graphics   _graphics;
    private Font       _font      = new Font ("굴림", 8);
    private SolidBrush _fontBrush = new SolidBrush(Color.Black);
    private SolidBrush _fillBrush = new SolidBrush(Color.Yellow);
    private string     _label     = "테스트";

    protected void Page_Load(object sender, EventArgs e)
    {
        _bitmap = new Bitmap(IMAGE_WIDTH, IMAGE_HEIGHT, PixelFormat.Format32bppArgb);

        _graphics = Graphics.FromImage(_bitmap);

        _graphics.FillRectangle(_fillBrush, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);
        _graphics.DrawString   (_label, _font, _fontBrush, 10, 10);

        Response.ContentType = IMAGE_FORMAT;
        _bitmap.Save(Response.OutputStream, ImageFormat.Gif);
    }
}

Posted by 셈말짓기 :