use of javax.media.jai.RenderedOp in project imageio-ext by geosolutions-it.
the class ArcGridReadTest method readJAI.
/**
* Simple test read through JAI - ImageIO
*
* @throws FileNotFoundException
* @throws IOException
*/
@org.junit.Test
public void readJAI() throws FileNotFoundException, IOException {
if (!isGDALAvailable) {
return;
}
final ParameterBlockJAI pbjImageRead;
final String fileName = "095b_dem_90m.asc";
TestData.unzipFile(this, "arcgrid.zip");
final File file = TestData.file(this, fileName);
pbjImageRead = new ParameterBlockJAI("ImageRead");
pbjImageRead.setParameter("Input", file);
RenderedOp image = JAI.create("ImageRead", pbjImageRead);
if (TestData.isInteractiveTest())
Viewer.visualizeAllInformation(image, fileName);
else
image.getTiles();
Assert.assertEquals(351, image.getWidth());
Assert.assertEquals(350, image.getHeight());
ImageIOUtilities.disposeImage(image);
}
use of javax.media.jai.RenderedOp in project imageio-ext by geosolutions-it.
the class JP2KKakaduWriteTest method testKakaduWriterParam.
public void testKakaduWriterParam() throws KduException, FileNotFoundException, IOException {
if (!isKakaduAvailable) {
LOGGER.warning("Kakadu libs not found: test are skipped ");
return;
}
if (files.length == 0) {
LOGGER.warning("No files have been specified. This test will be skipped");
return;
}
final String fileName = files[0];
// final String filePath = inputFileName + fileName;
// final File file = new File(filePath);
final File file = TestData.file(this, fileName);
final String filePath = file.getAbsolutePath();
if (!file.exists()) {
LOGGER.warning("Unable to find the file " + filePath + // + "\n Be sure you have properly specified the \"data.path\" property linking to the location where test data is available."
"\n This test will be skipped");
return;
}
final String suffix = fileName.substring(0, fileName.length() - 4);
LinkedList<TestConfiguration> configs = new LinkedList<TestConfiguration>();
JP2KKakaduImageWriteParam param = new JP2KKakaduImageWriteParam();
param.setSourceRegion(new Rectangle(100, 0, 450, 800));
param.setSourceSubsampling(2, 3, 0, 0);
configs.add(new TestConfiguration(outputFileName + "_pp_" + suffix, true, lossLessQuality, false, param));
configs.add(new TestConfiguration(outputFileName + "_pp_" + suffix, false, lossLessQuality, false, param));
configs.add(new TestConfiguration(outputFileName + "_pp_" + suffix, true, lossyQuality, false, param));
configs.add(new TestConfiguration(outputFileName + "_pp_" + suffix, false, lossyQuality, false, param));
configs.add(new TestConfiguration(outputFileName + "_pp_JAI_" + suffix, true, lossLessQuality, true, param));
configs.add(new TestConfiguration(outputFileName + "_pp_JAI_" + suffix, false, lossLessQuality, true, param));
for (TestConfiguration config : configs) {
final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI("ImageRead");
ImageReader reader = ImageIO.getImageReaders(ImageIO.createImageInputStream(file)).next();
pbjImageRead.setParameter("reader", reader);
pbjImageRead.setParameter("Input", file);
RenderedOp image = JAI.create("ImageRead", pbjImageRead);
write(config.outputFileName, image, config.writeCodeStreamOnly, config.quality, config.useJAI, config.param);
}
}
use of javax.media.jai.RenderedOp in project imageio-ext by geosolutions-it.
the class JP2KakaduReadTest method jaiReadFromFile.
@org.junit.Test
public void jaiReadFromFile() throws IOException {
if (!runTests)
return;
final File file = TestData.file(this, "CB_TM432.jp2");
ImageReadDescriptorMT.register(JAI.getDefaultInstance());
final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI("ImageReadMT");
ImageLayout l = new ImageLayout();
l.setTileHeight(256);
l.setTileWidth(256);
JP2KKakaduImageReadParam rp = new JP2KKakaduImageReadParam();
rp.setSourceSubsampling(1, 1, 0, 0);
rp.setSourceRegion(new Rectangle(10, 10, 200, 200));
rp.setInterpolationType(JP2KKakaduImageReadParam.INTERPOLATION_BILINEAR);
rp.setQualityLayers(2);
pbjImageRead.setParameter("ReadParam", rp);
pbjImageRead.setParameter("Input", file);
pbjImageRead.setParameter("imageChoice", 0);
RenderedOp image = JAI.create("ImageReadMT", pbjImageRead, new RenderingHints(JAI.KEY_IMAGE_LAYOUT, l));
if (TestData.isInteractiveTest())
ImageIOUtilities.visualize(image);
else
Assert.assertNotNull(image.getTiles());
}
use of javax.media.jai.RenderedOp in project imageio-ext by geosolutions-it.
the class PngSuiteImagesTest method testRoundTripTiledImage.
@Test
public void testRoundTripTiledImage() throws Exception {
BufferedImage input = ImageIO.read(sourceFile);
// prepare a tiled image layout
ImageLayout il = new ImageLayout(input);
il.setTileWidth(8);
il.setTileHeight(8);
RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il);
RenderedOp tiled = FormatDescriptor.create(input, input.getSampleModel().getDataType(), hints);
assertEquals(8, tiled.getTileWidth());
assertEquals(8, tiled.getTileHeight());
roundTripPNGJ(input, tiled);
}
use of javax.media.jai.RenderedOp in project imageio-ext by geosolutions-it.
the class JPEGReadTest method multithreadedJAIRead.
/**
* Simple test read
*
* @throws FileNotFoundException
* @throws IOException
*/
public void multithreadedJAIRead() throws FileNotFoundException, IOException {
if (!isJmagickAvailable) {
LOGGER.warning("JMagick Library is not Available; Skipping tests");
return;
}
// register the image read mt operation
ImageReadDescriptorMT.register(JAI.getDefaultInstance());
// get the file we are going to read
final String fileName = "001140.jpg";
final File file = TestData.file(this, fileName);
// acquire a reader for it but check that it is the right one
final Iterator readersIt = ImageIO.getImageReaders(file);
ImageReader reader = null;
while (readersIt.hasNext()) {
reader = (ImageReader) readersIt.next();
if (reader instanceof JpegJMagickImageReader)
break;
reader = null;
}
assertNotNull(reader);
// do an image read with jai
final ParameterBlockJAI pbjImageRead;
final ImageReadParam irp = reader.getDefaultReadParam();
irp.setSourceSubsampling(4, 4, 0, 0);
pbjImageRead = new ParameterBlockJAI("ImageReadMT");
pbjImageRead.setParameter("Input", file);
pbjImageRead.setParameter("Reader", reader);
pbjImageRead.setParameter("readParam", irp);
// set the layout so that we shrink the amount of memory needed to load
// this image
final ImageLayout l = new ImageLayout();
l.setTileGridXOffset(0).setTileGridYOffset(0).setTileHeight(512).setTileWidth(512);
RenderedOp image = JAI.create("ImageReadMT", pbjImageRead, new RenderingHints(JAI.KEY_IMAGE_LAYOUT, l));
if (TestData.isInteractiveTest()) {
final JFrame jf = new JFrame();
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.getContentPane().add(new ScrollingImagePanel(image, 1024, 768));
jf.pack();
jf.show();
} else {
assertNotNull(image.getTiles());
// remember that if we do not explictly provide an Imagereader to
// the ImageReadMT operation it consistently dispose the one it
// creates once we dispose the ImageReadOpImage
image.dispose();
}
}
Aggregations