Here you can find the source of toBufferedImage(Image image)
public static BufferedImage toBufferedImage(Image image)
//package com.java2s; /*/* www. j a v a2 s . c o m*/ * Copyright (C) 2007, 2008 Quadduc <quadduc@gmail.com> * Copyright (C) 2007, 2011 IsmAvatar <IsmAvatar@gmail.com> * Copyright (C) 2007 Clam <clamisgood@gmail.com> * Copyright (C) 2013, Robert B. Colton * * This file is part of FLUIDIDE. * FLUIDIDE is free software and comes with ABSOLUTELY NO WARRANTY. * See LICENSE for details. */ import java.awt.Graphics; import java.awt.Image; import java.awt.image.BufferedImage; import javax.swing.ImageIcon; public class Main { public static BufferedImage toBufferedImage(Image image) { if (image instanceof BufferedImage) return (BufferedImage) image; // This code ensures that all the pixels in the image are loaded image = new ImageIcon(image).getImage(); BufferedImage bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics g = bimage.createGraphics(); g.drawImage(image, 0, 0, null); g.dispose(); return bimage; } }