Here you can find the source of imageToBufferedImage(ImageIcon src)
public static BufferedImage imageToBufferedImage(ImageIcon 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 www .jav a2s .c o m 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()); } }