Question

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?
Was it helpful?

Solution

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.

OTHER TIPS

MagickWand is the C API for ImageMagick:

http://imagemagick.org/script/magick-wand.php

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

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++ http://www.imagemagick.org/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.

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: http://code.google.com/p/kgui/source/browse/trunk/kguiimage.cpp

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top