Here you can find the source of imageToBufferedImage(Image src)
public static BufferedImage imageToBufferedImage(Image src)
//package com.java2s; //License from project: Open Source License import java.awt.*; import java.awt.image.BufferedImage; import javax.swing.ImageIcon; public class Main { public static BufferedImage imageToBufferedImage(Image src) { int width = 0; int height = 0; if (src != null) { width = src.getWidth(null);/*from w w w .java 2 s.c om*/ height = src.getHeight(null); } BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR); Graphics2D g = image.createGraphics(); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.drawImage(src, 0, 0, null); g.dispose(); return image; } public static BufferedImage imageToBufferedImage(ImageIcon src) { return imageToBufferedImage(src.getImage()); } }