there. I’m using Java to build a desktop program which needs to frequently repaint. Just like below:
class myWindow extends JWindow {
Image[] layers = new Image[8] // Some png Image object filled here
@Override
public void paint(Graphics g) {
int i;
super.paint();
for (i=0;i<=7;i++)
g.paintImage(layers[i], /*other param*/);
}
}
As we can see, it costs time to paint, so I want to build a buffer for some of the layer. It should be an Image or Graphics object.
But then I found that I can take no method to merge the Image (just put them one on the other).
So my question is: How can I build a buffer as I mentioned above , or if I use paintImage() to draw on a alternative Graphics, How can I use this Graphics to draw my window
Thanks to all.
Here’s one way to merge the Image array.