views:

40

answers:

1

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.

+2  A: 

There is a problem in your code and it isn't located in the snippet your provide. The memory and CPU usage should not depend much on the size of the pic (supposing it is a static image).

Please provide the code where you fill the mainMap with the backgroung image.

BenoitParis