create Translucent Compatible Image - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage Create

Description

create Translucent Compatible Image

Demo Code


//package com.java2s;

import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;

import java.awt.Transparency;

import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage createTranslucentCompatibleImage(int width,
            int height) {
        return getGraphicsConfiguration().createCompatibleImage(width,
                height, Transparency.TRANSLUCENT);
    }//from w w w  . j  a va  2  s.c o  m

    public static BufferedImage createCompatibleImage(int width, int height) {
        return getGraphicsConfiguration().createCompatibleImage(width,
                height);
    }

    private static GraphicsConfiguration getGraphicsConfiguration() {
        return GraphicsEnvironment.getLocalGraphicsEnvironment()
                .getDefaultScreenDevice().getDefaultConfiguration();
    }
}

Related Tutorials