make image keep ratio and don't exceeding the frame

Hi,Dr Ji

     I have done some works about the image display.

     I made the image keep ratio and don't exceeding the frame.

     Please check it.

     Thanks!