C# 使用GDI+获取不规则图形中所有像素点(扣图)
最开始一个个像素遍历,然后速度很慢,后发现了一种新方法Region.IsVisible
GraphicsPath path = new GraphicsPath() { };
path.AddPolygon(new PointF[] {new PointF(100,100),new PointF(300,300), new PointF(900, 100) , new PointF(900, 700) , new PointF(100, 700) });
Region r = new Region(path);
for (int i = 0; i < 960; i++)
{
for (int j = 0; j < 720; j++)
{
if (r.IsVisible(i, j))
{
pointList2.Add(new Point(i, j));
}
}
}