Automating the Zoom

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Automating the Zoom

Tony Shepherd
Is there a way to get and set the image-window magnification from inside a
plugin ?

T
Reply | Threaded
Open this post in threaded view
|

Re: Automating the Zoom

Ben.BigHair
Tony wrote:
> Is there a way to get and set the image-window magnification from inside a
> plugin ?
>
> T
>
Hello,

Take a look at the getMagnification() and setMagnification() methods for
ImageCanvas object.  You can get an instance of the ImageCanvas from
ImageWindow objects.

Cheers,
Ben
Reply | Threaded
Open this post in threaded view
|

Re: Automating the Zoom

Tony Shepherd
In reply to this post by Tony Shepherd
The problem is I can change the canvas but not the window. If I go:

imp.getWindow.getCanvas.setMagnification(2.0);

imp.updateAndDraw();   ( ... OR imp.updateAndRepaintWindow();)

then the magnified canvas is displayed inside a 'normal sized' window, i.e.
you just see the top-left portion of the bigger image and you have to drag
the  window from the bottom right corner to see the rest of it.
Reply | Threaded
Open this post in threaded view
|

Re: Automating the Zoom

James Norman
I have some code that if you add the the resizeCanvas(int,int) method of
ImageCanvas, the Image will automatically enlarge to fit the window.  There
is one if statement in it, add this else if to it:

else if( width >= 256 && height >= 256 )
        {
            //TODO: this is how you resize the image by dragging, its having
some problems though
            //todo, figure out how to get rig of the border around the
image....
            double widthIncrease = ((double)width)/256d;
            double heightIncrease = ((double)height)/256d;

            double increase =
widthIncrease>heightIncrease?heightIncrease:widthIncrease;
            setDrawingSize( width, height );
            setMagnification( increase );
            repaint();
        }

I hard coded the default size of my images, you could just derive these
values from the ImagePlus.  May not help you in a plugin unless you can
override the resizeCanvas method in ImageCanvas.

I think you could also do this with window listeners on the ImageWindow
class.

On 2/13/07, Tony Shepherd <[hidden email]> wrote:

>
> The problem is I can change the canvas but not the window. If I go:
>
> imp.getWindow.getCanvas.setMagnification(2.0);
>
> imp.updateAndDraw();   ( ... OR imp.updateAndRepaintWindow();)
>
> then the magnified canvas is displayed inside a 'normal sized' window, i.e
> .
> you just see the top-left portion of the bigger image and you have to drag
> the  window from the bottom right corner to see the rest of it.
>