List of usage examples for java.awt GraphicsConfiguration createCompatibleVolatileImage
public VolatileImage createCompatibleVolatileImage(int width, int height, ImageCapabilities caps, int transparency) throws AWTException
From source file:Main.java
public static BufferedImage toBufferedImage(Image image) { if (image instanceof BufferedImage) { return (BufferedImage) image; }// w w w . j ava 2s. co m // This code ensures that all the pixels in the image are loaded image = new ImageIcon(image).getImage(); // Create a buffered image with a format that's compatible with the screen BufferedImage bimage = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { GraphicsDevice gs = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gs.getDefaultConfiguration(); VolatileImage vbimage = gc.createCompatibleVolatileImage(200, 200, gc.getImageCapabilities(), Transparency.BITMASK); } catch (Exception e) { // The system does not have a screen } return bimage; }