is there a way to get the content of the current Buffer im writing to? a sort of a representation of what i've written to its graphics. For example, in the following code, i would like to get a BufferedImage or even an Array that has values that represent what i've written, in this case; a black background and a white rectangle:
public static void render (Canvas canvas) {
BufferStrategy buffer = canvas.getBufferStrategy();
Graphics g = buffer.getDrawGraphics();
g.setColor(Color.BLACK);
g.fillRect(0, 0, canvas.getWidth(), canvas.getHeight());
g.setColor(Color.WHITE);
g.drawRect(50, 50, 100, 100);
g.dispose();
// Maybe a method here that allows me to get what has been writen?
buffer.show();
}
Thanks in advance!