透视图像失真

ove*_*ive 4 .net c# image perspective

我正在处理的应用程序目前需要Perspective Image Distortion的功能.基本上我想要做的是允许用户将图像加载到应用程序中,并根据他们可以指定的4个角点调整其透视图属性.

我看了一下ImageMagic.它有一些扭曲功能,可以进行调整,但速度非常慢,某些输入输出不正确.

你们中的任何人都使用过任何其他库或算法.我在C#编码.

任何指针都将非常感激.

谢谢

Dou*_*g S 6

这似乎正是你(和我)正在寻找的:http: //www.codeproject.com/KB/graphics/YLScsFreeTransform.aspx

它会拍摄一张图像并使用您提供的4个X/Y坐标对其进行扭曲.

快速,免费,简单的代码.经过测试,效果很好.只需从链接下载代码,然后使用FreeTransform.cs,如下所示:

using (System.Drawing.Bitmap sourceImg = new System.Drawing.Bitmap(@"c:\image.jpg")) 
{ 
    YLScsDrawing.Imaging.Filters.FreeTransform filter = new YLScsDrawing.Imaging.Filters.FreeTransform(); 
    filter.Bitmap = sourceImg;
    // assign FourCorners (the four X/Y coords) of the new perspective shape
    filter.FourCorners = new System.Drawing.PointF[] { new System.Drawing.PointF(0, 0), new System.Drawing.PointF(300, 50), new System.Drawing.PointF(300, 411), new System.Drawing.PointF(0, 461)}; 
    filter.IsBilinearInterpolation = true; // optional for higher quality
    using (System.Drawing.Bitmap perspectiveImg = filter.Bitmap) 
    {
        // perspectiveImg contains your completed image. save the image or do whatever.
    } 
} 
Run Code Online (Sandbox Code Playgroud)

  • 这不是一个观点。看看这个:http://forums.getpaint.net/index.php?/topic/16197-perspective-effect-v20-update-030510/ (2认同)
  • @ironic 是对的:这不是透视图,它是梯形变换,这比透视图容易得多。 (2认同)