Results 1 to 1 of 1
Thread: Efficient image loading
- 02-04-2011, 03:44 PM #1Member
- Join Date
- Feb 2011
- Rep Power
Efficient image loading
I've been working on a piece of software which involves storing and retrieving large images in a database (the database aspect isn't relevant to the problem) and I keep running into memory issues related to the fact that I can't find a way to reuse buffers for storing image data (at least in javax.imagio). More specifically, I'm in a scenario where the images are viewed one at a time and never need to be simultaneously in memory. The imageio API allows to specify an existing BufferedImage as a target for a read operation, but this will only work if the underlying SampleModels/DataBuffers are identical. In my case, the images stored and loaded from the database are in a compressed format, and can vary greatly in format resulting in errors whenever I try to reuse a BufferedImage (number of bands/samples, interleaved vs non-interleaved...). It seems impossible to just allocate a single huge byte array and keep reading images into it, overwriting whatever was in it previously. An even better solution would be to be able to get uncompressed data as a stream but I can't find this anywhere either.
Does anyone know of a lib (or a way using Java SE only) that can read most image formats in one of these two ways:
-Read an image to an existing byte buffer regardless of the format (forcing it to ARGB in four bytes for instance), provided the buffer is big enough
-Read an image as a stream of uncompressed data, allowing for any memory management approach
I've looked around JAI and as far as I could tell none of these methods are available.
Thanks a lot if anyone can help!
- By hobbles in forum New To JavaReplies: 10Last Post: 09-06-2010, 08:30 PM
- By m00nchile in forum New To JavaReplies: 5Last Post: 05-25-2010, 01:34 PM
- By lolshooter in forum New To JavaReplies: 3Last Post: 01-06-2009, 08:14 AM
- By balaram in forum Java AppletsReplies: 1Last Post: 11-06-2008, 03:13 PM
- By shaungoater in forum Java 2DReplies: 2Last Post: 01-09-2008, 09:14 AM