Copying images with transparency

I’ve got a bunch of BufferedImages that I would like to copy to CompatibleImages without losing the transparency. How would I do that? Getting the Graphics object of the CompatibleImages and using drawImage()?

BufferedImage bi = createCompatibleImage(width,height,Transparency.BITMASK)
Graphics2D g2d = bi.createGraphics();
g2d.setComposite(AlphaComposite.Src);
g2d.drawImage(unmanagedImage,0,0,null);
g2d.dispose();

Just what I needed. Thanks!