ImageGraphics to BufferedImage


This may sound counter-useful, but is there a way to load the contents of an ImageGraphics content into a new BufferedImage. The easiest way I can think of is by creating a custom version of LWJGLImageGraphics that allows access to the inner BufferedImage, but I'd like to stay true to the jME code base.

I need this for creating a pure java2D version of my UI, because some of our customers want to play the game without the necessary hardware.

Thanks a bunch,


I've added getAwtImage() to LWJGLImageGraphics for you. Is this enough?

That's perfect. Thanks a bunch.

LWJGLImageGraphics is package-private, so I cannot access it without an abstract method of the same name in ImageGraphics.

uh, right. But ImageGraphics should not get that method as it is not required to implement it with a BufferedImage. What about subclassing LWJGLImageGraphics with a public class with the same package name?  (otherwise I could make LWJGLImageGraphics public, but usually people should not use it directly…)

I'll do that then.