How can we know the polygon contains many pixels?
-
I use a list of points to draw a ploygon,and i want to know how many pixels has be contained,what should i do?
thanks!
-
Study some math. Qt doesn't help you calculate that, but a fair bit of "Geometry":http://en.wikipedia.org/wiki/Geometry will.
-
Your question is a little bit inaccurate and meaningless.
Exact question please. -
Does "this":http://en.wikipedia.org/wiki/Polygon_triangulation help? Anyway, this is not a Qt related question.
-
I don't think so,because when i use red brush to draw this polygon,Qt knows which pixel will be red and paint it red,so I think Qt must konws the count of the red pixels! but I don't konw how to get the count.
-
A QPolygon is a vector of points, so Qt does not know if your polygon is closed or not, and therefore could not know how you want to calculate its surface. At least, this is what I think.
-
The fact that Qt can fill your polygon, does not mean that it knows how many pixels are red. Filling doesn't work that way.
You could of course paint your polygon into a QImage, and can the image line by line to count the number of colored pixels. Not very efficient, but perhaps enough for your goals?
Post 4 of 7