• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Swing Code for image zoom in and out.

 
prajakta shirke
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi.............

I am doing a project where i require image to be zoomed in and out. Can anyone tell me how that can be done.

As i am using java swing as front end language so please , the code in same.???/


Please help.....................
 
Rob Spoor
Sheriff
Posts: 20820
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

If you want to paint an image from the paintComponent method of a component (usually a JPanel), you can use the drawImage of the Graphics object for that. It takes an X and Y position of its top-left corner, and optionally a width and height. If you provide the latter two the image will be scaled to use that size. For instance, to fill a JPanel completely:
If you now resize the panel, the image resizes along with it.

You can now use the same technique to zoom an image. Just use the right X and Y coordinates and the right size.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!