Opens a LUT and returns it as a LUT object.
(String pathOrURL)
| 301 | |
| 302 | /** Opens a LUT and returns it as a LUT object. */ |
| 303 | public static LUT openLut(String pathOrURL) { |
| 304 | boolean noError = pathOrURL.startsWith("noerror:"); |
| 305 | if (noError) |
| 306 | pathOrURL = pathOrURL.substring(8); |
| 307 | FileInfo fi = new FileInfo(); |
| 308 | fi.reds = new byte[256]; |
| 309 | fi.greens = new byte[256]; |
| 310 | fi.blues = new byte[256]; |
| 311 | fi.lutSize = 256; |
| 312 | int nColors = 0; |
| 313 | if (pathOrURL.contains("://")) { |
| 314 | fi.url = pathOrURL; |
| 315 | fi.fileName = ""; |
| 316 | } else { |
| 317 | OpenDialog od = new OpenDialog("Open LUT...", pathOrURL); |
| 318 | fi.directory = od.getDirectory(); |
| 319 | fi.fileName = od.getFileName(); |
| 320 | if (fi.fileName==null) |
| 321 | return null; |
| 322 | } |
| 323 | LutLoader loader = new LutLoader(); |
| 324 | loader.suppressErrors = noError; |
| 325 | boolean ok = loader.openLut(fi); |
| 326 | if (ok) |
| 327 | return new LUT(fi.reds, fi.greens, fi.blues); |
| 328 | else |
| 329 | return null; |
| 330 | } |
| 331 | |
| 332 | /** Opens an NIH Image LUT, 768 byte binary LUT or text LUT from a file or URL. */ |
| 333 | boolean openLut(FileInfo fi) { |
no test coverage detected