Re: Method to get zoomed in or zoomed out AWT image from and ImagePlus or ImageWindow?

Posted by dscho on
URL: http://imagej.273.s1.nabble.com/Method-to-get-zoomed-in-or-zoomed-out-AWT-image-from-and-ImagePlus-or-ImageWindow-tp3688583p3688584.html

Hi,

On Tue, 13 Apr 2010, Bill Mohler wrote:

> ImagePlus.getImage() gives me a nice AWT image.  But it always has the
> dimensions of the 100%-zoomed window.
>
> Is there and equivalent method that will give an AWT image of the
> zoomed-in or zoomed-out image shown in a zoomed ImageCanvas?  It looks
> like ImageCanvas.getImage() gives me an ImagePlus, rather than and AWT
> image.

As far as I can tell, ImageCanvas does not expose the image painted into
the canvas. You'll have to resize it yourself.

On the other hand, you _should_ resize it yourself in any case. ImageJ
uses AWT to resize the image, which is wrong, because it pretends that
pixels are little squares.

For zooming out, use something like
http://pacific.mpi-cbg.de/wiki/index.php/Downsample instead (on that page,
you will see why by the presented images).

For zooming in, I am not aware of an appropriate upsampling plugin, but I
am sure there is one.

Ciao,
Johannes