gdi+ 的 graphicspath

1 篇文章 0 订阅
gdi+的graphicspath很强大,就我的理解是它可以记录下来你绘图的过程,最后一起画出来。

由于我是使用c#编程的,对指针很模糊。gdi+画图,c#的效率是一个问题。如果你要画的东西少,那么你可以一个一个画。但是如果多的话,效率很成问题!

 

我在做一个工程的时候,一个form上要画1500多条直线。如果做个循环再画,那么根本就不刷新了,一直卡在那里。

 

而graphicspath就不会了,你可以使用它的addline()或者addlines()方法。我使用的是addlines()方法,它的参数是一个point数组,

这个方法是指连在一起的线,


    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)  
                };  
    GraphicsPath gPath1= new GraphicsPath();  
                gPath1.AddLines(p1);  
     g.DrawPath(new Pen(Color.Black), path);<pre>效果如图:</pre><pre> </pre><pre><img alt="" src="https://p-blog.csdn.net/images/p_blog_csdn_net/wwei466/EntryImages/20080724/1633525173887236250.jpg">g</pre><pre>raphicspath 还有一个优点,就是它可以添加其他的graphicspath,并且一次绘出。这个优点太棒了。</pre><pre>方法是addPath();可以设置graphicspath之间是否需要连接。</pre><pre>eg:</pre><pre>代码:</pre><pre> </pre><pre class="Csharp" name="code">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();  
                path.AddPath(gPath1, false);   
                path.AddPath(gPath2, false);  
     g.DrawPath(new Pen(Color.Black), path)<pre></pre></pre><pre>如上可以看出,addPath方法有两个参数,其中第二个就是设置是否连接的。</pre><pre>废话少说看效果:</pre><pre><img alt="" src="https://p-blog.csdn.net/images/p_blog_csdn_net/wwei466/EntryImages/20080724/2.jpg"></pre><pre>如果,第二个参数为true,效果如图:</pre><pre><img alt="" src="https://p-blog.csdn.net/images/p_blog_csdn_net/wwei466/EntryImages/20080724/3.jpg"></pre>  

http://blog.csdn.net/vevisoft/article/details/2705938

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值