Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

BufferedImage alternative?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mitchell Holmans
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!