Displaying large images
A typical image I want to display ( and be able to scroll around ) is 20 Mb, 10000 x 5000 pixels, png format.
Trying to load such an image, I get Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
despite increasing the heap space available to the runtime environment with:
in the eclpise.ini file
I have tried loading just a portion of the image and this works:
File file = new File(ChartInfo.chartDir + "\\"
ImageInputStream iis = ImageIO.createImageInputStream(file);
Iterator readers = ImageIO.getImageReadersByFormatName("png");
reader = (ImageReader) readers.next();
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
viewRectangle = new Rectangle(dim);
ImageReadParam readParam = reader.getDefaultReadParam();
However, the image takes 5 seconds to load. Scrolling to a different part of the image takes just as long.
Any suggestions most welcome.
I don't use Eclipse, but doesn't changing runtime parameters in the ini file only affect Eclipse itself and not the application run from Eclipse?
In NetBeans, the parameters with which an application is run are set from the project properties. I imagine Eclipse would have something similar.
You're right Darryl, thanks.
Run As -> Open Run Dialog ->
-> (x)=Arguments -> VM Arguments
Setting a bigger value there fixed the problem.