http://blog.csdn.net/wwei466/article/details/2705938
gdi+的graphicspath很強大,就我的理解是它可以記錄下來你繪圖的過程,最後一起畫出來。
由於我是使用c#編程的,對指針很模糊。gdi+畫圖,c#的效率是一個問題。如果你要畫的東西少,那麼你可以一個一個畫。但是如果多的話,效率很成問題!
我在做一個工程的時候,一個form上要畫1500多條直線。如果做個循環再畫,那麼根本就不刷新了,一直卡在那裡。
而graphicspath就不會了,你可以使用它的addline()或者addlines()方法。我使用的是addlines()方法,它的參數是一個point數組,
這個方法是指連在一起的線,
eg:
Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
Graphics g = Graphics.FromImage(bmp);
g.SmoothingMode = SmoothingMode.AntiAlias;
Point[] p1 = new Point[]{
new Point(0,0),
new Point(0,100),
new Point(100,100),
new Point(100,0),
new Point(200,10),
new Point(100,200)
};
Point[] p2 = new Point[]{
new Point(10,10),
new Point(10,90),
new Point(90,90),
new Point(90,10),new Point(10,10),
};
GraphicsPath gPath1 = new GraphicsPath();
gPath1.AddLines(p1);
GraphicsPath gPath2 = new GraphicsPath();
gPath2.AddLines(p2);
GraphicsPath path = new GraphicsPath();
//addPath方法有兩個參數,其中第二個就是設置是否連接的
path.AddPath(gPath1, false);
path.AddPath(gPath2, false);
g.DrawPath(new Pen(Color.Black), path);
pictureBox1.Image = bmp;