use of loci.common.IRandomAccess in project bioformats by openmicroscopy.
the class ZipReader method close.
/* @see loci.formats.IFormatReader#close(boolean) */
@Override
public void close(boolean fileOnly) throws IOException {
super.close(fileOnly);
if (reader != null)
reader.close(fileOnly);
if (!fileOnly)
reader = null;
for (String name : mappedFiles) {
IRandomAccess handle = Location.getMappedFile(name);
Location.mapFile(name, null);
if (handle != null) {
handle.close();
}
}
mappedFiles.clear();
entryName = null;
}
use of loci.common.IRandomAccess in project bioformats by openmicroscopy.
the class IM3Reader method openRaw.
/**
* Open the current series in raw-mode, returning the
* interleaved image bytes. The data format for a pixel is
* a run of 63 unsigned short little endian values.
*
* @return a byte array containing the data organized by
* spectral channel, then x, then y. Returns null
* if, for some incomprehensible reason, the DATA
* block was missing.
* @throws IOException
*/
public byte[] openRaw() throws IOException {
IRandomAccess is = Location.getHandle(getCurrentFile(), false);
try {
is.setOrder(ByteOrder.LITTLE_ENDIAN);
final ContainerRecord dataSet = dataSets.get(getSeries());
for (IM3Record subRec : dataSet.parseChunks(is)) {
if (subRec.name.equals(FIELD_DATA)) {
is.seek(subRec.offset + 4);
int width = is.readInt();
int height = is.readInt();
int channels = is.readInt();
final byte[] result = new byte[width * height * channels * 2];
is.read(result);
return result;
}
}
} finally {
is.close();
}
return null;
}
Aggregations