Thanks in advance!
Hi,
I've been trying to make a method that returns scaled images to fit
variable canvas sizes.
At present the method returns landscape images exceeding the canvas width.
But if I cycle through 3 or 4 images 3 times then the problem goes and
landscape images fit perfectly.
Portrait images fit ok all the time.
Can anyone shed some light on the problem or give me some ideas on a better
method?
Regards,
Gary
The code:
/*cvw = canvas width
cvh = canvas height*/
public Image rescale(Image photo,int cvw,int cvh)
{
int w = photo.getWidth(this);
int h = photo.getHeight(this);
Image scaledPhoto;
if(w > h)
scaledPhoto = photo.getScaledInstance(cvw,-1,Image.SCALE_FAST);
else
scaledPhoto = photo.getScaledInstance(-1,cvh,Image.SCALE_FAST);
return scaledPhoto;
}