Fix bug in cropToImageEdges() when there might appear more than 2
points.

It was due to rounding endpoints before checking that they are inside
image. Now they rounded after checking.