Math: scaling to resolution

Ok this is more of a math issue than an AS issue, but in flash player 10 you can have an area of less than 16777215 pixels in order to make a BitmapData.

The problem is I have an image bigger than this and for some reason I can’t logically develop an equation that will take an image bigger than the resolution and scale it down so it’s right under it in, and was curious if anyone has done this before.

Example: if i was trying to get something under 5,000 pixels and I had an image 300x60 that is a resolution of 18,000 what multiplier would i use on the height and width of the image so it stays the same aspect ratio and stays under 5,000 pixels.

any help would be appreciated.