Canvas to BufferedImage





2
Date Submitted Fri. Oct. 19th, 2007 8:09 PM
Revision 1 of 1
Helper rugi
Tags BufferedImage | Canvas | Image | Java
Comments 0 comments
Convert java.awt.Canvas to java.awt.image.BufferedImage

    private BufferedImage canvasToBufferedImage(Canvas sp) {
        int w = sp.getWidth();
        int h = sp.getHeight();
        int type = BufferedImage.TYPE_INT_RGB;
        BufferedImage image = new BufferedImage(w,h,type);
        Graphics2D g2 = image.createGraphics();
        sp.paint(g2);
        g2.dispose();
        return image;
    }   
 

Isaac Ruiz Guerra

weblogs.javahispano.org/rugi/
"non nobis domine"

Comments

There are currently no comments for this snippet.

Voting

Votes Up


Syntax Master dannyboy
Helper rugi

Votes Down