use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.
the class ImaconReader 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;
return ifd.containsKey(XML_TAG);
}
use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.
the class PCIReader method getOptimalTileWidth.
/* @see loci.formats.IFormatReader#getOptimalTileWidth() */
@Override
public int getOptimalTileWidth() {
FormatTools.assertId(currentId, true, 1);
String file = imageFiles.get(0);
try {
if (poi == null) {
initPOIService();
}
RandomAccessInputStream s = poi.getDocumentStream(file);
TiffParser tp = new TiffParser(s);
if (tp.isValidHeader()) {
IFD ifd = tp.getFirstIFD();
s.close();
return (int) ifd.getTileWidth();
}
s.close();
} catch (FormatException e) {
LOGGER.debug("Could not retrieve tile width", e);
} catch (IOException e) {
LOGGER.debug("Could not retrieve tile width", e);
}
return super.getOptimalTileWidth();
}
use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.
the class PCIReader 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();
}
String file = imageFiles.get(no);
RandomAccessInputStream s = poi.getDocumentStream(file);
TiffParser tp = new TiffParser(s);
if (tp.isValidHeader()) {
IFD ifd = tp.getFirstIFD();
tp.getSamples(ifd, buf, x, y, w, h);
} else {
s.seek(0);
readPlane(s, x, y, w, h, buf);
}
s.close();
return buf;
}
use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.
the class PhotoshopTiffReader method isThisType.
// -- IFormatReader API methods --
/* @see loci.formats.IFormatReader#isThisType(RandomAccessInputStream) */
@Override
public boolean isThisType(RandomAccessInputStream stream) throws IOException {
TiffParser tp = new TiffParser(stream);
tp.setDoCaching(false);
IFD ifd = tp.getFirstIFD();
if (ifd == null)
return false;
return ifd.containsKey(IMAGE_SOURCE_DATA);
}
use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.
the class PrairieReader method isThisType.
@Override
public boolean isThisType(RandomAccessInputStream stream) throws IOException {
final int blockLen = (int) Math.min(1048608, stream.length());
if (!FormatTools.validStream(stream, blockLen, false))
return false;
String s = stream.readString(blockLen);
if (s.indexOf("xml") != -1 && s.indexOf("PV") != -1)
return true;
TiffParser tp = new TiffParser(stream);
IFD ifd = tp.getFirstIFD();
if (ifd == null)
return false;
String software = null;
try {
software = ifd.getIFDStringValue(IFD.SOFTWARE);
} catch (FormatException exc) {
// no software tag, or tag is wrong type
return false;
}
if (software == null)
return false;
// not Prairie software
if (software.indexOf("Prairie") < 0)
return false;
return ifd.containsKey(new Integer(PRAIRIE_TAG_1)) && ifd.containsKey(new Integer(PRAIRIE_TAG_2)) && ifd.containsKey(new Integer(PRAIRIE_TAG_3));
}
Aggregations