Example usage for java.awt.image RenderedImage getPropertyNames

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

Introduction

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

Prototype

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.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfGraphics2D.java

/**
 * @noinspection UseOfObsoleteCollectionType
 * @see Graphics2D#drawRenderedImage(RenderedImage, AffineTransform)
 *//* w ww.  j  ava2  s  .  co m*/
@Override
public void drawRenderedImage(final RenderedImage img, final AffineTransform xform) {
    final BufferedImage image;
    if (img instanceof BufferedImage) {
        image = (BufferedImage) img;
    } else {
        final ColorModel cm = img.getColorModel();
        final int width = img.getWidth();
        final int height = img.getHeight();
        final WritableRaster raster = cm.createCompatibleWritableRaster(width, height);
        final boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
        final Hashtable properties = new Hashtable();
        final String[] keys = img.getPropertyNames();
        if (keys != null) {
            final int keyCount = keys.length;
            for (int i = 0; i < keyCount; i++) {
                properties.put(keys[i], img.getProperty(keys[i]));
            }
        }
        final BufferedImage result = new BufferedImage(cm, raster, isAlphaPremultiplied, properties);
        img.copyData(raster);
        image = result;
    }
    drawImage(image, xform, null);
}