Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Inconsistent getScaledInstance behaviour - Help!

0 views
Skip to first unread message

Gary

unread,
Sep 22, 2000, 3:00:00 AM9/22/00
to
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:

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;
}


0 new messages