You can use the BufferedImage.TYPE_BYTE_GRAY
as follows: Create you noise-array of type int[]
where the numbers in the array should be between [0,255]. Let's assume this pixel array is called pixelData
, then the following should work
BufferedImage img = new BufferedImage(WIDTH, HEIGHT,
BufferedImage.TYPE_BYTE_GRAY);
img.getRaster().setPixels(0, 0, WIDTH, HEIGHT, pixelData);
File output = new File("image.jpg");
try {
ImageIO.write(img, "jpg", output);
} catch (IOException e) {
e.printStackTrace();
}
If you want to have a complete example, then please look at the following question: Issue with Perlin Noise in Java