C# GDI graphics.DrawImage 的参数问题

           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),
                        }
            );

 

posted @ 2019-08-26 11:34  胡正  阅读(4959)  评论(4编辑  收藏  举报