clampedTo

fun PixelRect.clampedTo(sourceWidth: Int, sourceHeight: Int): PixelRect?

Clamps this rectangle to lie within a sourceWidth x sourceHeight image, or null if it doesn't overlap the image at all (degenerate). Keeps the platform crop codecs from throwing on an off-image or oversized rect produced by gesture rounding.