private static RectangleF GetImageCenterCrop(Size imageSize, Size maxImageSize) { PointF imageCenterPosition = UserPhotoUtilities.GetImageCenterPosition(imageSize, maxImageSize); float width = (float)Math.Min(imageSize.Width, maxImageSize.Width); float height = (float)Math.Min(imageSize.Height, maxImageSize.Height); return(new RectangleF(imageCenterPosition, new SizeF(width, height))); }