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();
}
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;
}
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;
}
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;
}
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[]));
}
Aggregations