Is there any way to read Bufferstrategy´s backbuffer into bufferedimage without calling BufferStrategy.show()?
Yes, but its a hideous hack - and requires the permission "readDisplayPixels" to be set (so it won't work in unsigned Applets for example)
The way to do it, is create your own class that implements the Composite interface. (as Compositing operations require access to the destination Raster)
You can then do something like :-
1 2 3 4 5 6 7 8
| PixelReadbackComposite prc = new PixelReadbackComposite(); Graphics2D g2d = (Graphics2D)bufferStrategy.getDrawGraphics(); g2d.setComposite(prc);
g2d.fillRect(0,0,getWidth(),getHeight()); Image bufferStrategyContents = prc.getDestination(); |