• Post Reply Bookmark Topic Watch Topic
  • New Topic

Zoom Action  RSS feed

 
shansi raj
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone tell how to zoom an image?
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have options. If you are showing your image in a JLabel you can make a new BufferedImage, use a scale instance of AffineTransform to scale the original image on the fly as you draw it into the BufferedImage, wrap this (BufferedImage) in a new ImageIcon and set it into the JLabel with the setIcon method.
If you are drawing the image in a JComponents paintComponent method you can use AffineTransform to scale the image as you draw it. Save the scale value in a member variable if you want to change it with user interaction.
Examples have been posted in this forum.
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Craig Wood:
you can make a new BufferedImage, use a scale instance of AffineTransform to scale the original image on the fly as you draw it into the BufferedImage


Craig,

It would be great, if you throw some more light on this statement.

I am not able to understand this line only.

 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!