这似乎正是你(和我)正在寻找的: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)
| 归档时间: |
|
| 查看次数: |
10393 次 |
| 最近记录: |