有没有办法绘制图像以使用4点而不是3点(透视扭曲)
时间:2020-03-05 18:46:05 来源:igfitidea点击:
Graphics.DrawImage很好地支持绘制平行四边形:
Bitmap destImage = new Bitmap(srcImage.Width, srcImage.Height); using (Graphics gr = new Graphics.FromImage(destImage)) { Point[] destPts = new Point[] { new PointF(x1, y1), new PointF(x2, y2), new PointF(x4, y4)}; gr.DrawImage(srcImage, destPts);
如何做4分(显然不支持以下功能,但这是需要的):
Bitmap destImage = new Bitmap(srcImage.Width, srcImage.Height); using (Graphics gr = new Graphics.FromImage(destImage)) { Point[] destPts = new Point[] { new PointF(x1, y1), new PointF(x2, y2), new PointF(x3, y3), new PointF(x4, y4)}; gr.DrawImage(srcImage, destPts); }
解决方案
回答
通常,我们可以使用3x3矩阵来执行此操作,但是Matrix类仅允许我们指定6个值而不是9个值。我们可以在Direct X中执行此操作。
回答
我能找到的最接近的是[http://vckicks.110mb.com/image-distortion.html][1],这是非常漫长的:(