tiffParser = new TiffParser(in);
tiffParser.setDoCaching(false);
tiffParser.setUse64BitOffsets(false);
final Boolean littleEndian = tiffParser.checkHeader();
if (littleEndian == null) {
throw new FormatException("Invalid FlowSight file");
}
final boolean little = littleEndian.booleanValue();
in.order(little);
LOGGER.info("Reading IFDs");
ifdOffsets = tiffParser.getIFDOffsets();
if (ifdOffsets.length < 2) {
throw new FormatException("No IFDs found");
}
LOGGER.info("Populating metadata");
/*
* The first IFD contains file-scope metadata
*/
final IFD ifd0 = tiffParser.getFirstIFD();
tiffParser.fillInIFD(ifd0);
final int channelCount = ifd0.getIFDIntValue(CHANNEL_COUNT_TAG);
final String channelNamesString = ifd0.getIFDStringValue(CHANNEL_NAMES_TAG);
channelNames = channelNamesString.split("\\|");
if (channelNames.length != channelCount) {
throw new FormatException(String.format(
"Channel count (%d) does not match number of channel names (%d) in string \"%s\"",
channelCount, channelNames.length, channelNamesString));
}
LOGGER.debug(String.format(
"Found %d channels: %s",
channelCount, channelNamesString.replace('|', ',')));
final String channelDescsString = ifd0.getIFDStringValue(CHANNEL_DESCS_TAG);
channelDescs = channelDescsString.split("\\|");
if (channelDescs.length != channelCount) {
throw new FormatException(String.format(
"Channel count (%d) does not match number of channel descriptions (%d) in string \"%s\"",
channelCount, channelDescs.length, channelDescsString));
}
/*
* Scan the remaining IFDs