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

前端 未结 3 1834
别那么骄傲
别那么骄傲 2020-12-14 04:04

I need to paint a square image, mapped or transformed to an unknown-at-compile-time four-sided polygon. How can I do this?

Longer explanation

The specific

3条回答
  •  轮回少年
    2020-12-14 04:29

    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.

提交回复
热议问题