I had a read of the JFIF specs. The main thing it offers you over vanilla
JPEG is the X and Y resolution information, which gives you some idea of what
scale to view the image at. It is true, though, that the QuickTime JPEG
compressor reads and writes a standard JPEG data stream (well, it would have
to, wouldn't it?). Thus it's very easy to read and write JPEG files on a
QuickTime-equipped Mac.
Things get a little harder, though, if the image is too big to fit in memory
all at once. Then you have to figure out how to use data loading and unloading
routines with the Image Compression Manager...
Here's one useful piece of information about the JPEG data stream, for those
(like me) who have never seen a copy of the JPEG spec: if you want to determine
the size of the image, look for a hex FF byte followed by a hex C0 byte. Skip
the next three bytes, and you will find a 2-byte integer containing the number
of lines, followed by a 2-byte integer containing the number of columns. Both
are in big-endian format (ie on a Mac, you don't have to worry about it).
Thanks to Dolf Starreveld at Storm Technology for telling me this, along with
several other interesting things, a long time ago...
Lawrence D'Oliveiro fone: +64-7-856-2889
Computer Services Dept fax: +64-7-838-4066
University of Waikato electric mail: l...@waikato.ac.nz
Hamilton, New Zealand 37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
Ask not for whom the phone rings; it rings for you.
mac...@engin.umich.edu (Mike Neil) says:
> the data portion that is returned from a
> CompressImage call is in the JFIF format (Someone give the QT guys another
> cookie). So basically you can read a JFIF file into memory pass it into
> the DecompressImage call (You will need to make a Info block by hand).
> and you will get a decompressed image out. Very Cool.
I don't recall offhand whether QT makes a true JFIF file (complete with JFIF
marker) or just a "raw JPEG" file. Either way, though, the information is
compatible with non-Mac JFIF/JPEG programs. The JFIF marker is considered
optional by most non-Mac decoders; it really just certifies that the file
adheres to the JFIF conventions about colorspace.
> Couldn't find any mention of this in the QT docs so my guess is
> it is an unsupported feature.
I think it's reasonably safe to rely on it --- Apple's chief JPEG engineer
has spent a good deal of time making sure QT is compatible with JFIF-based
decoders :-)
And l...@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) writes:
> Here's one useful piece of information about the JPEG data stream, for those
> (like me) who have never seen a copy of the JPEG spec: if you want to
> determine the size of the image, look for a hex FF byte followed by a hex C0
> byte. Skip the next three bytes, and you will find a 2-byte integer
> containing the number of lines, followed by a 2-byte integer containing the
> number of columns.
Bzzt. Sorry, but that method is guaranteed to break sooner or later. If
you want reliable info, you have to parse the JPEG marker sequence, at least
well enough to skip over the arbitrary data that may be inside marker bodies
preceding the SOF marker.
If you don't want to buy a copy of the JPEG standard, at least go read the
free JPEG code available from ftp.uu.net: graphics/jpeg/ ... in particular,
jrdjfif.c will show you how to do this right. It only takes a few more
lines of code.
regards, tom lane
> mac...@engin.umich.edu (Mike Neil) says:
> > the data portion that is returned from a
> > CompressImage call is in the JFIF format (Someone give the QT guys another
> > cookie). So basically you can read a JFIF file into memory pass it into
> > the DecompressImage call (You will need to make a Info block by hand).
> > and you will get a decompressed image out. Very Cool.
> I don't recall offhand whether QT makes a true JFIF file (complete with JFIF
> marker) or just a "raw JPEG" file. Either way, though, the information is
> compatible with non-Mac JFIF/JPEG programs. The JFIF marker is considered
> optional by most non-Mac decoders; it really just certifies that the file
> adheres to the JFIF conventions about colorspace.
Actually, QT *does* include the JFIF marker and in fact produces a
perfectly acceptable JFIF output, not simply a JFIF-compatible output.
Aaron Giles
a-g...@uchicago.edu