如何将二维整数数组转换为灰度 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 的整数。