3

image[][] という配列があり、これから BufferedImage を作成して、プレーヤーにファイルに保存させることができます。

4

1 に答える 1

7
// Initialize Color[][] however you were already doing so.
Color[][] image;

// Initialize BufferedImage, assuming Color[][] is already properly populated.
BufferedImage bufferedImage = new BufferedImage(image.length, image[0].length,
        BufferedImage.TYPE_INT_RGB);

// Set each pixel of the BufferedImage to the color from the Color[][].
for (int x = 0; x < image.length; x++) {
    for (int y = 0; y < image[x].length; y++) {
        bufferedImage.setRGB(x, y, image[x][y].getRGB());
    }
}

これは、画像を作成する (そして保存する可能性がある) 簡単な方法です。ただし、これは決して効率的ではありません。より大きな画像で試してみると、顕著な速度の違いがわかります。

于 2012-11-15T04:10:37.823 に答える