scaleAndCenterWithin

Scale up a Size so that it fills a containingSize while maintaining its original aspect ratio.

If using this to project a preview image onto a full camera image, This makes a few assumptions:

  1. the preview image Size and full image containingSize are centered relative to each other

  2. the preview image and the full image have the same orientation

  3. the preview image and the full image share either a horizontal or vertical field of view

  4. the non-shared field of view must be smaller on the preview image than the full image

Note that the Size and the containingSize are allowed to have completely independent resolutions.