Image to BufferedImage - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage Convert

Description

Image to BufferedImage

Demo Code


//package com.java2s;

import java.awt.Image;

import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage bufferImage(Image in) {
        BufferedImage buf = new BufferedImage(in.getWidth(null),
                in.getHeight(null), BufferedImage.TYPE_INT_ARGB);
        buf.createGraphics().drawImage(in, 0, 0, null);
        return buf;
    }/*w  w  w .ja v  a  2 s.c  o m*/
}

Related Tutorials