I'm having a buffered image with lot of small square's(grid).This image is created based on a user selected background image.If the selection is small the image appears fast.But if the selection is a large then memory overflow happen even if set to 1GB. The code for buffered image is like this:
mainMap = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
I'm only using 4 colors.I would like to optimize the code for both space and time. Please suggest.