MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / openBinaryLut

Method openBinaryLut

ij/src/main/java/ij/plugin/LutLoader.java:367–397  ·  view source on GitHub ↗

Opens an NIH Image LUT or a 768 byte binary LUT.

(FileInfo fi, boolean isURL, boolean raw)

Source from the content-addressed store, hash-verified

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();

Callers 1

openLutMethod · 0.95

Calls 7

interpolateMethod · 0.95
closeMethod · 0.65
readMethod · 0.65
getFilePathMethod · 0.45
readIntMethod · 0.45
readShortMethod · 0.45
readLongMethod · 0.45

Tested by

no test coverage detected