Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Uniform Scaling

 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone know a good tutorial on how to uniformly resize an image is java?

Thanks,

Luke
 
Joe Ess
Bartender
Pie
Posts: 9258
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what you mean by "uniformly" but java.awt.Image has a getScaledInstance(int width, int height, int hints) method.
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 9258
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perfect! Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic