I'm currently working on an app that requires me to draw two large images (15MP) which can be zoomed, panned and resized. It works fine but the images total 500MB but it uses up 3.5GB of memory, which is fine on pc for what i need it for but will probably not work too well on a mobile device. At the moment, the code loads the two BufferedImages and then draws them as necessary within a viewport on the screen. I am aware that swing essentially keeps two copies of the BufferedImage, the normal one that was loaded (in raw uncompressed format) and a second copy which is essentially what gets drawn to the screen.
So, my question is this, is there a way for me to optimize this process? As in, make it so that it does not use up enormous amounts of memory. So far i've tried using ImageReaders to subsample the image and only load in as needed but i'm sort of fumbling in the dark and it still seems to use up massive amounts of memory. If necessary i'll need to swap to another programming language (most likely C++) but i'd rather keep it in java so if anyone has any ideas, it would be very much appreciated.