Pure Java jpeg decoder wanted

I need a pure Java JPEG decoder that decodes from raw bytes into raw bytes. Must have a free license to redistribute.

Anyone know where I can get one?

Cas :slight_smile:

http://www.geocities.com/marcoschmidt.geo/java-image-coding.html

has always served me well in the past…

Kev

Thanks Kev. It looks like I’m going to have to either port libjpeg or write a Java wrapper for it.

I think a wrapper will be easiest for now…

Cas :slight_smile:

I have to ask…

Why do you need this to be pure Java?
And why can’t you use the JPEG support that is built-in?
(either AWT or ImageIO, raw bytes to raw bytes should be possible)

As I’m sure you know, doing that sort of stuff with pure java will be quite slow. You really want SIMD-based native code, as it is perfect for this sort of thing.

I suspect he’s avoiding AWT.

ImageIO returns java.awt.image.BufferedImage doesn’t it?

Kev

Ah yes of course… I keep forgetting about JET. Me, I rather would not fight against what Java wants to be and work with it. Install a JRE, be happy :slight_smile: But for consoles, phones, etc. you need something. Is pulling in BufferedImage all that is needed to bloat the JET exe?

I guess no JNI is also because he wants to target phones/consoles etc. and the porting effort of a JPEG library is just too much.

That’s exactly right. It’s one of Java’s real strengths. If it’s native code I’ve got to get it compiled on various different platforms and that’s a bugger.

It’s really annoying that ImageIO is linked to AWT and that linking to just about anything in AWT drags in approximately 2MB of rubbish I don’t want.

Cas :slight_smile:

What about ripping out the JPEG File loader that’s in SWT? It is pure Java. Moreover, you’ll be able to rip it without dragging a huge chunk of SWT into your code.
I think all you’ll need are org.eclipse.swt.internal.image.JPEG* classes, and additionally, probably org.eclipse.swt.graphics.ImageData/org.eclipse.swt.graphics.PaletteData.

But you’ll have to check the CPL license whether it permits doing such stuff.

HOWEVER, someone complained that the JPEG loader in SWT is a bit slow, mind you.

I’ll have a look at it. I think the SWT license will permit me to bastardise their code providing I chip in a mention and keep it open sourced, which I will on both counts if I use it.

I bet it’s not really that slow.

Cas :slight_smile:

I’ve read the Common Public License attached to it and it seems I’ve got the green light. I plan to hack out all the image writing code and optimise it to buggery to use direct byte buffers suitable for piping directly into OpenGL. I’ll let you know when it’s done, and it’ll be in the SPGL.

Cas :slight_smile: