0

有没有办法获取当前缓冲区即时写入的内容?一种我在其图形中写入的内容的表示。例如,在下面的代码中,我想获得一个 BufferedImage 甚至是一个数组,它的值代表我所写的内容,在这种情况下;黑色背景和白色矩形:

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();                  
    }

提前致谢!

4

0 回答 0