4 import java.awt.image.*;
10 import ij.util.StringSorter;
11 import ij.plugin.frame.Recorder;
16 private String fileName;
17 private String directory;
18 static final String TYPE =
"raw.type";
19 static final String WIDTH =
"raw.width";
20 static final String HEIGHT =
"raw.height";
21 static final String OFFSET =
"raw.offset";
22 static final String N =
"raw.n";
23 static final String GAP =
"raw.gap";
24 static final String OPTIONS =
"raw.options";
25 static final int WHITE_IS_ZERO = 1;
26 static final int INTEL_BYTE_ORDER = 2;
27 static final int OPEN_ALL = 4;
30 private static int choiceSelection =
Prefs.
getInt(TYPE,0);
32 private static int height =
Prefs.
getInt(HEIGHT,512);
33 private static long offset =
Prefs.
getInt(OFFSET,0);
35 private static int gapBetweenImages =
Prefs.
getInt(GAP,0);
36 private static int options;
37 private static boolean whiteIsZero,intelByteOrder;
38 private static String[] types = {
"8-bit",
"16-bit Signed",
"16-bit Unsigned",
39 "32-bit Signed",
"32-bit Unsigned",
"32-bit Real",
"24-bit RGB",
40 "24-bit RGB Planar",
"24-bit BGR",
"32-bit ARGB",
"1-bit Bitmap"};
44 whiteIsZero = (options&WHITE_IS_ZERO)!=0;
45 intelByteOrder = (options&INTEL_BYTE_ORDER)!=0;
49 this.fileName = fileName;
50 this.directory = directory;
57 boolean showDialog() {
58 if (choiceSelection>=types.length)
60 GenericDialog gd =
new GenericDialog(
"Import...",
IJ.
getInstance());
61 gd.addChoice(
"Image Type:", types, types[choiceSelection]);
62 gd.addNumericField(
"Width:", width, 0, 6,
"pixels");
63 gd.addNumericField(
"Height:", height, 0, 6,
"pixels");
64 gd.addNumericField(
"Offset to First Image:", offset, 0, 6,
"bytes");
65 gd.addNumericField(
"Number of Images:", nImages, 0, 6, null);
66 gd.addNumericField(
"Gap Between Images:", gapBetweenImages, 0, 6,
"bytes");
67 gd.addCheckbox(
"White is Zero", whiteIsZero);
68 gd.addCheckbox(
"Little-Endian Byte Order", intelByteOrder);
72 choiceSelection = gd.getNextChoiceIndex();
73 width = (int)gd.getNextNumber();
74 height = (int)gd.getNextNumber();
75 offset = (long)gd.getNextNumber();
76 nImages = (int)gd.getNextNumber();
77 gapBetweenImages = (int)gd.getNextNumber();
78 whiteIsZero = gd.getNextBoolean();
79 intelByteOrder = gd.getNextBoolean();
101 String imageType = types[choiceSelection];
103 fi.fileFormat = fi.RAW;
104 fi.fileName = fileName;
105 fi.directory = directory;
108 if (offset>2147483647)
111 fi.offset = (int)offset;
112 fi.nImages = nImages;
113 fi.gapBetweenImages = gapBetweenImages;
114 fi.intelByteOrder = intelByteOrder;
115 fi.whiteIsZero = whiteIsZero;
116 if (imageType.equals(
"8-bit"))
118 else if (imageType.equals(
"16-bit Signed"))
120 else if (imageType.equals(
"16-bit Unsigned"))
122 else if (imageType.equals(
"32-bit Signed"))
124 else if (imageType.equals(
"32-bit Unsigned"))
126 else if (imageType.equals(
"32-bit Real"))
128 else if (imageType.equals(
"24-bit RGB"))
130 else if (imageType.equals(
"24-bit RGB Planar"))
132 else if (imageType.equals(
"24-bit BGR"))
134 else if (imageType.equals(
"32-bit ARGB"))
136 else if (imageType.equals(
"1-bit Bitmap"))
140 if (
IJ.debugMode)
IJ.
log(
"ImportDialog: "+fi);
146 prefs.put(TYPE, Integer.toString(choiceSelection));
147 prefs.put(WIDTH, Integer.toString(width));
148 prefs.put(HEIGHT, Integer.toString(height));
149 prefs.put(OFFSET, Integer.toString(offset>2147483647?0:(
int)offset));
150 prefs.put(N, Integer.toString(nImages));
151 prefs.put(GAP, Integer.toString(gapBetweenImages));
154 options |= WHITE_IS_ZERO;
156 options |= INTEL_BYTE_ORDER;
157 prefs.put(OPTIONS, Integer.toString(options));