Link to home
Start Free TrialLog in
Avatar of InteractiveMind
InteractiveMindFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Resize Image

Hi..
I'm looking for a simple solution, to resize an image.. perferably some method with this effect:

Image oldImage = new ImageImage("..").getImage();
Image newImage = resizeImage( oldImage, 800, 600 );   // 800px wide, 600px high

Anyone? I'm guessing I need to use the AffineTransform.scale(..) for this; but I don't know what sort of argument I would need to pass...

For example:

   AffineTransform tx = new AffineTransform();
   tx.scale(scalex, scaley);

What would the scalex and scaley need to be, in order to scale it down, from 1024x768 to 800x600 (for example)..
Would it be something like this:

   AffineTransform tx = new AffineTransform();
   tx.scale(0.78125, 0.78125);

??

Cheers.
>> IM
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
scalex - the factor by which coordinates are scaled along the X axis direction
scaley - the factor by which coordinates are scaled along the Y axis direction
scalex = 800 * 1024
scaley = 600 * 768
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
heres an example showing how to create thumbnails:

http://developer.java.sun.com/developer/TechTips/1999/tt1021.html
Which is
>> tx.scale(0.78125, 0.78125);
indeed :°)
you can also use:

Image scaled = image.getScaledInstance(width, height ,Image.SCALE_FAST);
Avatar of InteractiveMind

ASKER

Thank you. :)
Thanks
no worries :)