use of javax.media.jai.RenderedOp in project imageio-ext by geosolutions-it.
the class JP2KWriteTest method write_Corder.
// ////////////////////////////////////////////////////////////////////////
//
// Testing "Corder" Create Option.
//
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_Corder() throws IOException, FileNotFoundException {
if (!isJp2KakDriverAvailable)
return;
LOGGER.info("Testing JP2 Write operation with Corder 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 Corder.
final File outputFile1 = TestData.temp(this, "CorderPCRL-.jp2", deleteTempFilesOnExit);
final File outputFile2 = TestData.temp(this, "CorderRPCL-.jp2", deleteTempFilesOnExit);
final File outputFile3 = TestData.temp(this, "CorderLRCP-.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).setCorder("PCRL");
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).setCorder("RPCL");
pbjImageWrite2.setParameter("writeParam", param2);
// Writing
final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
// ////////////////////////////////////////////////////////////////////
//
// preparing to write (3RD version of the create option test)
//
// ////////////////////////////////////////////////////////////////////
// Setting output and writer
final ParameterBlockJAI pbjImageWrite3 = new ParameterBlockJAI("ImageWrite");
pbjImageWrite3.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile3));
ImageWriter writer3 = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
pbjImageWrite3.setParameter("Writer", writer3);
// Specifying image source to write
pbjImageWrite3.addSource(image);
ImageWriteParam param3 = writer3.getDefaultWriteParam();
// Specifying the required create option
((JP2GDALKakaduImageWriteParam) param3).setCorder("LRCP");
pbjImageWrite3.setParameter("writeParam", param3);
// Writing
final RenderedOp op3 = JAI.create("ImageWrite", pbjImageWrite3);
}
use of javax.media.jai.RenderedOp in project imageio-ext by geosolutions-it.
the class JP2KWriteTest method write_GMLJp2.
// ////////////////////////////////////////////////////////////////////////
//
// Testing "GMLJp2" Create Option.
//
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_GMLJp2() throws IOException, FileNotFoundException {
if (!isJp2KakDriverAvailable)
return;
LOGGER.info("Testing JP2 Write operation with GMLJp2 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 GMLJp2.
final File outputFile1 = TestData.temp(this, "GML-.jp2", deleteTempFilesOnExit);
final File outputFile2 = TestData.temp(this, "NO-GML-.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).setGMLJp2("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).setGMLJp2("NO");
pbjImageWrite2.setParameter("writeParam", param2);
// Writing
final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
}
use of javax.media.jai.RenderedOp 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);
}
use of javax.media.jai.RenderedOp in project imageio-ext by geosolutions-it.
the class TestImageInputStream method stringImageInputStream.
/**
* Testing capabilities of {@link StringImageInputStreamSpi}.
*/
@Test
public void stringImageInputStream() {
LOGGER.info("Testing capabilities of StringImageInputStreamSpi");
// get a URL pointing to a FILE
final String inURLToFile = TestData.getResource(this, "a.txt").toString();
// get an ImageInputStream
ImageInputStream instream;
try {
instream = ImageIO.createImageInputStream(inURLToFile);
} catch (IOException e) {
LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
instream = null;
}
Assert.assertNotNull("Unable to get an StringImageInputStreamSpi from a URL pointing to a File", instream);
// get a URL pointing to an http page
try {
final String httpURL = new URL("http://www.corriere.it/").toString();
instream = ImageIO.createImageInputStream(httpURL);
} catch (MalformedURLException e) {
LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
instream = null;
} catch (IOException e) {
LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
instream = null;
}
Assert.assertNotNull("Unable to get an URLImageInputStreamSpi from a URL pointing to an http page", instream);
try {
final String url = TestData.url(this, "sample.jpeg").toString();
final ImageInputStream stream = ImageIO.createImageInputStream(url);
final RenderedOp image = JAI.create("ImageRead", stream);
if (TestData.isInteractiveTest())
visualize(image, "testURLImageInputStreamSpi");
else
image.getAsBufferedImage();
} catch (IOException e) {
LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
LOGGER.info("Testing capabilities of URLImageInputStreamSpi: SUCCESS!!!");
}
use of javax.media.jai.RenderedOp in project imageio-ext by geosolutions-it.
the class ErdasImgTest method jaiOperations.
/**
* Test read exploiting common JAI operations (Crop-Translate-Rotate)
*
* @throws FileNotFoundException
* @throws IOException
*/
@Test
public void jaiOperations() throws FileNotFoundException, IOException {
if (!isGDALAvailable) {
return;
}
File file;
try {
TestData.unzipFile(this, "test.zip");
file = TestData.file(this, fileName);
} catch (FileNotFoundException fnfe) {
warningMessage();
return;
}
// ////////////////////////////////////////////////////////////////
// preparing to read
// ////////////////////////////////////////////////////////////////
final ParameterBlockJAI pbjImageRead;
pbjImageRead = new ParameterBlockJAI("ImageRead");
pbjImageRead.setParameter("Input", file);
// get a RenderedImage
RenderedOp image = JAI.create("ImageRead", pbjImageRead);
if (TestData.isInteractiveTest())
Viewer.visualizeAllInformation(image, "Read");
else
Assert.assertNotNull(image.getTiles());
ImageIOUtilities.disposeImage(image);
}
Aggregations