GDI+入门01

来源:互联网 发布:护眼仪哪个牌子好 知乎 编辑:程序博客网 时间:2024/06/08 05:14

           本文章主要是来自http://blog.csdn.net/bobui/article/details/5136635

           自己看了楼主的文章后在加上自己的理解,决定在此基础上完善下,以供大家学习。

            Graphics g = this.CreateGraphics();
            g.SmoothingMode = SmoothingMode.AntiAlias;//消除锯齿
            g.FillRectangle(Brushes.Wheat, this.ClientRectangle);
            Pen myPen1 = new Pen(Color.Red, 10);
            myPen1.LineJoin = LineJoin.Bevel;//指定成斜角的链接
            Rectangle r = new Rectangle(20, 10, 60, 60);
            g.DrawRectangle(myPen1, r);

            Pen myPen2 = new Pen(Color.Red, 10);
            myPen2.LineJoin = LineJoin.Miter;//产生锐角或切除脚
            g.DrawRectangle(myPen2, 100, 10, 60, 60);

            Pen myPen3 = new Pen(Color.Red, 10);
            myPen3.LineJoin = LineJoin.MiterClipped;//产生锐角或者斜角
            g.DrawRectangle(myPen3, 20, 100, 60, 60);

            Pen myPen4 = new Pen(Color.Red, 10);
            myPen4.LineJoin = LineJoin.Round;//圆形连接
            g.DrawRectangle(myPen4, 100, 100, 60, 60);

            效果图如下:

           

 

         在此我也对Miter和MiterClipped属性做了对比:

       代码如下:

      

            Point point1 = new Point(50, 50);
            Point point2 = new Point(100, 25);
            Point point3 = new Point(200, 5);
            Point point4 = new Point(250, 50);
            Point point5 = new Point(300, 100);
            Point point6 = new Point(350, 200);
            Point point7 = new Point(250, 250);

            Point[] p ={
                           point1,
                           point2,
                           point3,
                           point4,
                           point5,
                           point6
                      };
            Pen myPen1 = new Pen(Color.Red, 10);
            myPen1.LineJoin = LineJoin.Miter;
            Graphics g = this.CreateGraphics();
            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.DrawPolygon(myPen1, p);


            Point point11 = new Point(50, 50);
            Point point12 = new Point(100,25);
            Point point13 = new Point(200, 5);
            Point point14 = new Point(250, 50);
            Point point15 = new Point(300, 100);
            Point point16 = new Point(350, 200);
            Point point17 = new Point(250, 250);
            Point[] pp ={
                           point11,
                           point12,
                           point13,
                           point14,
                           point15,
                           point16,
                           point17
                       };
            g.TranslateTransform(500, 0);
            Pen myPen2 = new Pen(Color.Red, 10);
            myPen2.LineJoin = LineJoin.MiterClipped;
            g.DrawPolygon(myPen2, pp);

 

  效果图如下: 

  

 实在没找出什么区别,如果大家有什么意见或者方法可以告诉我下,先谢谢大家了。

 

         本人也是最近才学习GDI+,如有不对之处请大家指正。

 

原创粉丝点击