Morris Dovey said:
If you already have the data in your C program, all you need to do is use
fopen() to open the file, fwrite() to move the data into the file, and
fclose() to finish.
Much easier than you were expecting, yes?
if you have a valid jpeg bitstream in the buffer, but if it is actual
graphical data (say, an image rendered into a buffer), then a little more is
needed than this.
as noted by others, IJG's libjpeg is a common option for loading/saving jpeg
files.
at least a few of us here have written custom load/save code as well (the
advantage of going this route is that one can do a single-file
implementation of the thing and avoid the dependency/liscense/bulk/...
issues involved with using a 3rd party library).
of course, be warned that writing code to encode/decode a jpeg bitstream
isn't exactly a newbie friendly task (at least a few of us are probably also
likely to make such code available on request as well).
my particular case:
I can send my version if asked via email.
I have been using it fairly effectively for both encoding and decoding for a
few years now.
it also has a faster encoder (lower quality/conpression tradeoff), which was
tweaked mostly for the task of encoding images to be used in MJPEG videos
(basically, when I was trying to minimize the performance impact when doing
real-time video recording/encoding in my apps, albeit glReadPixels is the
main bottleneck IME).
or such...