Example usage for java.awt.image BufferedImage getProperty

List of usage examples for java.awt.image BufferedImage getProperty

Introduction

In this page you can find the example usage for java.awt.image BufferedImage getProperty.

Prototype

public Object getProperty(String name) 

Source Link

Document

Returns a property of the image by name.

Usage

From source file:org.deegree.tile.persistence.geotiff.GeoTIFFTile.java

@Override
public BufferedImage getAsImage() throws TileIOException {
    ImageReader reader = null;/* w ww  . j a va  2 s .  co  m*/
    try {
        reader = (ImageReader) readerPool.borrowObject();
        BufferedImage img = reader.readTile(imageIndex, x, y);
        if (img.getWidth() != sizeX || img.getHeight() != sizeY) {
            Hashtable<Object, Object> table = new Hashtable<Object, Object>();
            String[] props = img.getPropertyNames();
            if (props != null) {
                for (String p : props) {
                    table.put(p, img.getProperty(p));
                }
            }
            BufferedImage img2 = new BufferedImage(img.getColorModel(),
                    img.getData().createCompatibleWritableRaster(sizeX, sizeY), img.isAlphaPremultiplied(),
                    table);
            Graphics2D g = img2.createGraphics();
            g.drawImage(img, 0, 0, null);
            g.dispose();
            img = img2;
        }
        return img;
    } catch (Exception e) {
        throw new TileIOException("Error retrieving image: " + e.getMessage(), e);
    } finally {
        try {
            readerPool.returnObject(reader);
        } catch (Exception e) {
            // ignore closing error
        }
    }
}