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
LVL 25
InteractiveMindAsked:
Who is Participating?
 
zzynxSoftware engineerCommented:
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
0
 
zzynxSoftware engineerCommented:
scalex = 800 * 1024
scaley = 600 * 768
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
zzynxSoftware engineerCommented:
Typo:
scalex = 800 / 1024
scaley = 600 / 768

of course
0
 
objectsCommented:
heres an example showing how to create thumbnails:

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

Image scaled = image.getScaledInstance(width, height ,Image.SCALE_FAST);
0
 
InteractiveMindAuthor Commented:
Thank you. :)
0
 
zzynxSoftware engineerCommented:
Thanks
0
 
objectsCommented:
no worries :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.