当前位置 : 主页 > 编程语言 > c语言 >

C# GDI graphics.DrawImage 的参数问题

来源:互联网 收集:自由互联 发布时间:2021-06-25
graphics.DrawImage(imageSource, new System.Drawing.Point[] { new System.Drawing.Point( 1 , 1 ), new System.Drawing.Point( 3 , 1 ), new System.Drawing.Point( 1 , 3 ), } ); graphics.DrawImage(imageSource, new System.Drawing.Point[] { new Syst
           graphics.DrawImage(imageSource,
                new System.Drawing.Point[] {
                                new System.Drawing.Point(1,1),
                                new System.Drawing.Point(3, 1),
                                new System.Drawing.Point(1, 3),
                        }
            );
            graphics.DrawImage(imageSource,
                new System.Drawing.Point[] {
                                new System.Drawing.Point(1,3),
                                new System.Drawing.Point(3, 3),
                                new System.Drawing.Point(1, 5),
                        }
            );

对于如上代码,

传入平行的点坐标,包含的点实际上每个都有3*3=9个点。

实际绘制的点只有 (2,2),(5,5) 两个点

所以如果要绘制到(1,1)(1,2)两个点需要这样设置参数

            graphics.DrawImage(imageSource,
                 new System.Drawing.Point[] {
                                            new System.Drawing.Point(-1,-1),
                                            new System.Drawing.Point(1, -1),
                                            new System.Drawing.Point(-1, 1),
                         }
             );
            graphics.DrawImage(imageSource,
                new System.Drawing.Point[] {
                                    new System.Drawing.Point(-1,0),
                                    new System.Drawing.Point(1, 0),
                                    new System.Drawing.Point(-1, 2),
                        }
            );
网友评论