use of it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl in project imageio-ext by geosolutions-it.
the class JP2KWriteTest method write_Cblk.
// ////////////////////////////////////////////////////////////////////////
//
// Testing "Cblk" Create Option.
//
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_Cblk() throws IOException, FileNotFoundException {
if (!isJp2KakDriverAvailable)
return;
LOGGER.info("Testing JP2 Write operation with Cblk option setting");
// //
// Preparing input/output files
// //
final File inputFile = TestData.file(this, testFileName);
Assert.assertTrue(inputFile.exists());
// Output files resulting from 2 different values of the same create
// option. In this test, the create option is Cblk.
final File outputFile1 = TestData.temp(this, "cblk16x16-.jp2", deleteTempFilesOnExit);
final File outputFile2 = TestData.temp(this, "cblk64x64-.jp2", deleteTempFilesOnExit);
// //
// Preparing to read
// //
final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI("ImageRead");
pbjImageRead.setParameter("Input", inputFile);
if (ENABLE_SUBSAMPLING) {
ImageReadParam readParam = new ImageReadParam();
readParam.setSourceSubsampling(4, 4, 0, 0);
pbjImageRead.setParameter("readParam", readParam);
}
pbjImageRead.setParameter("Reader", new JP2GDALKakaduImageReaderSpi().createReaderInstance());
RenderedOp image = JAI.create("ImageRead", pbjImageRead);
// ////////////////////////////////////////////////////////////////////
//
// preparing to write (1ST version of the create option test)
//
// ////////////////////////////////////////////////////////////////////
// Setting output and writer
final ParameterBlockJAI pbjImageWrite = new ParameterBlockJAI("ImageWrite");
pbjImageWrite.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile1));
ImageWriter writer = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
pbjImageWrite.setParameter("Writer", writer);
// Specifying image source to write
pbjImageWrite.addSource(image);
ImageWriteParam param = writer.getDefaultWriteParam();
// Specifying the required create option
((JP2GDALKakaduImageWriteParam) param).setCblk("{16,16}");
pbjImageWrite.setParameter("writeParam", param);
// Writing
final RenderedOp op = JAI.create("ImageWrite", pbjImageWrite);
// ////////////////////////////////////////////////////////////////////
//
// preparing to write (2ND version of the create option test)
//
// ////////////////////////////////////////////////////////////////////
// Setting output and writer
final ParameterBlockJAI pbjImageWrite2 = new ParameterBlockJAI("ImageWrite");
pbjImageWrite2.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile2));
ImageWriter writer2 = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
pbjImageWrite2.setParameter("Writer", writer2);
// Specifying image source to write
pbjImageWrite2.addSource(image);
ImageWriteParam param2 = writer2.getDefaultWriteParam();
// Specifying the required create option
((JP2GDALKakaduImageWriteParam) param2).setCblk("{64,64}");
pbjImageWrite2.setParameter("writeParam", param2);
// Writing
final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
}
Aggregations