Search in sources :

Example 6 with ImageSubheader

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();
}
Also used : ImageSubheader(nitf.ImageSubheader) ColorSpace(java.awt.color.ColorSpace) NITFException(nitf.NITFException) ArrayList(java.util.ArrayList) ImageTypeSpecifier(javax.imageio.ImageTypeSpecifier) Point(java.awt.Point)

Aggregations

ImageSubheader (nitf.ImageSubheader)6 Point (java.awt.Point)5 NITFException (nitf.NITFException)5 IOException (java.io.IOException)4 IIOException (javax.imageio.IIOException)4 ArrayList (java.util.ArrayList)3 WritableRaster (java.awt.image.WritableRaster)2 ByteBuffer (java.nio.ByteBuffer)2 ImageTypeSpecifier (javax.imageio.ImageTypeSpecifier)2 DownSampler (nitf.DownSampler)2 PixelSkipDownSampler (nitf.PixelSkipDownSampler)2 SubWindow (nitf.SubWindow)2 WriteCompression (it.geosolutions.imageio.plugins.nitronitf.NITFUtilities.WriteCompression)1 ImageWrapper (it.geosolutions.imageio.plugins.nitronitf.wrapper.ImageWrapper)1 Rectangle (java.awt.Rectangle)1 ColorSpace (java.awt.color.ColorSpace)1 Raster (java.awt.image.Raster)1 DoubleBuffer (java.nio.DoubleBuffer)1 FloatBuffer (java.nio.FloatBuffer)1 ShortBuffer (java.nio.ShortBuffer)1