Do you need to resize it or scale it to fit a space? They may seem like the same question, but they are not. Scaling is really simple, but you have to think about the space you have. Do you need make the images fit based on height or based on width? In other words you have to ask yourself, It has to be X pixels wide and I don’t care how tall it is or It has to be Y pixels high and I don’t care how wide it is. Of course, you may have to do both to get it fit with in both dimensions.
Lets assume you want to use a tableView that has 100px high rows and you have something like:
local myImage = display.newImage(“mydownloaded.jpg”)
local s = 100 / myImage.height
myImage:scale( s, s )
If you need to constrain on the width:
local s = 100 / myImage.width
myImage:scale( s, s )
If you need to do both:
local s = 100 / myImage.height
if ( s * myImage.width ) > 100 then
s = 100 / myImage.width
end
myImage:scale( s, s )
Rob