protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "image/jpeg";
// Create a Bitmap instance that's 468x60, and a Graphics instance
const int width = 300, height = 300;
Bitmap objBitmap = new Bitmap(width, height);
Graphics objGraphics = Graphics.FromImage(objBitmap);
// Create a black background for the border
objGraphics.FillRectangle(new SolidBrush(Color.White), 0, 0, width, height);
//DrawPieChart(ref objGraphics);
DrawRectangle(ref objGraphics);
// Save the image to a file
objBitmap.Save(Response.OutputStream, ImageFormat.Jpeg);
// clean up...
objGraphics.Dispose();
objBitmap.Dispose();
}
private void DrawPieChart(ref Graphics objGraphics)
{
// Create location and size of ellipse.
int x = 50;
int y = 20;
int width = 200;
int height = 200;
// Create start and sweep angles.
int startAngle = 0;
int sweepAngle = 45;
SolidBrush objBrush = new SolidBrush(Color.Aqua);
objGraphics.FillPie(new HatchBrush(HatchStyle.Percent50, objBrush.Color), x,
y , width, height, startAngle, sweepAngle);
objBrush.Color = Color.Red;
objGraphics.FillPie(new HatchBrush(HatchStyle.Percent50, objBrush.Color), x,
y, width, height, startAngle+45, sweepAngle);
}
private void DrawRectangle(ref Graphics objGraphics)
{
SolidBrush objBrush = new SolidBrush(Color.Aqua);
objGraphics.FillRectangle(objBrush, 10, 50, 100, 40);
objBrush.Color = Color.Red;
objGraphics.FillRectangle(objBrush, 10, 100, 100, 40);
}
No comments:
Post a Comment