This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!