I am trying to learn to do things the IJ2 way. What’s the cleanest
way to open an in-jar resource as an Img<T>?
For example, is it possible to pass something like a
path-to-jar-resource String to ImgOpener.openImgs()?
Or might it be possible to directly wrap or convert a
sun.awt.image.ToolkitImage to an Img<T> without first
converting it to an ImagePlus?
Here is my non-pure-IJ2 way to open a jar image.
jar tf myPlugin.jar ... myPackage/ myPackage/MyPlugin.class resources/ resources/myImage.jpg
My code (in MyPlugin.java):
URL url = getClass().getResource ("/resources/myImage.jpg"); Image myImage = Toolkit.getDefaultToolkit().getImage(url); ImagePlus myImagePlus = new ImagePlus("myImagePlus", myImage); Img<T> myImgT = (Img<T>) ImagePlusAdapter.wrap (myImagePlus);
(url is of specific type java.net.URL, and myImage is of type
This works, all is good, but is it possible to replace these calls (or
some of them) by a single IJ2 call (or at least fewer IJ2 calls)?
I’m just looking for the “IJ2-approved” way of doing this.