Here you can find the source of optimizeForGraphicsHardware(BufferedImage image)
Parameter | Description |
---|---|
image | The image to optimize. |
public static BufferedImage optimizeForGraphicsHardware(BufferedImage image)
//package com.java2s; import java.awt.*; public class Main { /**/* ww w. j a v a2 s . c o m*/ * Converts an image to an optimized version for the default screen.<br> * The optimized image should draw faster. * @param image The image to optimize. * @return Returns the optimized image. */ public static BufferedImage optimizeForGraphicsHardware(BufferedImage image) { try { // create an empty optimized BufferedImage GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); int w = image.getWidth(); int h = image.getHeight(); BufferedImage optimized = gc.createCompatibleImage(w, h); // draw the passed image into the optimized image optimized.getGraphics().drawImage(image, 0, 0, null); return optimized; } catch (Throwable e) { // return the original image if an exception occured. return image; } } }