Example usage for java.awt.image BufferedImage getPropertyNames

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

Introduction

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

Prototype

public String[] getPropertyNames() 

Source Link

Document

Returns an array of names recognized by #getProperty(String) getProperty(String) or null , if no property names are recognized.

Usage

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

@Override
public BufferedImage getAsImage() throws TileIOException {
    ImageReader reader = null;//from w  ww. j  a v  a2 s . c  o 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
        }
    }
}