使用System.Drawing命名空间绘制图形
首先引入命名空间
using System.Drawing;
利用Graphics类创建一个椭圆,然后分块,而且用不同的颜色填充 protected void Page_Load(object sender, EventArgs e)
{
Bitmap image = new Bitmap(350, 200);
Graphics g = Graphics.FromImage(image);
g.Clear(Color.White);
Rectangle outline = new Rectangle(10, 5, 300, 100);
g.DrawEllipse(new Pen(Color.Black, 8.0f), outline);
g.FillPie(new SolidBrush(Color.Red), outline, -20f, 120f);
g.FillPie(new SolidBrush(Color.Yellow), outline, 100f, 120f);
g.FillPie(new SolidBrush(Color.Blue), outline, 220f, 100f);
g.FillPie(new SolidBrush(Color.Green), outline, 320f, 40f);
image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
}
{
Bitmap image = new Bitmap(350, 200);
Graphics g = Graphics.FromImage(image);
g.Clear(Color.White);
Rectangle outline = new Rectangle(10, 5, 300, 100);
g.DrawEllipse(new Pen(Color.Black, 8.0f), outline);
g.FillPie(new SolidBrush(Color.Red), outline, -20f, 120f);
g.FillPie(new SolidBrush(Color.Yellow), outline, 100f, 120f);
g.FillPie(new SolidBrush(Color.Blue), outline, 220f, 100f);
g.FillPie(new SolidBrush(Color.Green), outline, 320f, 40f);
image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
}