Here's a nice stack overflow that shows you how to do it: https://stackoverflow.com/questions/9994493/scale-image-to-fit-a-bounding-box