Making a BufferedImage managed
I am having problems getting the performance I want when drawing images.
I load a BufferedImage using ImageIO then draw it to a JPanel using the Graphics2D.draw(Image, AffineTransform, ImageObserver) method. The first time I draw this image it is much slower than subsequent calls. I think that the BufferedImage becomes 'Managed' through the creation of a CachingSurfaceManager that creates an accelerated SurfaceData object (I have be looking at the Java source).
I want my calls to drawImage to be as fast as possible (I am scrolling an area with many images drawn on it in various places). So much so that if I have not got an accelerated BufferedImage already then I will skip drawing it and return to it later. I currently load the image from file in a separate Thread and it is here that I want to explicitly make the BufferedImage 'Managed'. I thought that I was there by explicitly calling validate(gc) on the CachingSurfaceManager for the image, but that did not work. The first call to draw is still much slower.
The other option was to create a VolatileImage and draw that. The problem is that I need it to work just as well with the opengl and d3d rendering pipeline. OpenGL is fine, D3D for some reason is slow.
I am using JDK6. Any help would be appreciated.