I have to create an image with very large resolution, but the image is relatively "sparse", only some areas in the image need to draw.
For example with following code
/* this take 5GB memory */
final BufferedImage img = new BufferedImage( 36000, 36000, BufferedImage.TYPE_INT_ARGB);
/* draw something */
Graphics g = img.getGraphics();
g.drawImage(....);
/* output as PNG */
final File out = new File("out.png");
ImageIO.write(img, "png", out);
The PNG image on the end I created is ONLY about 200~300 MB.
The question is how can I avoid creating a 5GB BufferedImage at the beginning? I do need an image with large dimension, but with very sparse color information.
Is there any Stream for BufferedImage so that it will not take so much memory?