Converting an Image to a Buffered Image BufferedImage toBufferedImage(Image image) { // This code ensures that all the pixels in // the image are loaded. image = new ImageIcon(image).getImage(); // Create the buffered image. BufferedImage bufferedImage = new BufferedImage( image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB); // Copy image to buffered image. Graphics g = bufferedImage.createGraphics(); // Clear background and paint the image. g.setColor(Color.white); g.fillRect(0, 0, image.getWidth(null), image.getHeight(null)); g.drawImage(image, 0, 0, null); g.dispose(); return bufferedImage; }