/** Opens an NIH Image LUT, 768 byte binary LUT or text LUT from a file or URL. */ boolean openLut(FileInfo fi) { //IJ.log("openLut: " + fi.directory + fi.fileName); boolean isURL = fi.url!=null && !fi.url.equals(""); int length = 0; String path = isURL?fi.url:fi.directory+fi.fileName; if (!isURL) { File f = new File(path); length = (int)f.length(); if (length>10000) { error(path); return false; } } int size = 0; try { if (length>768) size = openBinaryLut(fi, isURL, false); // attempt to read NIH Image LUT if (size==0 && (length==0||length==768||length==970)) size = openBinaryLut(fi, isURL, true); // otherwise read raw LUT if (size==0 && length>768) size = openTextLut(fi); if (size==0) error(path); } catch (IOException e) { IJ.error("LUT Loader", ""+e); } return size==256; }
/** Opens an NIH Image LUT, 768 byte binary LUT or text LUT from a file or URL. */ boolean openLut(FileInfo fi) { //IJ.log("openLut: " + fi.directory + fi.fileName); boolean isURL = fi.url!=null && !fi.url.equals(""); int length = 0; String path = isURL?fi.url:fi.directory+fi.fileName; if (!isURL) { File f = new File(path); length = (int)f.length(); if (length>10000) { error(path); return false; } } int size = 0; try { if (length>768) size = openBinaryLut(fi, isURL, false); // attempt to read NIH Image LUT if (size==0 && (length==0||length==768||length==970)) size = openBinaryLut(fi, isURL, true); // otherwise read raw LUT if (size==0 && length>768) size = openTextLut(fi); if (size==0) error(path); } catch (IOException e) { IJ.error("LUT Loader", ""+e); } return size==256; }