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

Help ! getScaledInstance problem.

0 views
Skip to first unread message

zzzzzzzzz!!!!

unread,
Sep 27, 2000, 3:00:00 AM9/27/00
to
Hi all,
I posted this problem to the java help group last week but received no help
yet. I'm hoping someone in this group can help.

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


0 new messages