Opens an NIH Image LUT or a 768 byte binary LUT.
(FileInfo fi, boolean isURL, boolean raw)
| 365 | |
| 366 | /** Opens an NIH Image LUT or a 768 byte binary LUT. */ |
| 367 | int openBinaryLut(FileInfo fi, boolean isURL, boolean raw) throws IOException { |
| 368 | InputStream is; |
| 369 | if (isURL) |
| 370 | is = new URL(fi.url+fi.fileName).openStream(); |
| 371 | else |
| 372 | is = new FileInputStream(fi.getFilePath()); |
| 373 | DataInputStream f = new DataInputStream(is); |
| 374 | int nColors = 256; |
| 375 | if (!raw) { |
| 376 | // attempt to read 32 byte NIH Image LUT header |
| 377 | int id = f.readInt(); |
| 378 | if (id!=1229147980) { // 'ICOL' |
| 379 | f.close(); |
| 380 | return 0; |
| 381 | } |
| 382 | int version = f.readShort(); |
| 383 | nColors = f.readShort(); |
| 384 | int start = f.readShort(); |
| 385 | int end = f.readShort(); |
| 386 | long fill1 = f.readLong(); |
| 387 | long fill2 = f.readLong(); |
| 388 | int filler = f.readInt(); |
| 389 | } |
| 390 | f.read(fi.reds, 0, nColors); |
| 391 | f.read(fi.greens, 0, nColors); |
| 392 | f.read(fi.blues, 0, nColors); |
| 393 | if (nColors<256) |
| 394 | interpolate(fi.reds, fi.greens, fi.blues, nColors); |
| 395 | f.close(); |
| 396 | return 256; |
| 397 | } |
| 398 | |
| 399 | int openTextLut(FileInfo fi) throws IOException { |
| 400 | TextReader tr = new TextReader(); |
no test coverage detected