Search code examples
graphicsvector2draster

Find out pixels of an image under a vector


This might be a simple problem but I can't manage to solve it.

I've got this heightmap which I need to process. I must allow the user to trace a vector over an image, indicating which "line" of the height map should be processed at a given time.

The question is, once I got the vector traced, how can I find out which pixels of the raster image lie "under" said vector?

It's easy if the vector is horizontal or vertical, or even if it draws a 45º angle, but not with an arbitrary rotation angle.


Solution

  • I'm not completely sure I'm following you, but are you perhaps looking for something like Bresenham's line algorithm?