How can I render a square bitmap to an arbitrary four-sided polygon using GDI?

荒凉一梦 提交于 2019-11-28 19:36:05

You might also want to have a look at Graphics32. The screen shot bewlow shows how the transfrom demo in GR32 looks like

Take a look at 3D Lab Vector graphics. (Specially "Football field" in the demo).


Another cool resource is AggPas with full source included (download)

AggPas is Open Source and free of charge 2D vector graphics library. It is an Object Pascal native port of the Anti-Grain Geometry library - AGG, originally written by Maxim Shemanarev in C++. AggPas doesn't depend on any graphic API or technology. Basically, you can think of AggPas as of a rendering engine that produces pixel images in memory from some vectorial data.

Here is how the perspective demo looks like:

After transformation:

user1118321

The general technique is described in George Wolberg's "Digital Image Warping". It looks like this abstract contains the relevant math, as does this paper. You need to create a perspective matrix that maps from one quad to another. The above links show how to create the matrix. Once you have the matrix, you can scan your output buffer, perform the transformation (or possibly the inverse - depending on which they give you), and that will give you points in the original image that you can copy from.

It might be easier to use OpenGL to draw a textured quad between the 4 points, but that doesn't use GDI like you wanted.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!