Search in sources :

Example 6 with IRandomAccess

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;
}
Also used : IRandomAccess(loci.common.IRandomAccess)

Example 7 with IRandomAccess

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;
}
Also used : IRandomAccess(loci.common.IRandomAccess)

Aggregations

IRandomAccess (loci.common.IRandomAccess)7 CoreMetadata (loci.formats.CoreMetadata)4 RandomAccessInputStream (loci.common.RandomAccessInputStream)3 FormatException (loci.formats.FormatException)3 MetadataStore (loci.formats.meta.MetadataStore)3 ArrayList (java.util.ArrayList)2 MissingLibraryException (loci.formats.MissingLibraryException)2 BufferedImage (java.awt.image.BufferedImage)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStreamReader (java.io.InputStreamReader)1 ZipEntry (java.util.zip.ZipEntry)1 ZipInputStream (java.util.zip.ZipInputStream)1 ByteArrayHandle (loci.common.ByteArrayHandle)1 FileHandle (loci.common.FileHandle)1 Location (loci.common.Location)1 ReflectException (loci.common.ReflectException)1 ReflectedUniverse (loci.common.ReflectedUniverse)1