如何在给定坐标的图像上绘制圆。例如,我有一个700x400的图像,想在以(320,200)点为中心的图像上画一个圆。
private void DrawGraphics()
{
if (!this.DoubleBuffered)
{
//get rid of flickering while drawing images
this.DoubleBuffered = true;
}
//make sure you have write to the location you plan to save too
var imagePath = @"MyStuff\Image.png";
//Image bmp = new Bitmap(700,400);// you can use an empty image
Image bmp =new Bitmap(new Bitmap(@"MyStuff\img1.jpg"), new Size(700,400));
Graphics gg = Graphics.FromImage(bmp);
float Diameter = 100f;
Point givenPoint = new Point(320, 200);
gg.DrawEllipse(Pens.Blue, givenPoint.X - (Diameter / 2), givenPoint.Y - (Diameter / 2), Diameter , Diameter );
//save the new image
bmp.Save(imagePath);
this.BackgroundImage = bmp;
gg.Dispose();
}