I’m working on Android, but this is a java question.
I have an image and an array of points.
I would like to create a new image that has only what’s in the polygon defined by the array of points. What’s not inside I would like to have transparent.
What’s a good way to do this?
Thanks.
If speed is not an option, you can simply test if the polygon contains each point of the resulting image. http://en.wikipedia.org/wiki/Point_in_polygon
If speed is an option, then I would recommend using a scan line filling method to fill only the area covered by the polygon. http://www.cse.ohio-state.edu/~gurari/course/cse693s04/cse693s04su77.html
Both are simple* to implement and I will not explain both here. Just follow the links.