Search in sources :

Example 21 with TiffParser

use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.

the class IPWReader method getOptimalTileWidth.

/* @see loci.formats.IFormatReader#getOptimalTileWidth() */
@Override
public int getOptimalTileWidth() {
    FormatTools.assertId(currentId, true, 1);
    try {
        RandomAccessInputStream stream = poi.getDocumentStream(imageFiles.get(0));
        TiffParser tp = new TiffParser(stream);
        IFD ifd = tp.getFirstIFD();
        stream.close();
        return (int) ifd.getTileWidth();
    } catch (FormatException e) {
        LOGGER.debug("Could not retrieve tile width", e);
    } catch (IOException e) {
        LOGGER.debug("Could not retrieve tile height", e);
    }
    return super.getOptimalTileWidth();
}
Also used : IFD(loci.formats.tiff.IFD) TiffParser(loci.formats.tiff.TiffParser) RandomAccessInputStream(loci.common.RandomAccessInputStream) IOException(java.io.IOException) FormatException(loci.formats.FormatException)

Example 22 with TiffParser

use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.

the class IPWReader method get8BitLookupTable.

/* @see loci.formats.IFormatReader#get8BitLookupTable() */
@Override
public byte[][] get8BitLookupTable() throws FormatException, IOException {
    FormatTools.assertId(currentId, true, 1);
    RandomAccessInputStream stream = poi.getDocumentStream(imageFiles.get(0));
    TiffParser tp = new TiffParser(stream);
    IFD firstIFD = tp.getFirstIFD();
    int[] bits = firstIFD.getBitsPerSample();
    if (bits[0] <= 8) {
        int[] colorMap = tp.getColorMap(firstIFD);
        if (colorMap == null) {
            return null;
        }
        byte[][] table = new byte[3][colorMap.length / 3];
        int next = 0;
        for (int j = 0; j < table.length; j++) {
            for (int i = 0; i < table[0].length; i++) {
                table[j][i] = (byte) (colorMap[next++] >> 8);
            }
        }
        return table;
    }
    return null;
}
Also used : IFD(loci.formats.tiff.IFD) TiffParser(loci.formats.tiff.TiffParser) RandomAccessInputStream(loci.common.RandomAccessInputStream)

Example 23 with TiffParser

use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.

the class IPWReader 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 (poi == null) {
        initPOIService();
    }
    RandomAccessInputStream stream = poi.getDocumentStream(imageFiles.get(no));
    TiffParser tp = new TiffParser(stream);
    IFD ifd = tp.getFirstIFD();
    tp.getSamples(ifd, buf, x, y, w, h);
    stream.close();
    return buf;
}
Also used : IFD(loci.formats.tiff.IFD) TiffParser(loci.formats.tiff.TiffParser) RandomAccessInputStream(loci.common.RandomAccessInputStream)

Example 24 with TiffParser

use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.

the class ImprovisionTiffReader method isThisType.

// -- IFormatReader API methods --
/* @see loci.formats.IFormatReader#isThisType(RandomAccessInputStream) */
@Override
public boolean isThisType(RandomAccessInputStream stream) throws IOException {
    TiffParser tp = new TiffParser(stream);
    String comment = tp.getComment();
    if (comment == null)
        return false;
    return comment.indexOf(IMPROVISION_MAGIC_STRING) >= 0;
}
Also used : TiffParser(loci.formats.tiff.TiffParser)

Example 25 with TiffParser

use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.

the class SEQReader method isThisType.

// -- IFormatReader API methods --
/* @see loci.formats.IFormatReader#isThisType(RandomAccessInputStream) */
@Override
public boolean isThisType(RandomAccessInputStream stream) throws IOException {
    TiffParser parser = new TiffParser(stream);
    parser.setDoCaching(false);
    IFD ifd = parser.getFirstIFD();
    if (ifd == null)
        return false;
    parser.fillInIFD(ifd);
    Object tag1 = ifd.get(IMAGE_PRO_TAG_1);
    Object tag3 = ifd.get(IMAGE_PRO_TAG_3);
    return (tag1 != null && (tag1 instanceof short[])) || (tag3 != null && (tag3 instanceof int[]));
}
Also used : IFD(loci.formats.tiff.IFD) TiffParser(loci.formats.tiff.TiffParser)

Aggregations

TiffParser (loci.formats.tiff.TiffParser)96 IFD (loci.formats.tiff.IFD)74 RandomAccessInputStream (loci.common.RandomAccessInputStream)56 FormatException (loci.formats.FormatException)26 CoreMetadata (loci.formats.CoreMetadata)19 IOException (java.io.IOException)18 IFDList (loci.formats.tiff.IFDList)16 Location (loci.common.Location)15 MetadataStore (loci.formats.meta.MetadataStore)15 ArrayList (java.util.ArrayList)12 Timestamp (ome.xml.model.primitives.Timestamp)9 Length (ome.units.quantity.Length)8 PhotoInterp (loci.formats.tiff.PhotoInterp)6 File (java.io.File)5 HashMap (java.util.HashMap)5 ServiceException (loci.common.services.ServiceException)4 Time (ome.units.quantity.Time)4 NonNegativeInteger (ome.xml.model.primitives.NonNegativeInteger)4 List (java.util.List)3 ByteArrayHandle (loci.common.ByteArrayHandle)3