public DrawEllipse ( |
||
pen | ||
rect | ||
return | void |
// Create a Graphics object from an existing image Bitmap bitmap = new Bitmap("image.jpg"); Graphics graphics = Graphics.FromImage(bitmap); // Create a red pen and brush Pen pen = new Pen(Color.Red); SolidBrush brush = new SolidBrush(Color.Red); // Draw a filled ellipse graphics.FillEllipse(brush, 100, 100, 200, 150); // Save the modified image to a file bitmap.Save("modified_image.jpg");
// Create a Graphics object from a form Graphics graphics = this.CreateGraphics(); // Create a blue pen with a dashed line style and a thickness of 3 Pen pen = new Pen(Color.Blue, 3); pen.DashStyle = DashStyle.Dash; // Draw an ellipse with the blue pen graphics.DrawEllipse(pen, 100, 100, 200, 150);In both examples, the DrawEllipse method is used to draw an ellipse on a graphics surface. The first example fills the ellipse with a red color, while the second example draws a blue dashed ellipse with a thick outline. The package library used in these examples is System.Drawing.