This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes Uniform Scaling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Uniform Scaling" Watch "Uniform Scaling" New topic
Author

Uniform Scaling

Luke Shannon
Ranch Hand

Joined: Sep 30, 2004
Posts: 239
Anyone know a good tutorial on how to uniformly resize an image is java?

Thanks,

Luke


Luke
SCJP
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8915
    
    8

I don't know what you mean by "uniformly" but java.awt.Image has a getScaledInstance(int width, int height, int hints) method.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Luke Shannon
Ranch Hand

Joined: Sep 30, 2004
Posts: 239
What I mean is, if I know the desired width (or height) I can get an image that doesn't look all distorted when I resize.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8915
    
    8

From the Java API Documentation of the method I mentioned above:
Creates a scaled version of this image. A new Image object is returned which will render the image at the specified width and height by default.
If either width or height is a negative number then a value is substituted to maintain the aspect ratio of the original image dimensions. If both width and height are negative, then the original image dimensions are used.
Luke Shannon
Ranch Hand

Joined: Sep 30, 2004
Posts: 239
Perfect! Thanks.
 
GeeCON Prague 2014
 
subject: Uniform Scaling