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

Method getInfo

ij/src/main/java/ij/plugin/FITS_Reader.java:1429–1518  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1427 }
1428
1429 FileInfo getInfo() throws IOException {
1430 FileInfo fi = new FileInfo();
1431 fi.fileFormat = FileInfo.FITS;
1432 fi.fileName = fileName;
1433 fi.directory = directory;
1434 fi.width = 0;
1435 fi.height = 0;
1436 fi.offset = 0;
1437
1438 InputStream is = new FileInputStream(directory + fileName);
1439 if (fileName.toLowerCase().endsWith(".gz")) is = new GZIPInputStream(is);
1440 f = new DataInputStream(is);
1441 String line = getString(80);
1442 info.append(line+"\n");
1443 if (!line.startsWith("SIMPLE")) {f.close(); return null;}
1444 int count = 1;
1445 while ( true ) {
1446 count++;
1447 line = getString(80);
1448 info.append(line+"\n");
1449
1450 // Cut the key/value pair
1451 int index = line.indexOf ( "=" );
1452
1453 // Strip out comments
1454 int commentIndex = line.indexOf ( "/", index );
1455 if ( commentIndex < 0 )
1456 commentIndex = line.length ();
1457
1458 // Split that values
1459 String key;
1460 String value;
1461 if ( index >= 0 ) {
1462 key = line.substring ( 0, index ).trim ();
1463 value = line.substring ( index + 1, commentIndex ).trim ();
1464 } else {
1465 key = line.trim ();
1466 value = "";
1467 }
1468
1469 // Time to stop ?
1470 if (key.equals ("END") ) break;
1471
1472 // Look for interesting information
1473 if (key.equals("BITPIX")) {
1474 int bitsPerPixel = Integer.parseInt ( value );
1475 if (bitsPerPixel==8)
1476 fi.fileType = FileInfo.GRAY8;
1477 else if (bitsPerPixel==16)
1478 fi.fileType = FileInfo.GRAY16_SIGNED;
1479 else if (bitsPerPixel==32)
1480 fi.fileType = FileInfo.GRAY32_INT;
1481 else if (bitsPerPixel==-32)
1482 fi.fileType = FileInfo.GRAY32_FLOAT;
1483 else if (bitsPerPixel==-64)
1484 fi.fileType = FileInfo.GRAY64_FLOAT;
1485 else {
1486 IJ.error("BITPIX must be 8, 16, 32, -32 (float) or -64 (double).");

Callers 1

runMethod · 0.95

Calls 12

getStringMethod · 0.95
errorMethod · 0.95
parseDoubleMethod · 0.95
startsWithMethod · 0.80
substringMethod · 0.80
parseIntMethod · 0.80
appendMethod · 0.65
closeMethod · 0.65
lengthMethod · 0.65
indexOfMethod · 0.45
trimMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected