Skip to content
This repository has been archived by the owner on May 26, 2018. It is now read-only.

Commit

Permalink
Let ImageJ2 intercept loading cached sample images
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Jun 10, 2014
1 parent 2e32b55 commit b3236a8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/main/java/fiji/SampleImageLoader.java
@@ -1,22 +1,20 @@
package fiji;

import ij.IJ;
import ij.ImagePlus;
import ij.Menus;

import ij.io.Opener;
import ij.plugin.PlugIn;
import ij.plugin.URLOpener;

import java.awt.Menu;
import java.awt.MenuItem;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import java.net.URL;
import java.net.URLConnection;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
Expand All @@ -36,8 +34,13 @@ public void run(String arg) {

File cached = getCached(arg);
if (cached != null) try {
IJ.open(cached.getPath());
return;
final ImagePlus imp = IJ.openImage(cached.getPath());
if (imp != null) {
// *sigh* This is copied from the ImagePlus(String pathOrUrl) constructor:
Opener.convertGrayJpegTo8Bits(imp);
imp.show();
return;
}
} catch(Exception e) { e.printStackTrace(); }

new URLOpener().run(arg);
Expand Down

0 comments on commit b3236a8

Please sign in to comment.