use of it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl in project imageio-ext by geosolutions-it.
the class JP2KWriteTest method write_Cprecincts.
// ////////////////////////////////////////////////////////////////////////
//
// Testing "Cprecincts" Create Option.
//
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_Cprecincts() throws IOException, FileNotFoundException {
if (!isJp2KakDriverAvailable)
return;
LOGGER.info("Testing JP2 Write operation with Cprecincts 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 Cprecincts.
final File outputFile1 = TestData.temp(this, "CprecintsA-.jp2", deleteTempFilesOnExit);
final File outputFile2 = TestData.temp(this, "CprecintsB-.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).setCprecincts("{256,256},{256,256},{128,128}");
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).setCprecincts("{512,512},{256,512},{128,512},{64,512},{32,512},{16,512},{8,512},{4,512},{2,512}");
pbjImageWrite2.setParameter("writeParam", param2);
// Writing
final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
}
use of it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl in project imageio-ext by geosolutions-it.
the class JP2KWriteTest method write_GeoJp2.
// ////////////////////////////////////////////////////////////////////////
//
// Testing "GeoJp2" Create Option.
//
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_GeoJp2() throws IOException, FileNotFoundException {
if (!isJp2KakDriverAvailable)
return;
LOGGER.info("Testing JP2 Write operation with GeoJp2 option setting");
// //
// Preparing input/output files
// //
final File inputFile = TestData.file(this, "bogota.jp2");
Assert.assertTrue(inputFile.exists());
// Output files resulting from 2 different values of the same create
// option. In this test, the create option is GeoJp2.
final File outputFile1 = TestData.temp(this, "GeoJp2-.jp2", deleteTempFilesOnExit);
final File outputFile2 = TestData.temp(this, "NO-GeoJp2-.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).setGeoJp2("YES");
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).setGeoJp2("NO");
pbjImageWrite2.setParameter("writeParam", param2);
// Writing
final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
}
use of it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl in project imageio-ext by geosolutions-it.
the class JP2KWriteTest method write_Quality.
// ////////////////////////////////////////////////////////////////////////
//
// Testing "Quality" Create Option.
//
// ////////////////////////////////////////////////////////////////////////
// TODO: Investigate the strange displaying of a 100% quality factor write
// of an input UINT16 jpeg2000 image.
@Test
public void write_Quality() throws IOException, FileNotFoundException {
if (!isJp2KakDriverAvailable)
return;
LOGGER.info("Testing JP2 Write operation with Quality 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 Qstep.
final float firstQualityParam = 99.2f;
final float secondQualityParam = 1f;
final String fileName1 = new StringBuffer("Quality-").append(Float.toString(firstQualityParam)).append("f-.jp2").toString();
final String fileName2 = new StringBuffer("Quality-").append(Float.toString(secondQualityParam)).append("f-.jp2").toString();
final File outputFile1 = TestData.temp(this, fileName1, deleteTempFilesOnExit);
final File outputFile2 = TestData.temp(this, fileName2, 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).setQuality(firstQualityParam);
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).setQuality(secondQualityParam);
pbjImageWrite2.setParameter("writeParam", param2);
// Writing
final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
}
use of it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl in project imageio-ext by geosolutions-it.
the class JP2KWriteTest method write_SProfile.
// ////////////////////////////////////////////////////////////////////////
//
// Testing "SProfile" Create Option.
//
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_SProfile() throws IOException, FileNotFoundException {
if (!isJp2KakDriverAvailable)
return;
LOGGER.info("Testing JP2 Write operation with SProfile 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 SProfile.
final File outputFile1 = TestData.temp(this, "SProfile1-.jp2", deleteTempFilesOnExit);
final File outputFile2 = TestData.temp(this, "SProfile2-.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).setSProfile(1);
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).setSProfile("PROFILE2");
pbjImageWrite2.setParameter("writeParam", param2);
// Writing
final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
}
use of it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl in project imageio-ext by geosolutions-it.
the class JP2KWriteTest method write_COMSEG.
// ////////////////////////////////////////////////////////////////////////
//
// Testing "COMSEG" Create Option.
//
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_COMSEG() throws IOException, FileNotFoundException {
if (!isJp2KakDriverAvailable)
return;
LOGGER.info("Testing JP2 Write operation with COMSEG 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 COMSEG.
final File outputFile1 = TestData.temp(this, "COMSEG-.jp2", deleteTempFilesOnExit);
final File outputFile2 = TestData.temp(this, "NO-COMSEG-.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).setComseg("YES");
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).setComseg("NO");
pbjImageWrite2.setParameter("writeParam", param2);
// Writing
final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
}
Aggregations