This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes image zoom-in Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "image zoom-in" Watch "image zoom-in" New topic
Author

image zoom-in

meera sood
Ranch Hand

Joined: Dec 18, 2001
Posts: 50
hi!
could anybody help me out with image zoom-in and zoom-out. I am making an applet, wherein on the click of a button, the user should be able to zoom-in successively , and on the click of another button, zoom-out of the image successively. if anybody could help me out in this...
thanx in advance..
meera
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
I've never done this.
I'd try to construct a new image of whatever size I am displaying using a clipping region of the original image effectively zooming in on the original image. To zoom in some more, repeat using some clipping region of the new image. To zoom out, either maintain a collection of images and step backwards through them, or use some clipping region from the original image to construct a new image, etc.
For a more sophisticated approach, you might want to see what the group at Koala Graphics did. They provide an open source, high end, 2D graphics package.
Good Luck.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Shashi Kanta
Ranch Hand

Joined: May 08, 2002
Posts: 89
Hi Meera,
try out the following code:

///
hope u got what u want!
rgds,
Shashi
Shashi Kanta
Ranch Hand

Joined: May 08, 2002
Posts: 89
oh, by the way, if its too small to see, u just copy and paste in onto wordpad.
rgds,
Shashi
meera sood
Ranch Hand

Joined: Dec 18, 2001
Posts: 50
thanx a lot..i tried and it worked!!!
otherwise, i tried using the getScaledInstance() method of java.awt and it also worked.
thanx again...

meera
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: image zoom-in