DirectoryChooser chooser = new DirectoryChooser(); chooser.setTitle("JavaFX Projects"); File defaultDirectory = new File("c:/dev/javafx"); chooser.setInitialDirectory(defaultDirectory); File selectedDirectory = chooser.showDialog(primaryStage);
var uint8array = new TextEncoder("utf-8").encode("ยข"); var string = new TextDecoder("utf-8").decode(uint8array);
/** Returns the FileInfo of the specified TIFF file. */ public static FileInfo[] getTiffFileInfo(String path) { Opener o = new Opener(); TiffDecoder td = new TiffDecoder(o.getDir(path), o.getName(path)); if (IJ.debugMode) td.enableDebugging(); try { return td.getTiffInfo(); } catch (IOException e) { return null; } }
public void run(String arg) { OpenDialog od = new OpenDialog("Open Raw...", arg); String directory = od.getDirectory(); String fileName = od.getFileName(); if (fileName==null) return; ImportDialog d = new ImportDialog(fileName, directory); d.openImage(); }
boolean showDialog() { OpenDialog od = new OpenDialog("Open Text Image...", null); directory = od.getDirectory(); name = od.getFileName(); if (name!=null) path = directory + name; return name!=null; }
/** Saves the image or stack in TIFF format using a save file dialog. Returns false if the user selects cancel. Equivalent to IJ.saveAsTiff(imp,""), which is more convenient. */ public boolean saveAsTiff() { String path = getPath("TIFF", ".tif"); if (path==null) return false; if (fi.nImages>1) return saveAsTiffStack(path); else return saveAsTiff(path); }
/** Opens the Roi at the specified path. Returns null if there is an error. */ public static Roi open(String path) { Roi roi = null; RoiDecoder rd = new RoiDecoder(path); try { roi = rd.getRoi(); } catch (IOException e) { } return roi; }
private byte[] uncompress(byte[] input) { if (fi.compression==FileInfo.PACK_BITS) return packBitsUncompress(input, fi.rowsPerStrip*fi.width*fi.getBytesPerPixel()); else if (fi.compression==FileInfo.LZW || fi.compression==FileInfo.LZW_WITH_DIFFERENCING) return lzwUncompress(input); else if (fi.compression==FileInfo.ZIP) return zipUncompress(input); else return input; }
double getRational(long loc) throws IOException { long saveLoc = in.getLongFilePointer(); in.seek(loc); double numerator = getUnsignedInt(); double denominator = getUnsignedInt(); in.seek(saveLoc); if (denominator!=0.0) return numerator/denominator; else return 0.0; }
/** Save the image in FITS format using a save file dialog. Returns false if the user selects cancel. */ public boolean saveAsFits() { if (!okForFits(imp)) return false; String path = getPath("FITS", ".fits"); if (path==null) return false; else return saveAsFits(path); }
/** Returns the selected directory. */ public String getDirectory() { OpenDialog.setLastDirectory(dir); return dir; }
/** * @deprecated * replaced by FileSaver.setJpegQuality() */ public static void setQuality(int jpegQuality) { FileSaver.setJpegQuality(jpegQuality); }
/** * Redirects all output sent to <code>System.out</code> and <code>System.err</code> to ImageJ's log console * using the default prefixes. */ public static void redirectSystem(boolean redirect) { if (redirect) redirectSystem(); else revertSystem(); }
public final void readFully(byte[] bytes, int len) throws IOException { int read = 0; do { int l = read(bytes, read, len - read); if(l < 0) break; read += l; } while (read<len); }
Object readRGB48Planar(InputStream in) throws IOException { int channels = fi.samplesPerPixel; if (channels==1) channels=3; Object[] stack = new Object[channels]; for (int i=0; i<channels; i++) stack[i] = read16bitImage(in); return stack; }
public void run(String arg) { OpenDialog od = new OpenDialog("Open Raw...", arg); String directory = od.getDirectory(); String fileName = od.getFileName(); if (fileName==null) return; ImportDialog d = new ImportDialog(fileName, directory); d.openImage(); }
/** Returns the FileInfo of the specified TIFF file. */ public static FileInfo[] getTiffFileInfo(String path) { Opener o = new Opener(); TiffDecoder td = new TiffDecoder(o.getDir(path), o.getName(path)); if (IJ.debugMode) td.enableDebugging(); try { return td.getTiffInfo(); } catch (IOException e) { return null; } }
private byte[] uncompress(byte[] input) { if (fi.compression==FileInfo.PACK_BITS) return packBitsUncompress(input, fi.rowsPerStrip*fi.width*fi.getBytesPerPixel()); else if (fi.compression==FileInfo.LZW || fi.compression==FileInfo.LZW_WITH_DIFFERENCING) return lzwUncompress(input); else if (fi.compression==FileInfo.ZIP) return zipUncompress(input); else return input; }
double getRational(long loc) throws IOException { long saveLoc = in.getLongFilePointer(); in.seek(loc); double numerator = getUnsignedInt(); double denominator = getUnsignedInt(); in.seek(saveLoc); if (denominator!=0.0) return numerator/denominator; else return 0.0; }