我需要在给定的 X、Y 坐标处绘制小圆圈,但在窗口的面板上可能高达 6000 个圆圈。它非常慢,5000 圈大约需要 2 到 3 秒。我怎么能更快地画这个?
private void drawBGA_Pins(BGAmap PinCordinates, double ExternalZoomFactor, double ExternalOffset_X, double ExternalOffset_Y)
{
Graphics g = this.imgBox.CreateGraphics();
double zoomFactor = (Math.Min(Math.Abs((imgBox.Width) / PinCordinates.width), Math.Abs((imgBox.Height) / PinCordinates.height)))*92/100 * ExternalZoomFactor;
//g.Clear(Color.Transparent); //you can choose another color for your background here.
Pen pen = new Pen(Color.Yellow);
foreach (var p in PinCordinates.pkgCordinates)
{
try
{
g.DrawEllipse(pen, (float)(ExternalOffset_X + (p.X* zoomFactor)), (float)(ExternalOffset_Y + (p.Y* zoomFactor)), 10, 10);
}
catch
{
}
}
}