* @noinspection UseOfObsoleteCollectionType
* @see Graphics2D#drawRenderedImage(RenderedImage, AffineTransform)
*/
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);
}