Search in sources :

Example 46 with RenderedOp

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

the class JpegVrtTest method read.

/**
 * Simple test read
 *
 * @throws FileNotFoundException
 * @throws IOException
 */
@Test
public void read() throws FileNotFoundException, IOException {
    if (!isGDALAvailable) {
        return;
    }
    final ParameterBlockJAI pbjImageRead;
    final ImageReadParam irp = new ImageReadParam();
    final String fileName = "bw_sample.jpg.vrt";
    final File file = TestData.file(this, fileName);
    irp.setSourceSubsampling(1, 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
        Assert.assertNotNull(image.getTiles());
    ImageIOUtilities.disposeImage(image);
}
Also used : ImageReadParam(javax.imageio.ImageReadParam) RenderedOp(javax.media.jai.RenderedOp) ParameterBlockJAI(javax.media.jai.ParameterBlockJAI) File(java.io.File) ImageLayout(javax.media.jai.ImageLayout) Test(org.junit.Test) AbstractGDALTest(it.geosolutions.imageio.gdalframework.AbstractGDALTest)

Example 47 with RenderedOp

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

the class IdrisiReadVrtTest 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 = "idrisi.rst.vrt";
    TestData.unzipFile(this, "idrisi.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(86, image.getWidth());
    Assert.assertEquals(43, 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 48 with RenderedOp

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

the class NitfVrtTest method testJaiOperations.

/**
 * Test read exploiting common JAI operations (Crop-Translate-Rotate)
 *
 * @throws FileNotFoundException
 * @throws IOException
 */
@Test
public void testJaiOperations() throws FileNotFoundException, IOException {
    if (!isGDALAvailable) {
        return;
    }
    File file = TestData.file(this, fileName);
    // ////////////////////////////////////////////////////////////////
    // 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());
    ImageIOUtilities.disposeImage(image);
}
Also used : ImageReadParam(javax.imageio.ImageReadParam) 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 49 with RenderedOp

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

the class JPEGReadTest method sourceBands.

/**
 * Test sourceBands management capabilities.
 *
 * @throws FileNotFoundException
 * @throws IOException
 */
@Test
public void sourceBands() throws IOException, FileNotFoundException {
    if (!isGDALAvailable) {
        return;
    }
    final File inputFile = TestData.file(this, "small_world.jpg");
    // //
    // 
    // Preparing srcRegion constants
    // 
    // //
    final int srcRegionX = 40;
    final int srcRegionY = 50;
    final int srcRegionWidth = 400;
    final int srcRegionHeight = 300;
    final int subSamplingX = 2;
    final int subSamplingY = 1;
    // //
    // 
    // Setting source settings parameters
    // 
    // //
    ImageReadParam rparam = new ImageReadParam();
    rparam.setSourceRegion(new Rectangle(srcRegionX, srcRegionY, srcRegionWidth, srcRegionHeight));
    rparam.setSourceSubsampling(subSamplingX, subSamplingY, 0, 0);
    rparam.setSourceBands(new int[] { 0 });
    // //
    // 
    // Setting destination settings parameters
    // 
    // //
    rparam.setDestinationBands(new int[] { 0 });
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
    ColorModel cm = RasterFactory.createComponentColorModel(// dataType
    DataBuffer.TYPE_BYTE, // color space
    cs, // has alpha
    false, // is alphaPremultiplied
    false, // transparency
    Transparency.OPAQUE);
    final int destWidth = srcRegionWidth / subSamplingX;
    final int destHeight = srcRegionHeight / subSamplingY;
    Assert.assertEquals(destWidth, 200);
    Assert.assertEquals(destHeight, 300);
    final SampleModel sm = cm.createCompatibleSampleModel(destWidth, destHeight);
    rparam.setDestinationType(new ImageTypeSpecifier(cm, sm));
    // //
    // 
    // Preparing for image read operation
    // 
    // //
    ImageReader reader = new JpegGDALImageReaderSpi().createReaderInstance();
    final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI("ImageRead");
    pbjImageRead.setParameter("Input", inputFile);
    pbjImageRead.setParameter("reader", reader);
    pbjImageRead.setParameter("readParam", rparam);
    final ImageLayout l = new ImageLayout();
    l.setTileGridXOffset(0).setTileGridYOffset(0).setTileHeight(128).setTileWidth(128);
    RenderedOp image = JAI.create("ImageRead", pbjImageRead, new RenderingHints(JAI.KEY_IMAGE_LAYOUT, l));
    if (TestData.isInteractiveTest())
        Viewer.visualizeAllInformation(image, "imageread");
    else
        Assert.assertNotNull(image.getTiles());
    ImageIOUtilities.disposeImage(image);
}
Also used : ParameterBlockJAI(javax.media.jai.ParameterBlockJAI) ColorSpace(java.awt.color.ColorSpace) Rectangle(java.awt.Rectangle) ImageTypeSpecifier(javax.imageio.ImageTypeSpecifier) RenderingHints(java.awt.RenderingHints) ImageReadParam(javax.imageio.ImageReadParam) SampleModel(java.awt.image.SampleModel) RenderedOp(javax.media.jai.RenderedOp) ColorModel(java.awt.image.ColorModel) ImageReader(javax.imageio.ImageReader) File(java.io.File) ImageLayout(javax.media.jai.ImageLayout) Test(org.junit.Test) AbstractGDALTest(it.geosolutions.imageio.gdalframework.AbstractGDALTest)

Example 50 with RenderedOp

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

the class JPEGReadTest method read.

/**
 * Simple test read
 *
 * @throws FileNotFoundException
 * @throws IOException
 */
@Test
public void read() throws FileNotFoundException, IOException {
    if (!isGDALAvailable) {
        return;
    }
    final ParameterBlockJAI pbjImageRead;
    final ImageReadParam irp = new ImageReadParam();
    final String fileName = "bw_sample.jpg";
    final File file = TestData.file(this, fileName);
    irp.setSourceSubsampling(1, 2, 0, 0);
    pbjImageRead = new ParameterBlockJAI("ImageRead");
    pbjImageRead.setParameter("Input", file);
    pbjImageRead.setParameter("Reader", new JpegGDALImageReaderSpi().createReaderInstance());
    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
        Assert.assertNotNull(image.getTiles());
    ImageIOUtilities.disposeImage(image);
}
Also used : ImageReadParam(javax.imageio.ImageReadParam) 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)

Aggregations

RenderedOp (javax.media.jai.RenderedOp)82 File (java.io.File)72 ParameterBlockJAI (javax.media.jai.ParameterBlockJAI)71 Test (org.junit.Test)61 ImageReadParam (javax.imageio.ImageReadParam)48 AbstractGDALTest (it.geosolutions.imageio.gdalframework.AbstractGDALTest)32 ImageWriter (javax.imageio.ImageWriter)28 ImageLayout (javax.media.jai.ImageLayout)28 ImageWriteParam (javax.imageio.ImageWriteParam)23 RenderingHints (java.awt.RenderingHints)21 FileImageOutputStreamExtImpl (it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl)20 ImageReader (javax.imageio.ImageReader)14 FileNotFoundException (java.io.FileNotFoundException)13 Rectangle (java.awt.Rectangle)9 IIOMetadata (javax.imageio.metadata.IIOMetadata)5 IOException (java.io.IOException)4 ImageInputStream (javax.imageio.stream.ImageInputStream)4 FileImageInputStreamExtImpl (it.geosolutions.imageio.stream.input.FileImageInputStreamExtImpl)3 ColorSpace (java.awt.color.ColorSpace)3 ColorModel (java.awt.image.ColorModel)3