I need to create an image with a very high resolution, but the image is relatively "sparse", I need to draw only some areas of the image.
For example, using the following code
final BufferedImage img = new BufferedImage( 36000, 36000, BufferedImage.TYPE_INT_ARGB);
Graphics g = img.getGraphics();
g.drawImage(....);
final File out = new File("out.png");
ImageIO.write(img, "png", out);
The PNG image at the end that I created is ONLY about 200 ~ 300 MB.
Question: How can I avoid creating a 5GB BufferedImage at the beginning? I need an image with a large size, but with very rare color information.
Is there any thread for BufferedImage so it doesn't take up so much memory?
source
share