0

我编写了一个 Java 颜色缓冲区类,其中包含一个 2D 浮点数组,即缓冲区。现在我想用我的缓冲区交换来自我的 JFrame/Canvas 的 BufferStrategy 的缓冲区。我通过使用 drawLine 将缓冲区的每个像素绘制到屏幕上来做到这一点:

public void exchangeBuffers(Graphics g) {
    for (int i = 0; i < width; i++)
        for (int j = 0; j < width; j++)
            g.drawLine(i, j, i, j);
}

现在有没有更好的方法来做到这一点?使用它的性能真的很低。

4

0 回答 0