Search in sources :

Example 1 with J2KImageReader

use of com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader in project bioformats by openmicroscopy.

the class JAIIIOServiceImpl method readRaster.

/* @see JAIIIOService#readRaster(InputStream, JPEG2000CodecOptions) */
@Override
public Raster readRaster(InputStream in, JPEG2000CodecOptions options) throws IOException, ServiceException {
    J2KImageReader reader = getReader();
    MemoryCacheImageInputStream mciis = new MemoryCacheImageInputStream(in);
    reader.setInput(mciis, false, true);
    J2KImageReadParam param = (J2KImageReadParam) reader.getDefaultReadParam();
    if (options.resolution != null) {
        param.setResolution(options.resolution.intValue());
    }
    Raster raster = reader.readRaster(0, param);
    mciis.close();
    reader.dispose();
    return raster;
}
Also used : J2KImageReadParam(com.sun.media.imageio.plugins.jpeg2000.J2KImageReadParam) Raster(java.awt.image.Raster) MemoryCacheImageInputStream(javax.imageio.stream.MemoryCacheImageInputStream) J2KImageReader(com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader)

Example 2 with J2KImageReader

use of com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader in project bioformats by openmicroscopy.

the class JAIIIOServiceImpl method readImage.

/* @see JAIIIOService#readImage(InputStream, JPEG2000CodecOptions) */
@Override
public BufferedImage readImage(InputStream in, JPEG2000CodecOptions options) throws IOException, ServiceException {
    J2KImageReader reader = getReader();
    MemoryCacheImageInputStream mciis = new MemoryCacheImageInputStream(in);
    reader.setInput(mciis, false, true);
    J2KImageReadParam param = (J2KImageReadParam) reader.getDefaultReadParam();
    if (options.resolution != null) {
        param.setResolution(options.resolution.intValue());
    }
    BufferedImage image = reader.read(0, param);
    mciis.close();
    reader.dispose();
    return image;
}
Also used : J2KImageReadParam(com.sun.media.imageio.plugins.jpeg2000.J2KImageReadParam) MemoryCacheImageInputStream(javax.imageio.stream.MemoryCacheImageInputStream) J2KImageReader(com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader) BufferedImage(java.awt.image.BufferedImage)

Aggregations

J2KImageReadParam (com.sun.media.imageio.plugins.jpeg2000.J2KImageReadParam)2 J2KImageReader (com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader)2 MemoryCacheImageInputStream (javax.imageio.stream.MemoryCacheImageInputStream)2 BufferedImage (java.awt.image.BufferedImage)1 Raster (java.awt.image.Raster)1