Search in sources :

Example 1 with UnsupportedCompressionException

use of loci.formats.UnsupportedCompressionException in project bioformats by openmicroscopy.

the class LiFlimReader method initCoreMetadata.

private void initCoreMetadata() throws FormatException {
    // check version number
    if (DataTools.indexOf(KNOWN_VERSIONS, version) < 0) {
        LOGGER.warn("Unknown LI-FLIM version: {}", version);
    }
    // check compression type
    if (COMPRESSION_NONE.equals(compression))
        gzip = false;
    else if (COMPRESSION_GZIP.equals(compression))
        gzip = true;
    else {
        throw new UnsupportedCompressionException("Unknown compression type: " + compression);
    }
    // check dimensional extents
    int sizeP = Integer.parseInt(phases);
    int sizeF = Integer.parseInt(frequencies);
    int p = backgroundP == null ? 1 : Integer.parseInt(backgroundP);
    int f = backgroundF == null ? 1 : Integer.parseInt(backgroundF);
    // populate core metadata
    CoreMetadata ms = core.get(0);
    ms.sizeX = Integer.parseInt(xLen);
    ms.sizeY = Integer.parseInt(yLen);
    ms.sizeZ = Integer.parseInt(zLen) * sizeF;
    ms.sizeC = Integer.parseInt(channels);
    ms.sizeT = Integer.parseInt(timestamps) * sizeP;
    ms.imageCount = getSizeZ() * getSizeT();
    ms.rgb = getSizeC() > 1;
    ms.indexed = false;
    ms.dimensionOrder = "XYCZT";
    ms.pixelType = getPixelTypeFromString(datatype);
    ms.littleEndian = true;
    ms.interleaved = true;
    ms.falseColor = false;
    ms.moduloZ.type = FormatTools.FREQUENCY;
    ms.moduloZ.step = ms.sizeZ / sizeF;
    ms.moduloZ.start = 0;
    ms.moduloZ.end = ms.sizeZ - 1;
    ms.moduloT.type = FormatTools.PHASE;
    ms.moduloT.step = ms.sizeT / sizeP;
    ms.moduloT.start = 0;
    ms.moduloT.end = ms.sizeT - 1;
    if (backgroundX != null) {
        ms = new CoreMetadata();
        ms.sizeX = Integer.parseInt(backgroundX);
        ms.sizeY = Integer.parseInt(backgroundY);
        ms.sizeZ = Integer.parseInt(backgroundZ) * f;
        ms.sizeC = Integer.parseInt(backgroundC);
        ms.sizeT = Integer.parseInt(backgroundT) * p;
        ms.imageCount = ms.sizeZ * ms.sizeT;
        ms.rgb = ms.sizeC > 1;
        ms.indexed = false;
        ms.dimensionOrder = "XYCZT";
        ms.pixelType = getPixelTypeFromString(backgroundDatatype);
        ms.littleEndian = true;
        ms.interleaved = true;
        ms.falseColor = false;
        ms.moduloZ.type = FormatTools.FREQUENCY;
        ms.moduloZ.step = ms.sizeZ / f;
        ms.moduloZ.start = 0;
        ms.moduloZ.end = ms.sizeZ - 1;
        ms.moduloT.type = FormatTools.PHASE;
        ms.moduloT.step = ms.sizeT / p;
        ms.moduloT.start = 0;
        ms.moduloT.end = ms.sizeT - 1;
        core.add(ms);
    }
}
Also used : UnsupportedCompressionException(loci.formats.UnsupportedCompressionException) CoreMetadata(loci.formats.CoreMetadata)

Example 2 with UnsupportedCompressionException

use of loci.formats.UnsupportedCompressionException in project bioformats by openmicroscopy.

the class NativeQTReader method parse.

// -- Helper methods --
/**
 * Parse all of the atoms in the file.
 */
private void parse(int depth, long offset, long length) throws FormatException, IOException {
    while (offset < length) {
        in.seek(offset);
        // first 4 bytes are the atom size
        long atomSize = in.readInt() & 0xffffffffL;
        // read the atom type
        String atomType = in.readString(4);
        // if atomSize is 1, then there is an 8 byte extended size
        if (atomSize == 1) {
            atomSize = in.readLong();
        }
        if (atomSize < 0) {
            LOGGER.warn("QTReader: invalid atom size: {}", atomSize);
        } else if (atomSize > in.length()) {
            offset += 4;
            continue;
        }
        LOGGER.debug("Seeking to {}; atomType={}; atomSize={}", new Object[] { offset, atomType, atomSize });
        // if this is a container atom, parse the children
        if (isContainer(atomType)) {
            parse(depth++, in.getFilePointer(), offset + atomSize);
        } else {
            if (atomSize == 0)
                atomSize = in.length();
            long oldpos = in.getFilePointer();
            if (atomType.equals("mdat")) {
                // we've found the pixel data
                pixelOffset = in.getFilePointer();
                pixelBytes = atomSize;
                if (pixelBytes > (in.length() - pixelOffset)) {
                    pixelBytes = in.length() - pixelOffset;
                }
            } else if (atomType.equals("tkhd")) {
                // we've found the dimensions
                in.skipBytes(38);
                int[][] matrix = new int[3][3];
                for (int i = 0; i < matrix.length; i++) {
                    for (int j = 0; j < matrix[0].length; j++) {
                        matrix[i][j] = in.readInt();
                    }
                }
                // The contents of the matrix we just read determine whether or not
                // we should flip the width and height.  We can check the first two
                // rows of the matrix - they should correspond to the first two rows
                // of an identity matrix.
                // TODO : adapt to use the value of flip
                flip = matrix[0][0] == 0 && matrix[1][0] != 0;
                if (getSizeX() == 0)
                    core.get(0).sizeX = in.readInt();
                if (getSizeY() == 0)
                    core.get(0).sizeY = in.readInt();
            } else if (atomType.equals("cmov")) {
                in.skipBytes(8);
                if ("zlib".equals(in.readString(4))) {
                    atomSize = in.readInt();
                    in.skipBytes(4);
                    int uncompressedSize = in.readInt();
                    byte[] b = new byte[(int) (atomSize - 12)];
                    in.read(b);
                    byte[] output = new ZlibCodec().decompress(b, null);
                    RandomAccessInputStream oldIn = in;
                    in = new RandomAccessInputStream(output);
                    parse(0, 0, output.length);
                    in.close();
                    in = oldIn;
                } else {
                    throw new UnsupportedCompressionException("Compressed header not supported.");
                }
            } else if (atomType.equals("stco")) {
                if (offsets.size() > 0)
                    break;
                separatedFork = false;
                in.skipBytes(4);
                int numPlanes = in.readInt();
                if (numPlanes != getImageCount()) {
                    in.seek(in.getFilePointer() - 4);
                    int off = in.readInt();
                    offsets.add(new Integer(off));
                    for (int i = 1; i < getImageCount(); i++) {
                        if ((chunkSizes.size() > 0) && (i < chunkSizes.size())) {
                            rawSize = chunkSizes.get(i).intValue();
                        } else
                            i = getImageCount();
                        off += rawSize;
                        offsets.add(new Integer(off));
                    }
                } else {
                    for (int i = 0; i < numPlanes; i++) {
                        offsets.add(new Integer(in.readInt()));
                    }
                }
            } else if (atomType.equals("stsd")) {
                // found video codec and pixel depth information
                in.skipBytes(4);
                int numEntries = in.readInt();
                in.skipBytes(4);
                for (int i = 0; i < numEntries; i++) {
                    if (i == 0) {
                        codec = in.readString(4);
                        if (!codec.equals("raw ") && !codec.equals("rle ") && !codec.equals("rpza") && !codec.equals("mjpb") && !codec.equals("jpeg")) {
                            throw new UnsupportedCompressionException("Unsupported codec: " + codec);
                        }
                        in.skipBytes(16);
                        if (in.readShort() == 0) {
                            in.skipBytes(56);
                            bitsPerPixel = in.readShort();
                            if (codec.equals("rpza"))
                                bitsPerPixel = 8;
                            in.skipBytes(10);
                            interlaced = in.read() == 2;
                            addGlobalMeta("Codec", codec);
                            addGlobalMeta("Bits per pixel", bitsPerPixel);
                            in.skipBytes(9);
                        }
                    } else {
                        altCodec = in.readString(4);
                        addGlobalMeta("Second codec", altCodec);
                    }
                }
            } else if (atomType.equals("stsz")) {
                // found the number of planes
                in.skipBytes(4);
                rawSize = in.readInt();
                core.get(0).imageCount = in.readInt();
                if (rawSize == 0) {
                    in.seek(in.getFilePointer() - 4);
                    for (int b = 0; b < getImageCount(); b++) {
                        chunkSizes.add(new Integer(in.readInt()));
                    }
                }
            } else if (atomType.equals("stsc")) {
                in.skipBytes(4);
                int numChunks = in.readInt();
                if (altCodec != null) {
                    int prevChunk = 0;
                    for (int i = 0; i < numChunks; i++) {
                        int chunk = in.readInt();
                        int planesPerChunk = in.readInt();
                        int id = in.readInt();
                        if (id == 2)
                            altPlanes += planesPerChunk * (chunk - prevChunk);
                        prevChunk = chunk;
                    }
                }
            } else if (atomType.equals("stts")) {
                in.skipBytes(12);
                int fps = in.readInt();
                addGlobalMeta("Frames per second", fps);
            }
            if (oldpos + atomSize < in.length()) {
                in.seek(oldpos + atomSize);
            } else
                break;
        }
        if (atomSize == 0)
            offset = in.length();
        else
            offset += atomSize;
        // if a 'udta' atom, skip ahead 4 bytes
        if (atomType.equals("udta"))
            offset += 4;
        print(depth, atomSize, atomType);
    }
}
Also used : ZlibCodec(loci.formats.codec.ZlibCodec) UnsupportedCompressionException(loci.formats.UnsupportedCompressionException) RandomAccessInputStream(loci.common.RandomAccessInputStream)

Example 3 with UnsupportedCompressionException

use of loci.formats.UnsupportedCompressionException in project bioformats by openmicroscopy.

the class NativeQTReader method uncompress.

/**
 * Uncompresses an image plane according to the the codec identifier.
 */
private byte[] uncompress(byte[] pixs, String code) throws FormatException, IOException {
    CodecOptions options = new MJPBCodecOptions();
    options.width = getSizeX();
    options.height = getSizeY();
    options.bitsPerSample = bitsPerPixel;
    options.channels = bitsPerPixel < 40 ? bitsPerPixel / 8 : (bitsPerPixel - 32) / 8;
    options.previousImage = canUsePrevious ? prevPixels : null;
    options.littleEndian = isLittleEndian();
    options.interleaved = isRGB();
    if (code.equals("raw "))
        return pixs;
    else if (code.equals("rle ")) {
        return new QTRLECodec().decompress(pixs, options);
    } else if (code.equals("rpza")) {
        return new RPZACodec().decompress(pixs, options);
    } else if (code.equals("mjpb")) {
        ((MJPBCodecOptions) options).interlaced = interlaced;
        return new MJPBCodec().decompress(pixs, options);
    } else if (code.equals("jpeg")) {
        return new JPEGCodec().decompress(pixs, options);
    } else {
        throw new UnsupportedCompressionException("Unsupported codec : " + code);
    }
}
Also used : CodecOptions(loci.formats.codec.CodecOptions) MJPBCodecOptions(loci.formats.codec.MJPBCodecOptions) QTRLECodec(loci.formats.codec.QTRLECodec) MJPBCodec(loci.formats.codec.MJPBCodec) RPZACodec(loci.formats.codec.RPZACodec) UnsupportedCompressionException(loci.formats.UnsupportedCompressionException) MJPBCodecOptions(loci.formats.codec.MJPBCodecOptions) JPEGCodec(loci.formats.codec.JPEGCodec)

Example 4 with UnsupportedCompressionException

use of loci.formats.UnsupportedCompressionException in project bioformats by openmicroscopy.

the class NRRDReader method openBytes.

/**
 * @see loci.formats.IFormatReader#openBytes(int, byte[], int, int, int, int)
 */
@Override
public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException {
    FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h);
    if (initializeHelper && dataFile != null && helper.getCurrentFile() == null) {
        helper.setId(dataFile);
    }
    // TODO : add support for additional encoding types
    if (dataFile == null) {
        long planeSize = FormatTools.getPlaneSize(this);
        if (encoding.equals("raw")) {
            in.seek(offset + no * planeSize);
            readPlane(in, x, y, w, h, buf);
        } else if (encoding.equals("gzip")) {
            if (gzip == null || no <= lastPlane) {
                FileInputStream fis = new FileInputStream(getCurrentFile());
                safeSkip(fis, offset);
                gzip = new GZIPInputStream(fis);
                lastPlane = -1;
            }
            int bpp = getRGBChannelCount() * FormatTools.getBytesPerPixel(getPixelType());
            int rowLen = getSizeX() * bpp;
            int diff = no - (lastPlane + 1);
            safeSkip(gzip, (planeSize * diff) + (y * rowLen));
            int readLen = w * bpp;
            for (int row = 0; row < h; row++) {
                safeSkip(gzip, x * bpp);
                int toRead = readLen;
                while (toRead > 0) {
                    toRead -= gzip.read(buf, ((row + y) * readLen) + (readLen - toRead), toRead);
                }
                safeSkip(gzip, (getSizeX() - w - x) * bpp);
            }
            lastPlane = no;
        } else {
            throw new UnsupportedCompressionException("Unsupported encoding: " + encoding);
        }
        return buf;
    } else if (encoding.equals("raw")) {
        RandomAccessInputStream s = new RandomAccessInputStream(dataFile);
        s.seek(offset + no * FormatTools.getPlaneSize(this));
        readPlane(s, x, y, w, h, buf);
        s.close();
        return buf;
    }
    return helper.openBytes(no, buf, x, y, w, h);
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) UnsupportedCompressionException(loci.formats.UnsupportedCompressionException) RandomAccessInputStream(loci.common.RandomAccessInputStream) FileInputStream(java.io.FileInputStream)

Example 5 with UnsupportedCompressionException

use of loci.formats.UnsupportedCompressionException in project bioformats by openmicroscopy.

the class AVIReader method readChunk.

private void readChunk() throws FormatException, IOException {
    readChunkHeader();
    CoreMetadata m = core.get(0);
    if (type.equals("RIFF")) {
        if (!fcc.startsWith("AVI")) {
            throw new FormatException("Sorry, AVI RIFF format not found.");
        }
    } else if (in.getFilePointer() == 12) {
        throw new FormatException("Not an AVI file");
    } else {
        if (in.getFilePointer() + size - 4 <= in.length()) {
            in.skipBytes(size - 4);
        }
        return;
    }
    pos = in.getFilePointer();
    long spos = pos;
    LOGGER.info("Searching for image data");
    while ((in.length() - in.getFilePointer()) > 4) {
        listString = in.readString(4);
        if (listString.equals("RIFF")) {
            in.seek(in.getFilePointer() - 4);
            return;
        }
        in.seek(pos);
        if (listString.equals(" JUN")) {
            in.skipBytes(1);
            pos++;
        }
        if (listString.equals("JUNK")) {
            readTypeAndSize();
            if (type.equals("JUNK")) {
                in.skipBytes(size);
            }
        } else if (listString.equals("IDIT")) {
            readTypeAndSize();
            in.skipBytes(size);
        } else if (listString.equals("LIST")) {
            spos = in.getFilePointer();
            readChunkHeader();
            in.seek(spos);
            if (fcc.equals("hdrl")) {
                readChunkHeader();
                if (type.equals("LIST")) {
                    if (fcc.equals("hdrl")) {
                        readTypeAndSize();
                        if (type.equals("avih")) {
                            spos = in.getFilePointer();
                            addGlobalMeta("Microseconds per frame", in.readInt());
                            addGlobalMeta("Max. bytes per second", in.readInt());
                            in.skipBytes(8);
                            addGlobalMeta("Total frames", in.readInt());
                            addGlobalMeta("Initial frames", in.readInt());
                            in.skipBytes(8);
                            m.sizeX = in.readInt();
                            addGlobalMeta("Frame height", in.readInt());
                            addGlobalMeta("Scale factor", in.readInt());
                            addGlobalMeta("Frame rate", in.readInt());
                            addGlobalMeta("Start time", in.readInt());
                            addGlobalMeta("Length", in.readInt());
                            addGlobalMeta("Frame width", getSizeX());
                            if (spos + size <= in.length()) {
                                in.seek(spos + size);
                            }
                        }
                    }
                }
            } else if (fcc.equals("strl")) {
                long startPos = in.getFilePointer();
                long streamSize = size;
                readChunkHeader();
                if (type.equals("LIST")) {
                    if (fcc.equals("strl")) {
                        readTypeAndSize();
                        if (type.equals("strh")) {
                            spos = in.getFilePointer();
                            in.skipBytes(40);
                            addGlobalMeta("Stream quality", in.readInt());
                            bytesPerPlane = in.readInt();
                            addGlobalMeta("Stream sample size", bytesPerPlane);
                            if (spos + size <= in.length()) {
                                in.seek(spos + size);
                            }
                        }
                        readTypeAndSize();
                        if (type.equals("strf")) {
                            spos = in.getFilePointer();
                            if (getSizeY() != 0) {
                                in.skipBytes(size);
                                readTypeAndSize();
                                while (type.equals("indx")) {
                                    in.skipBytes(size);
                                    readTypeAndSize();
                                }
                                pos = in.getFilePointer() - 4;
                                in.seek(pos - 4);
                                continue;
                            }
                            in.skipBytes(4);
                            bmpWidth = in.readInt();
                            m.sizeY = in.readInt();
                            in.skipBytes(2);
                            bmpBitsPerPixel = in.readShort();
                            bmpCompression = in.readInt();
                            in.skipBytes(4);
                            addGlobalMeta("Horizontal resolution", in.readInt());
                            addGlobalMeta("Vertical resolution", in.readInt());
                            bmpColorsUsed = in.readInt();
                            in.skipBytes(4);
                            addGlobalMeta("Bitmap compression value", bmpCompression);
                            addGlobalMeta("Number of colors used", bmpColorsUsed);
                            addGlobalMeta("Bits per pixel", bmpBitsPerPixel);
                            // scan line is padded with zeros to be a multiple of 4 bytes
                            int npad = bmpWidth % 4;
                            if (npad > 0)
                                npad = 4 - npad;
                            bmpScanLineSize = (bmpWidth + npad) * (bmpBitsPerPixel / 8);
                            int bmpActualColorsUsed = 0;
                            if (bmpColorsUsed != 0) {
                                bmpActualColorsUsed = bmpColorsUsed;
                            } else if (bmpBitsPerPixel < 16) {
                                // a value of 0 means we determine this based on the
                                // bits per pixel
                                bmpActualColorsUsed = 1 << bmpBitsPerPixel;
                                bmpColorsUsed = bmpActualColorsUsed;
                            }
                            if (bmpCompression != MSRLE && bmpCompression != 0 && bmpCompression != MS_VIDEO && bmpCompression != JPEG && bmpCompression != Y8) {
                                throw new UnsupportedCompressionException(bmpCompression + " not supported");
                            }
                            if (!(bmpBitsPerPixel == 4 || bmpBitsPerPixel == 8 || bmpBitsPerPixel == 24 || bmpBitsPerPixel == 16 || bmpBitsPerPixel == 32)) {
                                throw new FormatException(bmpBitsPerPixel + " bits per pixel not supported");
                            }
                            if (bmpActualColorsUsed != 0) {
                                // read the palette
                                lut = new byte[3][bmpColorsUsed];
                                for (int i = 0; i < bmpColorsUsed; i++) {
                                    if (bmpCompression != Y8) {
                                        lut[2][i] = in.readByte();
                                        lut[1][i] = in.readByte();
                                        lut[0][i] = in.readByte();
                                        in.skipBytes(1);
                                    } else {
                                        lut[0][i] = (byte) i;
                                        lut[1][i] = (byte) i;
                                        lut[2][i] = (byte) i;
                                    }
                                }
                            }
                            in.seek(spos + size);
                        }
                    }
                    spos = in.getFilePointer();
                    readTypeAndSize();
                    if (type.equals("strd")) {
                        in.skipBytes(size);
                    } else {
                        in.seek(spos);
                    }
                    spos = in.getFilePointer();
                    readTypeAndSize();
                    if (type.equals("strn") || type.equals("indx")) {
                        in.skipBytes(size);
                    } else {
                        in.seek(spos);
                    }
                }
                if (startPos + streamSize + 8 <= in.length()) {
                    in.seek(startPos + 8 + streamSize);
                }
            } else if (fcc.equals("movi")) {
                readChunkHeader();
                if (type.equals("LIST")) {
                    if (fcc.equals("movi")) {
                        spos = in.getFilePointer();
                        long startOfMovi = spos - 4;
                        if (spos >= in.length() - 12)
                            break;
                        readChunkHeader();
                        if (!(type.equals("LIST") && (fcc.equals("rec ") || fcc.equals("movi")))) {
                            in.seek(spos);
                        }
                        spos = in.getFilePointer();
                        boolean end = false;
                        while (!end && in.getFilePointer() < in.length() - 8) {
                            readTypeAndSize();
                            String oldType = type;
                            while (type.startsWith("ix") || type.endsWith("tx") || type.equals("JUNK")) {
                                in.skipBytes(size);
                                readTypeAndSize();
                            }
                            String check = type.substring(2);
                            boolean foundPixels = false;
                            while (check.equals("db") || check.equals("dc") || check.equals("wb")) {
                                foundPixels = true;
                                if (check.startsWith("d")) {
                                    if (size > 0 || bmpCompression != 0) {
                                        offsets.add(new Long(in.getFilePointer()));
                                        lengths.add(new Long(size));
                                        in.skipBytes(size);
                                    }
                                } else if (check.equals("wb")) {
                                    in.skipBytes(size);
                                }
                                spos = in.getFilePointer();
                                if (spos + 8 >= in.length())
                                    return;
                                readTypeAndSize();
                                if (type.equals("JUNK")) {
                                    in.skipBytes(size);
                                    spos = in.getFilePointer();
                                    if (spos + 8 >= in.length())
                                        return;
                                    readTypeAndSize();
                                } else if (type.length() < 4 || type.endsWith("JUN")) {
                                    in.seek(spos + 1);
                                    readTypeAndSize();
                                    in.skipBytes(size);
                                    spos = in.getFilePointer();
                                    if (spos + 8 >= in.length())
                                        return;
                                    readTypeAndSize();
                                }
                                if (type.length() < 4) {
                                    return;
                                }
                                check = type.substring(2);
                                if (check.equals("0d")) {
                                    in.seek(spos + 1);
                                    readTypeAndSize();
                                    check = type.substring(2);
                                }
                            }
                            in.seek(spos);
                            if (!oldType.startsWith("ix") && !foundPixels) {
                                if (check.equals("x1") && in.getFilePointer() < in.length() - 24) {
                                    // read the index table
                                    // the number of entries in the index table may not
                                    // match the number of frame streams (frames can
                                    // be omitted or duplicated)
                                    in.skipBytes(8);
                                    offsets.clear();
                                    lengths.clear();
                                    long tableEnd = in.getFilePointer() + size;
                                    if (tableEnd <= 0 || tableEnd > in.length()) {
                                        tableEnd = in.length();
                                    }
                                    boolean useSOM = false;
                                    while (in.getFilePointer() + 16 <= tableEnd) {
                                        String chunkID = in.readString(4);
                                        int flags = in.readInt();
                                        int offset = in.readInt() + 8;
                                        int chunkSize = in.readInt();
                                        if (chunkID.endsWith("db") || chunkID.endsWith("dc")) {
                                            if (offsets.size() == 0) {
                                                useSOM = offset < startOfMovi;
                                            }
                                            if (offsets.size() > 0) {
                                                if (offset == offsets.get(offsets.size() - 1)) {
                                                    chunkSize = lengths.get(lengths.size() - 1).intValue();
                                                }
                                            }
                                            if (chunkSize == 0 && offsets.size() > 0 && bmpCompression == 0) {
                                                offsets.add(offsets.get(offsets.size() - 1));
                                            } else if (chunkSize > 0 || offsets.size() > 0) {
                                                offsets.add(new Long(useSOM ? startOfMovi + offset : offset));
                                            }
                                            lengths.add(new Long(chunkSize));
                                        }
                                    }
                                } else {
                                    end = true;
                                }
                            } else if (oldType.startsWith("ix") && !foundPixels) {
                                end = true;
                            }
                        }
                    }
                }
            } else {
                int oldSize = size;
                size = in.readInt() - 8;
                if (size > oldSize) {
                    size = oldSize;
                    in.seek(in.getFilePointer() - 4);
                }
                // skipping unknown block
                if (size + 8 >= 0)
                    in.skipBytes(8 + size);
            }
        } else if (in.getFilePointer() + 8 < in.length()) {
            // skipping unknown block
            readTypeAndSize();
            if (in.getFilePointer() + 8 < in.length() && !type.equals("idx1")) {
                readTypeAndSize();
            } else if (!type.equals("idx1"))
                break;
            if (in.getFilePointer() + size + 4 <= in.length()) {
                in.skipBytes(size);
            }
            if (type.equals("idx1"))
                break;
        } else {
            break;
        }
        pos = in.getFilePointer();
    }
}
Also used : UnsupportedCompressionException(loci.formats.UnsupportedCompressionException) CoreMetadata(loci.formats.CoreMetadata) FormatException(loci.formats.FormatException)

Aggregations

UnsupportedCompressionException (loci.formats.UnsupportedCompressionException)12 RandomAccessInputStream (loci.common.RandomAccessInputStream)6 CoreMetadata (loci.formats.CoreMetadata)5 CodecOptions (loci.formats.codec.CodecOptions)4 JPEGCodec (loci.formats.codec.JPEGCodec)3 MetadataStore (loci.formats.meta.MetadataStore)3 ArrayList (java.util.ArrayList)2 Location (loci.common.Location)2 PackbitsCodec (loci.formats.codec.PackbitsCodec)2 Length (ome.units.quantity.Length)2 FileInputStream (java.io.FileInputStream)1 List (java.util.List)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 InflaterInputStream (java.util.zip.InflaterInputStream)1 FormatException (loci.formats.FormatException)1 Codec (loci.formats.codec.Codec)1 JPEG2000Codec (loci.formats.codec.JPEG2000Codec)1 MJPBCodec (loci.formats.codec.MJPBCodec)1 MJPBCodecOptions (loci.formats.codec.MJPBCodecOptions)1 MSRLECodec (loci.formats.codec.MSRLECodec)1