How does one convert an Image object to a RenderedImage?

Curtis Hatter

This may not be the best way to do it, but this is how I converted into a rendered image.

// construct the buffered image
BufferedImage bImage      = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB);

//obtain it's graphics
Graphics2D bImageGraphics = bImage.createGraphics();

//draw the Image (image) into the BufferedImage (bImage)
bImageGraphics.drawImage(image, null, null);

// cast it to rendered image
RenderedImage rImage      = (RenderedImage)bImage;

That's all I did and it worked extremely well. I have yet to find a way to cut out going to the BufferedImage first.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact