Java AWT BufferedImage create from existing image

Description

Java AWT BufferedImage create from existing image



//package com.demo2s;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

public class Main {

    public static BufferedImage makeCompatible(BufferedImage image) {
        BufferedImage compatibleImage = new BufferedImage(image.getWidth(), image.getHeight(),
                BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = compatibleImage.createGraphics();
        g.drawImage(image, 0, 0, null);/*ww  w.j  av  a2 s .  com*/
        g.dispose();
        return compatibleImage;
    }
}



PreviousNext

Related