aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes zooming an image / imageicon Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "zooming an image / imageicon " Watch "zooming an image / imageicon " New topic
Author

zooming an image / imageicon

tony navaratnam
Greenhorn

Joined: Dec 27, 2006
Posts: 14
I have a basic drawing program that uses a imageicon on a jlabel as a canvas.
An image is chosen and an icon is created from it to use with seticon.It is drawn onto later by getgraphics and then drawLine etc.

Is it possible to zoom the icon of the label using a slider/buttons??
If i could be sent to a example,that would be handy.
If it is possible, can area selected using the mouse be specificallly zoomed??

I already have a built in way to record what has been drawn on the canvas.It records as x-y co-ordinates. what changes will be needed for zooming?
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Is it possible to zoom the icon of the label using a slider/buttons??
Yes. Both work well. With a button you make small increments, eg, 0.01, to the scale (member variable). With a slider you can set the scale directly.
If i could be sent to a example,that would be handy.
Examples have been posted on this forum and on the Java2D forum at sun.
If it is possible, can area selected using the mouse be specificallly zoomed??
Yes. There are many ways to do this. You could scale the entire image with AffineTransform and position it in your label so the (clipping) rectangle is centered. Or you can get a subimage using the rectangle dimensions/location, copy it (to avoid changes made to the subimage causing affects in the source image) and scale to the desired size.
I already have a built in way to record what has been drawn on the canvas.It records as x-y co-ordinates. what changes will be needed for zooming?
Care to properly align the clipping rectangle over the image. If their origins are different you will need to make adjustments to align them to avoid RasterFormatExceptions.
This is based on the assumption that you are using BufferedImages for this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: zooming an image / imageicon