<% @ Page contenttype = "image/GIF" %>
<% @ Import namespace = "system. Drawing" %>
<% @ Import namespace = "system. Drawing. Imaging" %>
<% @ Import namespace = "system. Drawing. Text" %>
<SCRIPT runat = "server" Language = "C #">
Void page_load (Object sender, eventargs E)
{
Bitmap objbitmap;
Graphics objgraphics;
// Create a canvas
Objbitmap = new Bitmap (400,440 );
Objgraphics = graphics. fromimage (objbitmap );
// Fill in the background
Objgraphics. Clear (color. White );
// Draw a pie chart
Pen P = new pen (color. Yellow, 0 );
Rectangle rect = new rectangle (10, 10, 380,380 );
Objgraphics. drawellipse (p, rect );
// Fill the pie chart
Brush b1 = new solidbrush (color. Red );
Brush b2 = new solidbrush (color. Green );
Brush b3 = new SolidBrush (Color. Blue );
ObjGraphics. FillPie (b1, rect, 0f, 120f );
ObjGraphics. FillPie (b2, rect, 120f, 120f );
ObjGraphics. FillPie (b3, rect, 240f, 120f );
// Draw text
FontFamily fontfml = new FontFamily (GenericFontFamilies. Serif );
Font font = new Font (fontfml, 20 );
SolidBrush brush = new SolidBrush (Color. Blue );
ObjGraphics. DrawString ("ASP. net c # drawing example", font, brush, 50,400 );
// Output and save the image
ObjBitmap. Save (Response. OutputStream, ImageFormat. Gif );
ObjBitmap. Save (Server. MapPath ("x.jpg"), ImageFormat. Jpeg );
// End the painting
ObjBitmap. Dispose ();
ObjGraphics. Dispose ();
}
</Script>
<Html>
<Head runat = "server">
<Title> No title page </title>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
</Div>
</Form>
</Body>
</Html>