有什么方法可以使用 4 个点而不是 3 个点来绘制图像(透视扭曲)
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);
How,你做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);
}
Drawing a parallelgram is nicely supported with 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);
How, do you do 4 points (obviously the following is not supported, but this is what is wanted):
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);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我在CodeProject中找到了以下文章:
YLS 提供的免费图像转换
需要一些工作
也许你可以使用这个:)
I found the following article in CodeProject:
Free Image Transformation By YLS
needs some works
maybe you can use this :)
当考虑 3D 工具如何处理它时......尝试绘制一半的三角形,然后绘制另一半的另一个三角形。 因此,如果您有 A、B、C 点, D; 你可以(使用剪切平面)绘制 A、B、C,然后绘制 B、C、D 或类似的东西。
When thinking of how 3D tools would handle it... try drawing a triangle of one half and then the other triangle for the other half. So if you have points A, B, C, & D; you would draw (with a clipping plane) A, B, C and then B, C, D, or something of the sort.
通常您会使用 3x3 矩阵来执行此操作,但 Matrix 类仅允许您指定 6 个值而不是 9 个值。您也许可以在 Direct X 中执行此操作。
Normally you would do this with a 3x3 Matrix, but the Matrix class only lets you specify 6 values instead of 9. You might be able to do this in Direct X.
我能找到的最接近的是 此信息,它非常滞后。
Closest I can find is this information, which is extremely laggy.