Java BufferedImage Operation newOptimizedImageLike(GraphicsConfiguration destination, BufferedImage img)

Here you can find the source of newOptimizedImageLike(GraphicsConfiguration destination, BufferedImage img)

Description

new Optimized Image Like

License

Open Source License

Declaration

public static BufferedImage newOptimizedImageLike(GraphicsConfiguration destination, BufferedImage img) 

Method Source Code


//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();
    }
}

Related

  1. makeTintedCopy(BufferedImage bi, Color tint)
  2. markImageBorders(final BufferedImage img, final int startW, final int startH)
  3. matBytesToBufferedImage(byte[] data, int cols, int rows, int type)
  4. matte(BufferedImage image, int top, int bottom, int left, int right, Color bg)
  5. mirror(final BufferedImage image, final boolean horizontal)
  6. newSubimage(BufferedImage src, int x, int y, int w, int h)
  7. nNeighbors(BufferedImage image, int i, int j)
  8. nrChannels(BufferedImage img)
  9. numPixelsDifferent(BufferedImage imgA, BufferedImage imgB)