cropCameraPreviewToSquare

fun cropCameraPreviewToSquare(cameraPreviewImage: Bitmap, previewBounds: Rect, viewFinder: Rect): Bitmap

Crop the preview image from the camera based on a square surrounding the view finder's position in the preview bounds.

Note: This algorithm makes some assumptions:

  1. the previewBounds and the cameraPreviewImage are centered relative to each other.

  2. the previewBounds circumscribes the cameraPreviewImage. I.E. they share at least one field of view, and the cameraPreviewImage's fields of view are smaller than or the same size as the previewBounds's

  3. the previewBounds and the cameraPreviewImage have the same orientation