JPEG/JFIF Datatype Handler - (c) Simon Clarke 1996-7
====================================================

Here is another datatype to make your datatype programs much more useful!
As the title suggests this handler will decode JPEG/JFIF files for you, 
through any datatype compatible program and display them at a maximum
of 24 bits depth.

This software is based in part on the work of the Independent JPEG Group,
and I am very grateful to Thomas Lane and associates for making the JPEG
format a lot less confusing.

History
=======

1.00 - 	Inital Release

1.01 - 	Removed DATAMakeView() code, now only outputs 32-bit data (previously
       	the datatype rendered to the depth of active workspace) thanks to
       	Jeremy Moskovish.  Compiled with CodeWarrior 1.1

1.50 - 	Added DATABitmap -> JPEG saver method.  This accepts either 8-bit or 
	   	32-bit data. Recompiled with CodeWarrior for Be 1.1.1
	   	Implemented a preference view (see below).  The JPEGHandler can now be
	   	run like an application to allow you to edit the settings.

1.60 - 	Implemented standard ioExtensions, header only and data only. Added
		scale preference to view to reduce output JPEG size.  Implemented
		Datatypes 1.4.1 color space ioExtension, N.B. The 8-bit output will be
		FS dithered!  Added scale and grayscale ioExtension, see below.
		The JPEG datatype will now return a B_GRAYSCALE_8_BIT bitmap if the
		file is in grayscale format, previously it would crash - Thanks to Olaf
		Seibert for the bug report.
		
1.70 - 	The JPEGHandler now multithreads image decoding to achieve some small
		speedups. It automatically works out how many threads to launch based
		on image size.
		
1.80 - 	Added support for progressive decoding of images.  
		Also added creation preference for progressive JPEG files.  If you want
		to support the displaying of progressive images in your program, you
		will need to use a custom datastream that is capable of receiving and 
		processing MEDIA streams.  
		Removed multithreading - serious problems with thread safeness of
		library and considering the small speedup only enjoyed with large
		images on MP machines, you will be able to live without it.  This
		stops the problems with random corruption appearing on the screen.
		Added preference option for input DCT method.  See below for more
		information.
		
1.90 - 	DR9 AA version.  Changed preference view around a bit.  Has better
		error handling and decoding quicker.  Additional type checking
		in Identify() function.
		
1.91 -	DR9 Preview version.  Set alpha channel value to 255 for 32-bit
		bitmaps.
	   
Preference View
===============
New for version 1.5 is a preferences view, within this view you can change
the compression quality of encoding JPEGs.  As an note to programmers, you
can fully resize the view as required.

Input Scale is a global setting to decide if loaded jpegs are scaled at all
It is best to leave this setting at the default level.  However, it can be
useful to have smaller images coming into your favourite viewing program.

Input DCT has settings which really speak for themselves, you can set which
code the handler will use to decode the image, the default is slow and 
accurate - crank it up if you are a speed freak!  

Output Type lets you set how the image will be encoded.  Progressive
encoding takes longer, but allows the image to be decoded in a progressive
manner (you can make out more of the image as the data is read - perfect
for using over a slower network).  Standard image encoding is quicker but
will not allow the same effect.  Its also worth noting that progressive
jpegs can often be several kilobytes smaller, but will use a LOT more
memory when they are being created.

Programmers - Custom ioExtensions
=================================
All ioExtensions start with the code JPEG before the defined action.
They are listed below.

"JPEG/scale":int32			With this set, the application can
							override the user preference and have the
							input image scaled down by either a factor
							of 2, 4 or 8.  Simply set the long to the 
							value you require - currently 2,4 and 8 are
							the only extra scaling supported, very useful
							for generating thumbnail images.

"JPEG/outgrayscale":bool	When this is set, the output image will be
							return as a B_GRAYSCALE_8_BIT, resulting in
							a much quicker decode - great for previews.
							
"JPEG/createprog":bool		This is will override the user's setting of
							saving images in progressive format or not.
							
Some Examples of usage

BMessage *ioMessage = new BMessage('IOMS');
ioMessage->AddInt32("JPEG/scale",4); // render as quarter of original size
color_space outspace = B_COLOR_8_BIT;
ioMessage->AddData("bits/space",B_RGB_COLOR_TYPE,&outspace,sizeof(color_space));
// request 8 bit data output
ioMessage->AddBool("JPEG/createprog",FALSE); // request non progressive save image

N.B. ALWAYS try and pass the JPEGHandler 32-bit data to convert to a JPEG
if its at all possible, since when you pass the Handler 8-bit data all it
is doing is expanding it to 32-bit data using the colour map.

Finally, please remember, there are two ways to check if a datatype supports
progressive image decoding through the MEDIAStream format, firstly check
through its output formats to find DATA_MEDIA or call DATATranslate() with
an outtype of DATA_MEDIA, and be prepared for it to fail.  You then try and
translate it with DATA_BITMAP.

Special Thanks To
=================
Jon Watte, Jeremy Moskovish, Philippe Thomas, Olaf Seibert, Kevin Hendrickson,
Chris Herborth and Edmund Vermeulen.

License
=======
There is no warranty with this program, and no liability for any consequential
damages caused arising out of the use or inability to use this program.  In no
event shall I be liable for any damages whatsoever.
Distribution is strictly forbidden on any kind of media containing commerical
software without a license agreement.  Distribution is also forbidden on any
software collections costing over 50USD.

Contact
=======
Simon Clarke (S.J.Clarke@herts.ac.uk)
If you want to include this with a commerical program, please email me.
