コード例 #1
0
ファイル: FileOpener.java プロジェクト: earrouvi/PAPPL
 /** Reads the pixel data from an image described by a FileInfo object. */
 Object readPixels(FileInfo fi) {
   Object pixels = null;
   try {
     InputStream is = createInputStream(fi);
     if (is == null) return null;
     ImageReader reader = new ImageReader(fi);
     pixels = reader.readPixels(is);
     minValue = reader.min;
     maxValue = reader.max;
     is.close();
   } catch (Exception e) {
     if (!Macro.MACRO_CANCELED.equals(e.getMessage())) IJ.handleException(e);
   }
   return pixels;
 }
コード例 #2
0
ファイル: DragAndDrop.java プロジェクト: Jondeen/imagej1
 /**
  * Open a file. If it's a directory, ask to open all images as a sequence in a stack or
  * individually.
  */
 public void openFile(File f) {
   if (IJ.debugMode) IJ.log("DragAndDrop.openFile: " + f);
   try {
     if (null == f) return;
     String path = f.getCanonicalPath();
     if (f.exists()) {
       if (f.isDirectory()) openDirectory(f, path);
       else {
         if (openAsVirtualStack && (path.endsWith(".tif") || path.endsWith(".TIF")))
           (new FileInfoVirtualStack()).run(path);
         else (new Opener()).openAndAddToRecent(path);
         OpenDialog.setLastDirectory(f.getParent() + File.separator);
         OpenDialog.setLastName(f.getName());
       }
     } else {
       IJ.log("File not found: " + path);
     }
   } catch (Throwable e) {
     if (!Macro.MACRO_CANCELED.equals(e.getMessage())) IJ.handleException(e);
   }
 }