Copy and Paste in a plugin

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

Copy and Paste in a plugin

Gabriel Landini
Hi,
Rather than calling:  IJ.run("Copy"); and IJ.run("Paste"); in a plugin, can
somebody please suggest a way to directly copy from an existing ROI in an
ImagePlus and paste it directly into another ROI in a different ImagePlus?  
(the ROIs are the same type and size).

And similarly is there a way to execute a "Duplicate..." command so it is
guaranteed that a particular image is being duplicated ?
I just want the ROI to be duplicated, as when using the Duplicate... command,
but I wonder if calling IJ.run("Duplicate...", "_temp"); one runs the risk (as
in macros) of not accessing the right image if one mistakenly clicks into
another image while the plugin is being executed.

Many thanks

Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: Copy and Paste in a plugin

Michael Schmid
Hi Gabriel,

you could use imp.copy(false) and imp2.paste. It does the same  
without "IJ.run", also using the clipboard.

One level deeper - without the clipboard - I fear that you would have  
to write it yourself, with a loop and ip.getPixel, ip.set (or  
ip.putPixel).

The Blitter commands like ip.copyBits always take a full ip as a  
source; this won't help.

Michael
________________________________________________________________

On 9 Mar 2009, at 15:15, Gabriel Landini wrote:

> Hi,
> Rather than calling:  IJ.run("Copy"); and IJ.run("Paste"); in a  
> plugin, can
> somebody please suggest a way to directly copy from an existing ROI  
> in an
> ImagePlus and paste it directly into another ROI in a different  
> ImagePlus?
> (the ROIs are the same type and size).
>
> And similarly is there a way to execute a "Duplicate..." command so  
> it is
> guaranteed that a particular image is being duplicated ?
> I just want the ROI to be duplicated, as when using the  
> Duplicate... command,
> but I wonder if calling IJ.run("Duplicate...", "_temp"); one runs  
> the risk (as
> in macros) of not accessing the right image if one mistakenly  
> clicks into
> another image while the plugin is being executed.
>
> Many thanks
>
> Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: Copy and Paste in a plugin

Gabriel Landini
On Monday 09 March 2009 14:56:08 Michael Schmid wrote:
> you could use imp.copy(false) and imp2.paste. It does the same
> without "IJ.run", also using the clipboard.

Thank you Michael, yes that is what I was looking for.

> > And similarly is there a way to execute a "Duplicate..." command so
> > it is guaranteed that a particular image is being duplicated ?

For this 2nd question, I found the Duplicater class so I will use just that.

Many thanks again!

Gabriel