Returns a FileInfo object containing information, including the pixel array, needed to save this image. Use getOriginalFileInfo() to get a copy of the FileInfo object used to open the image. @see ij.io.FileInfo @see #getOriginalFileInfo @see #setFileInfo
()
| 2490 | @see #setFileInfo |
| 2491 | */ |
| 2492 | public FileInfo getFileInfo() { |
| 2493 | FileInfo fi = new FileInfo(); |
| 2494 | fi.width = width; |
| 2495 | fi.height = height; |
| 2496 | fi.nImages = getStackSize(); |
| 2497 | if (compositeImage) |
| 2498 | fi.nImages = getImageStackSize(); |
| 2499 | fi.whiteIsZero = isInvertedLut(); |
| 2500 | fi.intelByteOrder = false; |
| 2501 | if (fi.nImages==1 && ip!=null) |
| 2502 | fi.pixels = ip.getPixels(); |
| 2503 | else if (stack!=null) |
| 2504 | fi.pixels = stack.getImageArray(); |
| 2505 | Calibration cal = getCalibration(); |
| 2506 | if (cal.scaled()) { |
| 2507 | fi.pixelWidth = cal.pixelWidth; |
| 2508 | fi.pixelHeight = cal.pixelHeight; |
| 2509 | fi.unit = cal.getUnit(); |
| 2510 | } |
| 2511 | if (fi.nImages>1) |
| 2512 | fi.pixelDepth = cal.pixelDepth; |
| 2513 | fi.frameInterval = cal.frameInterval; |
| 2514 | if (cal.calibrated()) { |
| 2515 | fi.calibrationFunction = cal.getFunction(); |
| 2516 | fi.coefficients = cal.getCoefficients(); |
| 2517 | fi.valueUnit = cal.getValueUnit(); |
| 2518 | } else if (!Calibration.DEFAULT_VALUE_UNIT.equals(cal.getValueUnit())) |
| 2519 | fi.valueUnit = cal.getValueUnit(); |
| 2520 | |
| 2521 | switch (imageType) { |
| 2522 | case GRAY8: case COLOR_256: |
| 2523 | LookUpTable lut = createLut(); |
| 2524 | boolean customLut = !lut.isGrayscale() || (ip!=null&&!ip.isDefaultLut()); |
| 2525 | if (imageType==COLOR_256 || customLut) |
| 2526 | fi.fileType = FileInfo.COLOR8; |
| 2527 | else |
| 2528 | fi.fileType = FileInfo.GRAY8; |
| 2529 | addLut(lut, fi); |
| 2530 | break; |
| 2531 | case GRAY16: |
| 2532 | if (compositeImage && fi.nImages==3) { |
| 2533 | if ("Red".equals(getStack().getSliceLabel(1))) |
| 2534 | fi.fileType = fi.RGB48; |
| 2535 | else |
| 2536 | fi.fileType = fi.GRAY16_UNSIGNED; |
| 2537 | } else |
| 2538 | fi.fileType = fi.GRAY16_UNSIGNED; |
| 2539 | if (!compositeImage) { |
| 2540 | lut = createLut(); |
| 2541 | if (!lut.isGrayscale() || (ip!=null&&!ip.isDefaultLut())) |
| 2542 | addLut(lut, fi); |
| 2543 | } |
| 2544 | break; |
| 2545 | case GRAY32: |
| 2546 | fi.fileType = fi.GRAY32_FLOAT; |
| 2547 | if (!compositeImage) { |
| 2548 | lut = createLut(); |
| 2549 | if (!lut.isGrayscale() || (ip!=null&&!ip.isDefaultLut())) |
no test coverage detected