aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes BufferedImage alternative? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "BufferedImage alternative?" Watch "BufferedImage alternative?" New topic
Author

BufferedImage alternative?

Mitchell Holmans
Greenhorn

Joined: Jan 07, 2013
Posts: 2
Hi all,

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.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4546
    
    5

I've never had occasion to use it, but I wonder if VolatileImage would help here.

Also, you can try setDoubleBuffered(false) as that should reduce the memory footprint.


luck, db
There are no new questions, but there may be new answers.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41884
    
  63
Which mobile devices are you targeting? I'm not aware of any that would support any kind of Swing-based or ImageIO-based solution, irrespective of the memory requirements.


Ping & DNS - my free Android networking tools app
Mitchell Holmans
Greenhorn

Joined: Jan 07, 2013
Posts: 2
It will be for iPhone, Android and PC but the initial PC implementation is being used to figure out how the program will work and how to deal with large images and small amounts of memory.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4546
    
    5

Well, the other devices don't furnish the same API, so I don't see how optimizing for a PC is going to solve anything.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BufferedImage alternative?