stacks[channelCount] = new ImageStack((int) cz.ThumbnailX,
(int) cz.ThumbnailY, cm);
}
firstImDir = null;
ImageReader reader = null;
int flength = 0;
lsmFi.stripOffsets = new int[1];
lsmFi.stripLengths = new int[1];
for (int imageCounter = 0; imageCounter < lsmFi.imageDirectories.size(); imageCounter++) {
ImageDirectory imDir = (ImageDirectory) lsmFi.imageDirectories
.get(imageCounter);
for (int i = 0; i < imDir.TIF_STRIPBYTECOUNTS.length; i++)
if (imDir.TIF_COMPRESSION == 5) {
lsmFi.compression = FileInfo.LZW;
flength = (int) new File(lsmFi.directory
+ System.getProperty("file.separator")
+ lsmFi.fileName).length();
if (imDir.TIF_PREDICTOR == 2)
lsmFi.compression = FileInfo.LZW_WITH_DIFFERENCING;
} else
lsmFi.compression = 0;
if (!thumb && imDir.TIF_NEWSUBFILETYPE == 0) {
lsmFi.width = (int) imDir.TIF_IMAGEWIDTH;
lsmFi.height = (int) imDir.TIF_IMAGELENGTH;
Object pixels;
for (int channelCount = 0; channelCount < (int) (cz.DimensionChannels); channelCount++) {
int datatype = (int) cz.IntensityDataType;
if (datatype == 0)
datatype = cz.OffsetChannelDataTypesValues[channelCount];
switch (datatype) {
case 1:
lsmFi.fileType = FileInfo.GRAY8;
break;
case 2:
lsmFi.fileType = FileInfo.GRAY16_UNSIGNED;
break;
case 5:
lsmFi.fileType = FileInfo.GRAY32_FLOAT;
break;
default:
lsmFi.fileType = FileInfo.GRAY8;
break;
}
lsmFi.stripLengths[0] = (int) imDir.TIF_STRIPBYTECOUNTS[channelCount];
lsmFi.stripOffsets[0] = (int) imDir.TIF_STRIPOFFSETS[channelCount];
reader = new ImageReader(lsmFi);
if (channelCount < imDir.TIF_STRIPOFFSETS_LENGTH) {
if (lsmFi.stripLengths[0] + lsmFi.stripOffsets[0] > flength) {
lsmFi.stripLengths[0] = flength
- lsmFi.stripOffsets[0];
}
try {
stream.seek(lsmFi.stripOffsets[0]);
} catch (IOException e) {
e.printStackTrace();
}
pixels = reader.readPixels((InputStream) stream);
stacks[channelCount].addSlice("", pixels);
}
}
} else if (thumb && imDir.TIF_NEWSUBFILETYPE == 1) { // ONLY IF
// THUMBS
lsmFi.width = (int) imDir.TIF_IMAGEWIDTH;
lsmFi.height = (int) imDir.TIF_IMAGELENGTH;
reader = new ImageReader(lsmFi);
Object pixels;
int channels = (int) (cz.DimensionChannels);
channels = 1; // only read the first channel for the thumbs.
// speed!
for (int channelCount = 0; channelCount < channels; channelCount++) {
lsmFi.stripLengths[0] = (int) imDir.TIF_STRIPBYTECOUNTS[channelCount];
lsmFi.stripOffsets[0] = (int) imDir.TIF_STRIPOFFSETS[channelCount];
if (channelCount < imDir.TIF_STRIPOFFSETS_LENGTH) {
try {
stream.seek(lsmFi.stripOffsets[0]);
} catch (IOException e) {
e.printStackTrace();
}
pixels = reader.readPixels((InputStream) stream);
stacks[channelCount].addSlice("", pixels);
}
}
imageCounter = lsmFi.imageDirectories.size(); // break out of
// for loop,