List of usage examples for javax.imageio ImageTypeSpecifier createInterleaved
public static ImageTypeSpecifier createInterleaved(ColorSpace colorSpace, int[] bandOffsets, int dataType, boolean hasAlpha, boolean isAlphaPremultiplied)
From source file:nitf.imageio.NITFReader.java
@Override public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex) throws IOException { checkIndex(imageIndex);/*from ww w . j a va 2s .c om*/ 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 NotImplementedException( "Support for pixels of size " + nbpp + " bytes has not been implemented yet"); } } catch (NITFException e) { log.error(ExceptionUtils.getStackTrace(e)); } return l.iterator(); }