int の 2D 配列をグレースケール png に変換するにはどうすればよいですか。今私はこれを持っています:
BufferedImage theImage = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
for(int y = 0; y<100; y++){
for(int x = 0; x<100; x++){
theImage.setRGB(x, y, image[y][x]);
}
}
File outputfile = new File("saved.bmp");
ImageIO.write(theImage, "png", outputfile);
しかし、画像は青くなります。どうすればグレースケールにできますか。
image[][] には、0 ~ 256 の範囲の整数が含まれます。