/** * If edge point [x, y] in array [x0, y0, x1, y1, ...] is outside of the image bound rectangle, * clamps it to the edge of the rectangle. * * @param imageBound the rectangle to clamp edge points to. * @param array an array of points to clamp to the rectangle, gets set to the clamped values. */ public static void getEdgePoints(RectF imageBound, float[] array) { if (array.length < 2) return; for (int x = 0; x < array.length; x += 2) { array[x] = GeometryMathUtils.clamp(array[x], imageBound.left, imageBound.right); array[x + 1] = GeometryMathUtils.clamp(array[x + 1], imageBound.top, imageBound.bottom); } }