Here you can find the source of newOptimizedImageLike(GraphicsConfiguration destination, BufferedImage img)
public static BufferedImage newOptimizedImageLike(GraphicsConfiguration destination, BufferedImage img)
//package com.java2s; /*=========================================================================== COPYRIGHT 2013 Vin?cius G. Mendon?a ALL RIGHTS RESERVED. //from w w w . j a va 2 s .co m This software cannot be copied, stored, distributed without Vin?cius G. Mendon?a prior authorization. This file was made available on https://github.com/ViniGodoy and it is free to be redistributed or used under Creative Commons license 2.5 br: http://creativecommons.org/licenses/by-sa/2.5/br/ ============================================================================*/ import java.awt.*; import java.awt.image.BufferedImage; public class Main { public static BufferedImage newOptimizedImageLike(GraphicsConfiguration destination, BufferedImage img) { return newOptimizedImage(destination, img.getWidth(), img.getHeight(), img.getColorModel().hasAlpha(), img.getTransparency()); } public static BufferedImage newOptimizedImageLike(BufferedImage img) { return newOptimizedImageLike(getDefaultConfig(), img); } public static BufferedImage newOptimizedImage(GraphicsConfiguration destination, int width, int height, boolean alpha, int transparency) { return alpha ? destination.createCompatibleImage(width, height, transparency) : destination.createCompatibleImage(width, height); } public static BufferedImage newOptimizedImage(int width, int height, boolean alpha, int transparency) { return newOptimizedImage(getDefaultConfig(), width, height, alpha, transparency); } private static GraphicsConfiguration getDefaultConfig() { return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration(); } }