1

I want to understand more about what I found about all point(s) in a polygon intersecting a bitmap in Android. Say I have a bitmap and I use the getPixels function to retrieve all of my pixel values in that bitmap. Then I draw a polygon of any shape such that part of it intersects with the bitmap. (At any part)

I want then is all of the pixel values of the intersect of the bitmap and the polygon. Here is an example image of what I am talking about: enter image description here

The shaded part is the intersection of pixels of the bitmap (larger rectangle) and the closed area of the polygon(smaller rectangle) that I want

From the post about "Point in Polygon" describes using ray casting, a straight line/ray horizontally across the shape, we find how many times the ray intersects the polygon's vertices. I think my solution is an extension of this concept but I am stuck about my approach.

I thought of having multiple rays and somehow grab the number of times that the pixels of the polygon and the pixels of the bitmap intersect but I believe this approach is not practical.

Can someone help with this issue?

Please do not write up a solution as I want to write one on my own although example code and how it works are appreicated as I am a beginner in Android.

GhostMember
  • 91
  • 1
  • 2
  • 9

0 Answers0