Here you can find the source of toBufferedImage(Image i)
public static BufferedImage toBufferedImage(Image i)
//package com.java2s; //License from project: Open Source License import java.awt.*; import java.awt.image.*; import javax.swing.*; public class Main { public static BufferedImage toBufferedImage(Image i) { BufferedImage result = new BufferedImage(i.getWidth(null), i.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics2D g = result.createGraphics(); g.drawImage(i, 0, 0, null);/*from w w w .ja v a2 s . co m*/ g.dispose(); return result; } public static BufferedImage toBufferedImage(Icon icon) { BufferedImage result = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); icon.paintIcon(null, result.createGraphics(), 0, 0); return result; } }