question: private BufferedImage toBufferedImage ( final Image image ) { if ( image instanceof BufferedImage ) { return ( BufferedImage ) image ; } if ( image instanceof VolatileImage ) { VolatileImage volatileImage = ( VolatileImage ) image ; return volatileImage . getSnapshot ( ) ; } GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment . getLocalGraphicsEnvironment ( ) ; GraphicsDevice graphicsDevice = graphicsEnvironment . getDefaultScreenDevice ( ) ; GraphicsConfiguration graphicsConfiguration = graphicsDevice . getDefaultConfiguration ( ) ; BufferedImage bufferedImage = graphicsConfiguration . createCompatibleImage ( image . getWidth ( null ) , image . getHeight ( null ) ) ; Graphics2D g = bufferedImage . createGraphics ( ) ; g . drawImage ( image , 0 , 0 , null ) ; g . dispose ( ) ; return bufferedImage ; }
target:  Convert the specified image to a BufferedImage, if necessary.