Decode JPEG to obtain uncompressed data

+3 votes
asked Jun 17, 2009 by ronny-brendel

I want to decode JPEG files and obtain uncompressed decoded output in BMP/RGB format.I am using GNU/Linux, and C/C++.

I had a look at libjpeg, but there seemed not to be any good documentation available. So my questions are:

  1. Where is documentation on libjpeg?
  2. Can you suggest other C-based jpeg-decompression libraries?

5 Answers

+2 votes
answered Jun 17, 2009 by balpha

MagickWand is the C API for ImageMagick:

I have not used it, but the documentation looks quite extensive.

+2 votes
answered Jun 17, 2009 by ben-hughes

You should check out Qt's QImage. It has a pretty easy interface that makes this task really easy. Setup is pretty simple for every platform.

If Qt is overkill, you can try Magick++ It supports similar operations and is also well suited for that sort of task. The last time I used it, I struggled a bit with dependencies for it on Windows, but don't recall much trouble on Linux.

For Magick++'s Image class, the function you probably want is getConstPixels.

+6 votes
answered Jun 17, 2009 by nils-pipenbrinck

The documentation for libjpeg comes with the source-code. Since you haven't found it yet:

Download the source-code archive and open the file libjpeg.doc. It's a plain ASCII file, not a word document, so better open it in notepad or another ASCII editor.

There are some other .doc files as well. Most of them aren't that interesting though.

Unfortunately I cannot recommend any other library besides libjpeg. I tried a couple of alternatives, but Libjpeg always won. Is pretty easy to work with once you have the basics done. Also it's the most complete and most stable jpeg library out there.

+1 vote
answered Jun 17, 2009 by kpexea

I have code that you can copy ( or just use as a reference ) for loading a jpeg image using the libjpeg library.

You can browse the code here:

Just look for the function LoadJPGImage.

The code is setup to handle c++ binding of my DataHandle class to it for loading the image, that way the image can be a file or data already in memory or whatever.

+1 vote
answered Jun 17, 2009 by rberteig

A slightly out of the box solution is to acquire a copy of the netpbm tools, which transform images from pretty much any format to any other format via one of several very simple intermediate formats. They work well from the shell, and are most often used in pipes to read some arbitrary image, perform an operation on it, and write it out to some other format.

The pbm formats can be as simple as a plain ASCII header followed by the RGB data in ASCII or binary. They are intended to be simple enough to use without required a library to implement.

JPEG is supported in netpbm by read and write filters that are implemented on top of libjpeg.

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter