动态图形生成
赢光小虾米 2008-06-06 05:33:41 using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Drawing;
using System.Drawing.Imaging;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Graphics G = null;
Bitmap bmp = null;
//创建图形文件
drawInit(G, bmp, 500, 250);
//画图
G.FillEllipse(new SolidBrush(Color.Blue), 10, 10, 300, 200);
string ImageKey = "IMG_" + Environment.TickCount.ToString();
Application[ImageKey] = bmp;
//设置图形文件
this.Image1.ImageUrl = "ImageServices.ashx?ImageKey="+ImageKey;
}
protected void drawInit(Graphics G,Bitmap bmp,int width,int height)
{
//笔刷
SolidBrush myBrush = null;
//画在bmp上面
bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb);
G = System.Drawing.Graphics.FromImage(bmp);
myBrush = new SolidBrush(Color.FromArgb(0, 224, 224, 224));
//清空全部区域
myBrush.Color = Color.FromArgb(255, 224, 224, 244);
G.FillRectangle(myBrush, 0, 0, width, height);
}
}
上面红字那段有错误。哪个高手帮我改一下。