Skip to main content

[JAI] Loading images in a memory and time efficient manner using JAI

1 reply [Last post]
Anonymous

Hello all,

I am not currently using JAI, however I'd like to investigate to see whether
it may help resolve some of the problems I am seeing with loading large
images. Basically, I am storing the images in a database as a BLOB (raw
pixels). I retrieve the image data from the database ultimately as a byte
array. From this point I construct a BufferedImage using the following
technique:

a) Extract the width/height/image type from the byte[] data.

b) Read each pixel as an int[] and then invoke BufferedImage.setRGB().

It turns out that this approach isn't very memory/time efficient when
loading large images. It seems to use an excessive amount of memory since
the whole image is in memory all of the time.

I'm wondering if JAI would be of any help here? Given that I have raw pixel
data, how does JAI help in this case? Would I still be using a
"BufferedImage" in my program or would I be using some other data structure?
Does JAI tiling help out in any way here?

Thank you for any advice/suggestions.

Ryan

[att1.html]

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Brian Burkhalter

There is a "raw" image reader in JAI-Image I/O Tools that would likely help in
this context. As you are dealing with uncompressed data you just need to
provide the raw data stream and a description of its layout.

See

http://java.sun.com/products/java-media/jai/forDevelopers/jai-imageio-1_...

for more information.

Brian

On Fri, 21 Oct 2005, Ryan LeCompte wrote:

> Hello all,
>
>
>
> I am not currently using JAI, however I'd like to investigate to see whether
> it may help resolve some of the problems I am seeing with loading large
> images. Basically, I am storing the images in a database as a BLOB (raw
> pixels). I retrieve the image data from the database ultimately as a byte
> array. From this point I construct a BufferedImage using the following
> technique:
>
>
>
> a) Extract the width/height/image type from the byte[] data.
>
> b) Read each pixel as an int[] and then invoke BufferedImage.setRGB().
>
>
>
> It turns out that this approach isn't very memory/time efficient when
> loading large images. It seems to use an excessive amount of memory since
> the whole image is in memory all of the time.
>
>
>
> I'm wondering if JAI would be of any help here? Given that I have raw pixel
> data, how does JAI help in this case? Would I still be using a
> "BufferedImage" in my program or would I be using some other data structure?
> Does JAI tiling help out in any way here?
>
>
>
> Thank you for any advice/suggestions.
>
>
>
> Ryan
>
>
>
>

----------------
Brian Burkhalter
Java Multimedia, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net