use of nitf.ImageSubheader in project imageio-ext by geosolutions-it.
the class NITFReader method getImageTypes.
@Override
public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex) throws IOException {
checkIndex(imageIndex);
List<ImageTypeSpecifier> l = new ArrayList<ImageTypeSpecifier>();
try {
ImageSubheader subheader = record.getImages()[imageIndex].getSubheader();
String irep = subheader.getImageRepresentation().getStringData().trim();
String pvType = subheader.getPixelValueType().getStringData().trim();
int bandCount = subheader.getBandCount();
int nbpp = subheader.getNumBitsPerPixel().getIntData();
// if (NITFUtils.isCompressed(record, imageIndex))
// {
// throw new NotImplementedException(
// "Only uncompressed imagery is currently supported");
// }
int nBytes = ((nbpp - 1) / 8) + 1;
if (nBytes == 1 || nBytes == 2 || (nBytes == 4 && pvType.equals("R")) || (nBytes == 8 && pvType.equals("R"))) {
if (nBytes == 1 && bandCount == 3 && irep.equals("RGB")) {
ColorSpace rgb = ColorSpace.getInstance(ColorSpace.CS_sRGB);
int[] bandOffsets = new int[3];
for (int i = 0; i < bandOffsets.length; ++i) bandOffsets[i] = i;
l.add(ImageTypeSpecifier.createInterleaved(rgb, bandOffsets, DataBuffer.TYPE_BYTE, false, false));
}
l.add(ImageTypeSpecifier.createGrayscale(8, DataBuffer.TYPE_BYTE, false));
} else {
throw new UnsupportedOperationException("Support for pixels of size " + nbpp + " bytes has not been implemented yet");
}
} catch (NITFException e) {
LOGGER.severe(e.getLocalizedMessage());
}
return l.iterator();
}
Aggregations