package ij.io;
import ij.VirtualStack;
import java.io.*;
import java.util.Properties;
public class FileInfo implements Cloneable {
public static final int GRAY8 = 0;
public static final int GRAY16_SIGNED = 1;
public static final int GRAY16_UNSIGNED = 2;
public static final int GRAY32_INT = 3;
public static final int GRAY32_FLOAT = 4;
public static final int COLOR8 = 5;
public static final int RGB = 6;
public static final int RGB_PLANAR = 7;
public static final int BITMAP = 8;
public static final int ARGB = 9;
public static final int BGR = 10;
public static final int GRAY32_UNSIGNED = 11;
public static final int RGB48 = 12;
public static final int GRAY12_UNSIGNED = 13;
public static final int GRAY24_UNSIGNED = 14;
public static final int BARG = 15;
public static final int GRAY64_FLOAT = 16;
public static final int RGB48_PLANAR = 17;
public static final int ABGR = 18;
public static final int CMYK = 19;
public static final int UNKNOWN = 0;
public static final int RAW = 1;
public static final int TIFF = 2;
public static final int GIF_OR_JPG = 3;
public static final int FITS = 4;
public static final int BMP = 5;
public static final int DICOM = 6;
public static final int ZIP_ARCHIVE = 7;
public static final int PGM = 8;
public static final int IMAGEIO = 9;
public static final int COMPRESSION_UNKNOWN = 0;
public static final int COMPRESSION_NONE= 1;
public static final int LZW = 2;
public static final int LZW_WITH_DIFFERENCING = 3;
public static final int JPEG = 4;
public static final int PACK_BITS = 5;
public static final int ZIP = 6;
public int fileFormat;
public int fileType;
public String fileName;
public String directory;
public String url;
public int width;
public int height;
public int offset=0; public int nImages;
public int gapBetweenImages;
public boolean whiteIsZero;
public boolean intelByteOrder;
public int compression;
public int[] stripOffsets;
public int[] stripLengths;
public int rowsPerStrip;
public int lutSize;
public byte[] reds;
public byte[] greens;
public byte[] blues;
public Object pixels;
public String debugInfo;
public String[] sliceLabels;
public String info;
public InputStream inputStream;
public VirtualStack virtualStack;
public double pixelWidth=1.0;
public double pixelHeight=1.0;
public double pixelDepth=1.0;
public String unit;
public int calibrationFunction;
public double[] coefficients;
public String valueUnit;
public double frameInterval;
public String description;
public long longOffset; public int[] metaDataTypes; public byte[][] metaData;
public double[] displayRanges;
public byte[][] channelLuts;
public byte[] plot; public byte[] roi; public byte[][] overlay; public int samplesPerPixel;
public String openNextDir, openNextName;
public FileInfo() {
fileFormat = UNKNOWN;
fileType = GRAY8;
fileName = "Untitled";
directory = "";
url = "";
nImages = 1;
compression = COMPRESSION_NONE;
samplesPerPixel = 1;
}
public final long getOffset() {
return longOffset>0L?longOffset:((long)offset)&0xffffffffL;
}
public int getBytesPerPixel() {
switch (fileType) {
case GRAY8: case COLOR8: case BITMAP: return 1;
case GRAY16_SIGNED: case GRAY16_UNSIGNED: return 2;
case GRAY32_INT: case GRAY32_UNSIGNED: case GRAY32_FLOAT: case ARGB: case GRAY24_UNSIGNED: case BARG: case ABGR: case CMYK: return 4;
case RGB: case RGB_PLANAR: case BGR: return 3;
case RGB48: case RGB48_PLANAR: return 6;
case GRAY64_FLOAT : return 8;
default: return 0;
}
}
public String toString() {
return
"name=" + fileName
+ ", dir=" + directory
+ ", width=" + width
+ ", height=" + height
+ ", nImages=" + nImages
+ ", offset=" + getOffset()
+ ", type=" + getType()
+ ", byteOrder=" + (intelByteOrder?"little":"big")
+ ", format=" + fileFormat
+ ", url=" + url
+ ", whiteIsZero=" + (whiteIsZero?"t":"f")
+ ", lutSize=" + lutSize
+ ", comp=" + compression
+ ", ranges=" + (displayRanges!=null?""+displayRanges.length/2:"null")
+ ", samples=" + samplesPerPixel;
}
private String getType() {
switch (fileType) {
case GRAY8: return "byte";
case GRAY16_SIGNED: return "short";
case GRAY16_UNSIGNED: return "ushort";
case GRAY32_INT: return "int";
case GRAY32_UNSIGNED: return "uint";
case GRAY32_FLOAT: return "float";
case COLOR8: return "byte(lut)";
case RGB: return "RGB";
case RGB_PLANAR: return "RGB(p)";
case RGB48: return "RGB48";
case BITMAP: return "bitmap";
case ARGB: return "ARGB";
case ABGR: return "ABGR";
case BGR: return "BGR";
case BARG: return "BARG";
case CMYK: return "CMYK";
case GRAY64_FLOAT: return "double";
case RGB48_PLANAR: return "RGB48(p)";
default: return "";
}
}
public synchronized Object clone() {
try {return super.clone();}
catch (CloneNotSupportedException e) {return null;}
}
}