tags:

views:

94

answers:

3

I would expect that there's some sort of library that I can use in this fashion:

int* buffer[720*480]; // read in from file/memory/network stream
raw_params params;
params.depth = 16;
params.width = 720;
params.height = 480;
params.map = "rgb";
params.interleave = JPEG_RAW_INTERLEAVE_OFF;

jpeg_encode(buffer, params)

But I can't seem to find it.

Clarification

I'm looking for a simple example of how to use such a library as well. Code as robust as the source of netpbm and magick are too complex for my level of understanding.

+1  A: 

Yes, there is a library for this (luckily!): http://freshmeat.net/projects/libjpeg/ equal (?) to http://sourceforge.net/projects/libjpeg/

Daevius
CoolAJ86
You did look at it perhaps, but you didn't mention you did. Neither did you specify you level of understanding. And neither did you ask for a manual past the 60's. If you are not clear in your questions, how can the answers be to your liking?Some quick googling gives me: http://andrewewhite.net/wordpress/2008/09/02/very-simple-jpeg-writer-in-c-cExample: http://www.codeguru.com/forum/showthread.php?t=467833But most useful of all: http://stackoverflow.com/questions/637043/using-jpeglib-for-jpeg-compressed-byte-stream
Daevius
The copy at sourceforge is out of date. See www.ijg.org for the latest and greatest. That said, libjpeg is the only sensible approach unless you have an unbounded budget and need hard real-time performance at better than standard video rates.
RBerteig
Sorry for the initial frustrated response. I'd been googling for a while to find a simple answer. Most of what I found are like the link that you mention in your comment - which is the OPPOSITE of what I want, and not very easy to understand.
CoolAJ86
+2  A: 

The libjpeg library from the Independent JPEG Group is the reference implementation of the JPEG standard, written by folks who were and are involved in the creation of the standard. It is robust, stable, and highly portable.

It comes as a source kit, which includes extensive documentation and samples.

Its preferred representation for a source image is as an array pointers to of arrays of pixels, not as a single monolithic array as you show. You can easily create the array of pointers to rows to address your image buffer, however.

It is highly configurable and extensible. Specifically, it allows both the data source and the destination to be configured through call backs. This adds some complexity to a first use, but it isn't all that hard to deal with.

There are certainly commercial libraries available as well, and I know that there is commercially available IP for implementation of JPEG in hardware. A commercial library is likely to be faster, but will never be cheaper.

RBerteig
+1  A: 

Here's a fairly simple example that's copied in a number of places on the web:

And this particular page of the documentation is relevant to understanding the require structs:

CoolAJ86