trouble pasting in plugin

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

trouble pasting in plugin

jvander
I am having a problem with pasting.  I have a workaround, but I would like to know the underlying issue as it may explain other issues I see from time to time.  In the code below I show that I copy the contents of one image into the clipboard, then (not showing all the code below) I make a larger image and then replicate the smaller image over and over to fill the larger image.

When I use IJ.run("Paste"); it works fine

When I use imp1.paste(); it only copies the last location

Below is the code.  Please advise on the difference in behavior.

(Running ImageJ 1.50g4    Java 1.8.0_60 64 bit  Mac OS 10.10.5)

thanks,

Joe
_________________________________

        ImagePlus imp = IJ.getImage();
        IJ.run(imp,"Select All", "");
        imp.copy(false);

/* skip a bit brother *//

        for ( k= 0; k <  factor; k++) {
                        for (l = 0; l <  factor; l++) {
                          iXROI = k *  width;
                    iYROI = l *  width;

                                imp1.setRoi (iXROI, iYROI, width,  width);
                                /*IJ.run("Paste");  this works - copies into all locations*/
                                imp1.paste();   /* this only copies into the last location */
                        }
                }

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

Re: trouble pasting in plugin

Michael Schmid
Hi Joe,

you might try roi.endPaste() after each paste operation, to ensure the
operation is properly completed.
You can get the roi via imp1.getRoi() after imp1.setRoi(...).


Michael
________________________________________________________________
On 08/03/2017 15:22, Joe Vandergracht wrote:

> I am having a problem with pasting.  I have a workaround, but I would like to know the underlying issue as it may explain other issues I see from time to time.  In the code below I show that I copy the contents of one image into the clipboard, then (not showing all the code below) I make a larger image and then replicate the smaller image over and over to fill the larger image.
>
> When I use IJ.run("Paste"); it works fine
>
> When I use imp1.paste(); it only copies the last location
>
> Below is the code.  Please advise on the difference in behavior.
>
> (Running ImageJ 1.50g4    Java 1.8.0_60 64 bit  Mac OS 10.10.5)
>
> thanks,
>
> Joe
> _________________________________
>
>         ImagePlus imp = IJ.getImage();
> IJ.run(imp,"Select All", "");
>         imp.copy(false);
>
> /* skip a bit brother *//
>
> for ( k= 0; k <  factor; k++) {
> for (l = 0; l <  factor; l++) {
>   iXROI = k *  width;
>   iYROI = l *  width;
>
> imp1.setRoi (iXROI, iYROI, width,  width);
> /*IJ.run("Paste");  this works - copies into all locations*/
> imp1.paste();   /* this only copies into the last location */
> }
> }
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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

Re: trouble pasting in plugin

jvander
In reply to this post by jvander
Hello Michael,

The addition of endPaste did indeed fix the issue.  I need to do some more reading on understanding Roi operations.  In any event I have a working plugin.

thanks very much for the help.

Joe

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