光栅扫描二维多边形多边形、光栅

2023-09-10 23:36:38 作者:你就是我的咒語

我需要从psented为点列表的封闭2D多边形重新$ P $创建一个二进制位。能否请你点我既高效又足够简单的算法来做到这一点,或者,甚至更好,一些C ++ code?

I need to create a binary bitmap from a closed 2D polygon represented as a list of points. Could you please point me to efficient and sufficiently simple algorithms to do that, or, even better, some C++ code?

非常感谢!

PS:我想避免添加依赖到我的项目。然而,如果你提出一个开放源码库,我总是看code,所以它可能是有用的了。

PS: I would like to avoid adding a dependency to my project. However if you suggest an open-source library, I can always look at the code, so it can be useful too.

推荐答案

你想要的魔谷歌的短语或者是非零缠绕规则或偶奇多边形填充。

The magic google phrase you want is either "non-zero winding rule" or "even odd polygon fill".

请参阅维基百科的条目:

See the wikipedia entries for:

非零缠绕规则 偶奇多边形填充 non-zero winding rule even odd polygon fill

两者都非常容易实现,足够快对于大多数用途。与一些聪明,也可以由抗锯齿以及

Both are very easy to implement and sufficiently fast for most purposes. With some cleverness, they can be made antialiased as well.