Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
FileInfo.java
1 package ij.io;
2 import java.io.*;
3 import java.util.Properties;
4 
6 public class FileInfo {
7 
9  public static final int GRAY8 = 0;
10 
13  public static final int GRAY16_SIGNED = 1;
14 
16  public static final int GRAY16_UNSIGNED = 2;
17 
20  public static final int GRAY32_INT = 3;
21 
23  public static final int GRAY32_FLOAT = 4;
24 
26  public static final int COLOR8 = 5;
27 
29  public static final int RGB = 6;
30 
32  public static final int RGB_PLANAR = 7;
33 
35  public static final int BITMAP = 8;
36 
38  public static final int ARGB = 9;
39 
41  public static final int BGR = 10;
42 
45  public static final int GRAY32_UNSIGNED = 11;
46 
48  public static final int RGB48 = 12;
49 
50  // File formats
51  public static final int UNKNOWN = 0;
52  public static final int RAW = 1;
53  public static final int TIFF = 2;
54  public static final int GIF_OR_JPG = 3;
55  public static final int FITS = 4;
56  public static final int BMP = 5;
57  public static final int DICOM = 6;
58 
59  /* File format (TIFF, GIF_OR_JPG, BMP, etc.). Used by the File/Revert command */
60  public int fileFormat;
61 
62  /* File type (GRAY8, GRAY_16_UNSIGNED, RGB, etc.) */
63  public int fileType;
64 
65  public String fileName;
66  public String directory;
67  public String url;
68  public int width;
69  public int height;
70  public int offset=0;
71  public int nImages;
72  public int gapBetweenImages;
73  public boolean whiteIsZero;
74  public boolean intelByteOrder;
75  public int lutSize;
76  public byte[] reds;
77  public byte[] greens;
78  public byte[] blues;
79  public Object pixels;
80  public String info;
81  InputStream inputStream;
82 
83  public double pixelWidth=1.0;
84  public double pixelHeight=1.0;
85  public double pixelDepth=1.0;
86  public String unit;
87  public int calibrationFunction;
88  public double[] coefficients;
89  public String valueUnit;
90  public double frameInterval;
91  public String description;
93  public long longOffset;
94 
96  public FileInfo() {
97  // assign default values
98  fileFormat = UNKNOWN;
99  fileType = GRAY8;
100  fileName = "Untitled";
101  directory = "";
102  url = "";
103  nImages = 1;
104  }
105 
107  public int getBytesPerPixel() {
108  switch (fileType) {
109  case GRAY8: case COLOR8: case BITMAP: return 1;
110  case GRAY16_SIGNED: case GRAY16_UNSIGNED: return 2;
111  case GRAY32_INT: case GRAY32_UNSIGNED: case GRAY32_FLOAT: case ARGB: return 4;
112  case RGB: case RGB_PLANAR: case BGR: return 3;
113  default: return 0;
114  }
115  }
116 
117  public String toString() {
118  return
119  "name=" + fileName
120  + ", dir=" + directory
121  + ", url=" + url
122  + ", width=" + width
123  + ", height=" + height
124  + ", nImages=" + nImages
125  + ", type=" + getType()
126  + ", offset=" + (longOffset>0?longOffset:offset)
127  + ", whiteZero=" + (whiteIsZero?"t":"f")
128  + ", Intel=" + (intelByteOrder?"t":"f")
129  + ", lutSize=" + lutSize;
130  }
131 
132  private String getType() {
133  switch (fileType) {
134  case GRAY8: return "byte";
135  case GRAY16_SIGNED: return "short";
136  case GRAY16_UNSIGNED: return "ushort";
137  case GRAY32_INT: return "int";
138  case GRAY32_UNSIGNED: return "uint";
139  case GRAY32_FLOAT: return "float";
140  case COLOR8: return "byte+lut";
141  case RGB: return "RGB";
142  case RGB_PLANAR: return "RGB(p)";
143  case BITMAP: return "bitmap";
144  case ARGB: return "ARGB";
145  case BGR: return "BGR";
146  default: return "";
147  }
148  }
149 
150 }