ImageCanvas

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

ImageCanvas

davek604
Hello
I'm trying to get the coordinates of a mouse click on an image. The code I
normally use has stopped working. The cause of the problem is that when I
assign my image to the canvas using

 ImageCanvas canvas = imp.getWindow().getCanvas();

Everything is assigned correctly except for the image size. I'm using
eclipse and when I inspect the canvas variable I see that dstHeight and
dstWidth are set much lower than the actual image size.
Does anyone know of any way of correcting these variables so that the canvas
is the correct size.

Thanks
David



--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: ImageCanvas

Michael Schmid
Hi David,

imp.getWindow().getCanvas() should be fine.

You can get the cursor location with canvas.getCursorLoc() in image
pixel coordinates. This does the transformation from screen coordinates
to image coordinates for you.

Otherwise, it is best to use canvas.offScreenX, offScreen to convert
from screen to image coordinates. These functions do not use dstWidth,
dstHeight.


Michael
________________________________________________________________
On 14.01.19 17:10, davek604 wrote:

> Hello
> I'm trying to get the coordinates of a mouse click on an image. The code I
> normally use has stopped working. The cause of the problem is that when I
> assign my image to the canvas using
>
>   ImageCanvas canvas = imp.getWindow().getCanvas();
>
> Everything is assigned correctly except for the image size. I'm using
> eclipse and when I inspect the canvas variable I see that dstHeight and
> dstWidth are set much lower than the actual image size.
> Does anyone know of any way of correcting these variables so that the canvas
> is the correct size.
>
> Thanks
> David
>
>
>
> --
> Sent from: http://imagej.1557.x6.nabble.com/
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html