private static BufferedImage createCompatibleImage(BufferedImage image) { GraphicsConfiguration gc = BufferedImageGraphicsConfig.getConfig(image); int w = image.getWidth(); int h = image.getHeight(); BufferedImage result = gc.createCompatibleImage(w, h, Transparency.TRANSLUCENT); Graphics2D g2 = result.createGraphics(); g2.drawRenderedImage(image, null); g2.dispose(); return result; }