Efficient, direct, image data loading.

Is there any freely-available code out there which will efficiently load .gif and .jpg images as raw RGBA byte arrays? I’m not interested in getting back a BufferedImage or Image. Besides, the built in java loaders seem terribly awkward and inefficient, and the only 3rd party library I’ve been able to find used a lot of native code and wasn’t implemented for the Mac.

Thanks in advance.

Devil can load gif and jpeg, and LWJGL includes a binding to it. Perhaps that will do what you want?

I was hoping for something implemented strictly in java, but thanks for the suggestion.

ImageIO does this reasonably efficiently. After you load the image, ask for the Raster from the resulting BufferedImage and get the DataBuffer from it. You can then get the image data as either a byte[] or an int[]. The TextureIO utility classes in the JOGL package do this and it seems to perform fine. You can find the source code for these classes in the JOGL CVS repository.

One of these might suit:

http://schmidt.devlib.org/java/pixel-image-io-libraries.html

Kev

[quote]ImageIO does this reasonably efficiently. After you load the image, ask for the Raster from the resulting BufferedImage and get the DataBuffer from it.
[/quote]
I’m familiar with this technique- using it atm- but my game may involve loading a lot of images in a short timeframe, so I’d like to cut down on overhead as much as possible. Plus, I’m feeding the image data as textures directly to JOGL, so Image objects themselves are redundant.

[quote]http://schmidt.devlib.org/java/pixel-image-io-libraries.html
[/quote]
I’d seen the list before, but on second inspection the FM Software GifDecoder seems promising… sadly, the JPEG baseline decoder and encoder isn’t accessible atm. I may be able to adapt the DevIL source to my requirements in any case. Thanks again.