to Accelerated Image - Java 2D Graphics

Java examples for 2D Graphics:Image

Description

to Accelerated Image

Demo Code


//package com.java2s;

import java.awt.Graphics;

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

import java.awt.Transparency;
import java.awt.image.BufferedImage;

public class Main {
    public static Image toAcceleratedImage(Image image) {

        GraphicsConfiguration graphicsConfiguration = GraphicsEnvironment
                .getLocalGraphicsEnvironment().getDefaultScreenDevice()
                .getDefaultConfiguration();

        BufferedImage acceleratedImage = graphicsConfiguration
                .createCompatibleImage(image.getWidth(null),
                        image.getHeight(null), Transparency.BITMASK);

        Graphics graphicsForAcceleratedImage = acceleratedImage
                .getGraphics();//w  ww  .  j av a  2s.c om
        graphicsForAcceleratedImage.drawImage(image, 0, 0, null);

        return acceleratedImage;

    }
}

Related Tutorials