Search in sources :

Example 21 with ParameterBlockJAI

use of javax.media.jai.ParameterBlockJAI in project imageio-ext by geosolutions-it.

the class EnvisatTest method testEnvisat.

/**
 * Test read exploiting common JAI operations (Crop-Translate-Rotate)
 *
 * @throws FileNotFoundException
 * @throws IOException
 */
@Test
public void testEnvisat() throws FileNotFoundException, IOException {
    if (!isGDALAvailable) {
        return;
    }
    File file;
    try {
        file = TestData.file(this, fileName);
    } catch (FileNotFoundException fnfe) {
        warningMessage();
        return;
    }
    // ////////////////////////////////////////////////////////////////
    // preparing to read
    // ////////////////////////////////////////////////////////////////
    final ParameterBlockJAI pbjImageRead;
    final ImageReadParam irp = new ImageReadParam();
    // subsample by 2 on both dimensions
    final int xSubSampling = 2;
    final int ySubSampling = 2;
    final int xSubSamplingOffset = 0;
    final int ySubSamplingOffset = 0;
    irp.setSourceSubsampling(xSubSampling, ySubSampling, xSubSamplingOffset, ySubSamplingOffset);
    pbjImageRead = new ParameterBlockJAI("ImageRead");
    pbjImageRead.setParameter("Input", file);
    pbjImageRead.setParameter("readParam", irp);
    // get a RenderedImage
    RenderedOp image = JAI.create("ImageRead", pbjImageRead);
    if (TestData.isInteractiveTest())
        Viewer.visualizeAllInformation(image, "Subsampling Read");
    else
        Assert.assertNotNull(image.getTiles());
}
Also used : ImageReadParam(javax.imageio.ImageReadParam) RenderedOp(javax.media.jai.RenderedOp) ParameterBlockJAI(javax.media.jai.ParameterBlockJAI) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File) Test(org.junit.Test) AbstractGDALTest(it.geosolutions.imageio.gdalframework.AbstractGDALTest)

Example 22 with ParameterBlockJAI

use of javax.media.jai.ParameterBlockJAI in project imageio-ext by geosolutions-it.

the class RPFTOCTest method read.

@Test
public void read() throws FileNotFoundException, IOException {
    if (!isGDALAvailable) {
        return;
    }
    File file;
    try {
        file = TestData.file(this, fileName);
    } catch (FileNotFoundException fnfe) {
        warningMessage();
        return;
    }
    // ////////////////////////////////////////////////////////////////
    // preparing to read
    // ////////////////////////////////////////////////////////////////
    final ParameterBlockJAI pbjImageRead;
    final ImageReadParam irp = new ImageReadParam();
    // subsample by 2 on both dimensions
    final int xSubSampling = 2;
    final int ySubSampling = 2;
    final int xSubSamplingOffset = 0;
    final int ySubSamplingOffset = 0;
    irp.setSourceSubsampling(xSubSampling, ySubSampling, xSubSamplingOffset, ySubSamplingOffset);
    pbjImageRead = new ParameterBlockJAI("ImageRead");
    pbjImageRead.setParameter("Input", file);
    pbjImageRead.setParameter("readParam", irp);
    // get a RenderedImage
    RenderedOp image = JAI.create("ImageRead", pbjImageRead);
    if (TestData.isInteractiveTest())
        Viewer.visualizeAllInformation(image, "Subsampling Read");
    else {
        Raster[] io = image.getTiles();
        Assert.assertNotNull(io);
        Assert.assertTrue(image.getWidth() == 768);
        Assert.assertTrue(image.getHeight() == 768);
    }
    ImageIOUtilities.disposeImage(image);
}
Also used : ImageReadParam(javax.imageio.ImageReadParam) RenderedOp(javax.media.jai.RenderedOp) ParameterBlockJAI(javax.media.jai.ParameterBlockJAI) Raster(java.awt.image.Raster) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File) Test(org.junit.Test) AbstractGDALTest(it.geosolutions.imageio.gdalframework.AbstractGDALTest)

Example 23 with ParameterBlockJAI

use of javax.media.jai.ParameterBlockJAI in project imageio-ext by geosolutions-it.

the class ArcGridReadVrtTest method readJAI.

/**
 * Simple test read through JAI - ImageIO
 *
 * @throws FileNotFoundException
 * @throws IOException
 */
@Test
public void readJAI() throws FileNotFoundException, IOException {
    if (!isGDALAvailable) {
        return;
    }
    final ParameterBlockJAI pbjImageRead;
    final String fileName = "095b_dem_90m.asc.vrt";
    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);
}
Also used : RenderedOp(javax.media.jai.RenderedOp) ParameterBlockJAI(javax.media.jai.ParameterBlockJAI) File(java.io.File) Test(org.junit.Test) AbstractGDALTest(it.geosolutions.imageio.gdalframework.AbstractGDALTest)

Example 24 with ParameterBlockJAI

use of javax.media.jai.ParameterBlockJAI in project imageio-ext by geosolutions-it.

the class ECWTest method imageRead.

// ecwp
/**
 * Test reading of a RGB image
 *
 * @throws FileNotFoundException
 * @throws IOException
 */
@Test
public void imageRead() throws FileNotFoundException, IOException {
    if (!isECWAvailable)
        return;
    final ParameterBlockJAI pbjImageRead;
    final EnhancedImageReadParam irp = new EnhancedImageReadParam();
    final String fileName = "sample.ecw";
    final File file = TestData.file(this, fileName);
    irp.setSourceSubsampling(2, 2, 0, 0);
    pbjImageRead = new ParameterBlockJAI("ImageRead");
    pbjImageRead.setParameter("Input", file);
    pbjImageRead.setParameter("readParam", irp);
    final ImageLayout l = new ImageLayout();
    l.setTileGridXOffset(0).setTileGridYOffset(0).setTileHeight(512).setTileWidth(512);
    RenderedOp image = JAI.create("ImageRead", pbjImageRead, new RenderingHints(JAI.KEY_IMAGE_LAYOUT, l));
    if (TestData.isInteractiveTest())
        Viewer.visualizeAllInformation(image, fileName);
    else
        image.getTiles();
    Assert.assertEquals(200, image.getWidth());
    Assert.assertEquals(100, image.getHeight());
    ImageIOUtilities.disposeImage(image);
}
Also used : EnhancedImageReadParam(it.geosolutions.imageio.imageioimpl.EnhancedImageReadParam) RenderedOp(javax.media.jai.RenderedOp) ParameterBlockJAI(javax.media.jai.ParameterBlockJAI) File(java.io.File) ImageLayout(javax.media.jai.ImageLayout) RenderingHints(java.awt.RenderingHints) Test(org.junit.Test) AbstractGDALTest(it.geosolutions.imageio.gdalframework.AbstractGDALTest)

Example 25 with ParameterBlockJAI

use of javax.media.jai.ParameterBlockJAI in project imageio-ext by geosolutions-it.

the class DOQ2Test method imageRead.

/**
 * Test read exploiting common JAI operations (Crop-Translate-Rotate)
 *
 * @throws FileNotFoundException
 * @throws IOException
 */
@Test
public void imageRead() throws FileNotFoundException, IOException {
    if (!isGDALAvailable) {
        return;
    }
    File file;
    try {
        file = TestData.file(this, fileName);
    } catch (FileNotFoundException fnfe) {
        super.warningMessage();
        return;
    }
    // ////////////////////////////////////////////////////////////////
    // preparing to read
    // ////////////////////////////////////////////////////////////////
    final ParameterBlockJAI pbjImageRead;
    final ImageReadParam irp = new ImageReadParam();
    pbjImageRead = new ParameterBlockJAI("ImageRead");
    pbjImageRead.setParameter("Input", file);
    pbjImageRead.setParameter("readParam", irp);
    // NOTE that the actual sample data (fakedoq1.doq) only contains a row.
    // Therefore, we need to force the read on that reduced area.
    // Requesting a bigger image height will result in a GDAL ReadBlock error.
    irp.setSourceRegion(new Rectangle(0, 0, 500, 1));
    final ImageLayout l = new ImageLayout();
    l.setTileGridXOffset(0).setTileGridYOffset(0).setTileHeight(512).setTileWidth(512);
    // get a RenderedImage
    RenderedOp image = JAI.create("ImageRead", pbjImageRead, new RenderingHints(JAI.KEY_IMAGE_LAYOUT, l));
    if (TestData.isInteractiveTest()) {
        Viewer.visualizeAllInformation(image, "test");
    } else {
        Assert.assertNotNull(image.getTiles());
    }
    Assert.assertEquals(500, image.getWidth());
    Assert.assertEquals(1, image.getHeight());
    ImageIOUtilities.disposeImage(image);
}
Also used : ImageReadParam(javax.imageio.ImageReadParam) RenderedOp(javax.media.jai.RenderedOp) ParameterBlockJAI(javax.media.jai.ParameterBlockJAI) FileNotFoundException(java.io.FileNotFoundException) Rectangle(java.awt.Rectangle) File(java.io.File) ImageLayout(javax.media.jai.ImageLayout) RenderingHints(java.awt.RenderingHints) Test(org.junit.Test) AbstractGDALTest(it.geosolutions.imageio.gdalframework.AbstractGDALTest)

Aggregations

ParameterBlockJAI (javax.media.jai.ParameterBlockJAI)76 File (java.io.File)71 RenderedOp (javax.media.jai.RenderedOp)71 Test (org.junit.Test)57 ImageReadParam (javax.imageio.ImageReadParam)48 AbstractGDALTest (it.geosolutions.imageio.gdalframework.AbstractGDALTest)32 ImageWriter (javax.imageio.ImageWriter)28 ImageLayout (javax.media.jai.ImageLayout)26 ImageWriteParam (javax.imageio.ImageWriteParam)23 RenderingHints (java.awt.RenderingHints)22 FileImageOutputStreamExtImpl (it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl)20 FileNotFoundException (java.io.FileNotFoundException)13 ImageReader (javax.imageio.ImageReader)13 Rectangle (java.awt.Rectangle)9 IIOMetadata (javax.imageio.metadata.IIOMetadata)5 FileImageInputStreamExtImpl (it.geosolutions.imageio.stream.input.FileImageInputStreamExtImpl)3 ColorSpace (java.awt.color.ColorSpace)3 ColorModel (java.awt.image.ColorModel)3 RenderedImage (java.awt.image.RenderedImage)3 SampleModel (java.awt.image.SampleModel)3