ratio = MIN( maxWidth / width, maxHeight/ height );
width = ratio * width;
height = ratio * height;
Make sure all divides are floating-point.
ratio = MIN( maxWidth / width, maxHeight/ height );
width = ratio * width;
height = ratio * height;
Make sure all divides are floating-point.