Search in sources :

Example 1 with JP2KKakaduImageWriter

use of it.geosolutions.imageio.plugins.jp2k.JP2KKakaduImageWriter in project imageio-ext by geosolutions-it.

the class NITFImageWriter method prepareJP2Image.

/**
 * Encode a RenderedImage as a JP2K codestream on the specified outputFile, using the proper set of compression parameters.
 *
 * @param outputFile
 * @param compression
 * @param ri
 * @throws FileNotFoundException
 * @throws IOException
 */
private void prepareJP2Image(final RenderedImage ri, final File outputFile, final WriteCompression compression) throws FileNotFoundException, IOException {
    JP2KKakaduImageWriter kakaduWriter = null;
    try {
        // TODO: Check PAN/MULTI can really be known from number of bands
        final int numBands = ri.getSampleModel().getNumBands();
        final boolean isMulti = numBands == 1 ? false : true;
        kakaduWriter = new JP2KKakaduImageWriter(KAKADU_SPI);
        kakaduWriter.setOutput(outputFile);
        JP2KKakaduImageWriteParam param = NITFUtilities.getCompressionParam(kakaduWriter, compression, isMulti);
        kakaduWriter.write(null, new IIOImage(ri, null, null), param);
    } finally {
        if (kakaduWriter != null) {
            try {
                kakaduWriter.dispose();
            } catch (Throwable t) {
            }
        }
    }
}
Also used : JP2KKakaduImageWriteParam(it.geosolutions.imageio.plugins.jp2k.JP2KKakaduImageWriteParam) JP2KKakaduImageWriter(it.geosolutions.imageio.plugins.jp2k.JP2KKakaduImageWriter) IIOImage(javax.imageio.IIOImage)

Aggregations

JP2KKakaduImageWriteParam (it.geosolutions.imageio.plugins.jp2k.JP2KKakaduImageWriteParam)1 JP2KKakaduImageWriter (it.geosolutions.imageio.plugins.jp2k.JP2KKakaduImageWriter)1 IIOImage (javax.imageio.IIOImage)1