Copyright: Copyright MWA Software 1998


Shareware Licence Agreement
Shareware Licence

LICENCE AGREEMENT

© 1997 McCallum Whyman Associates Limited trading as MWA Software

The copyright in the shareware version of this software ("the Software") is owned by McCallum Whyman Associates Limited trading as MWA Software ("the Owner").  You may not load the Software into any computer or copy it without the licence of the Owner.  The Owner offers you a non-exclusive licence on the terms of this Agreement.

Licence

You are permitted during the Term to:

(1)	load the Software and use it only on a single computer (with a single input terminal) which is under your control;

(2)	transfer the Software from one computer to another provided it is used on only one computer at a time;

(3)	make copies of the Software.  The copies must reproduce and include the Owner's copyright notice;

(4)	transfer a copy of the Software (complete with all its associated documentation and this licence) to another person provided that the Software is not modified in any way and includes all files as originally supplied and that no charge is made for the transfer.  If any transferee does not accept such terms then this licence shall automatically terminate.  The transferor does not retain any rights under this Agreement in respect of the transferred Software or licence.

You are not permitted:

(a)	to rent, lease, sub-licence, loan, copy (except as expressly provided in this Agreement), modify, adapt, merge, translate, reverse engineer, decompile, disassemble or create derivative works based on the whole or any part of the Software or its associated documentation;

(b)	except as expressly provided in this Agreement, to use, reproduce or deal in the Software in any way.

Acceptance

You shall be deemed to have accepted the terms of this Agreement by loading the Software into any computer.

Term

Subject as set out below this licence is effective for a period of 30 days from the date of first use by you.   This Licence will terminate if you fail to abide by its terms.  Upon termination you agree to destroy all copies of the Software and its documentation including any Software stored on the hard disk of any computer under your control.

Registration

If you wish to licence the Software beyond the period of 30 days aforesaid then please return the enclosed Licence Registration Form to the Owner within such period.

Ownership

The Owner shall at all times retain ownership of the Software as recorded in the original file set or diskette and all subsequent copies thereof regardless of form.  If the Software was supplied on diskette, you own only the diskette on which the Software is recorded.  You may retain the diskette on termination provided the Software has been erased.  This Agreement applies to the grant of the licence only and not to the contract of sale of the diskette.

Warranties

(1)	The express terms of this Agreement are in lieu of all warranties, conditions, undertakings, terms and obligations implied by statute, common law, trade usage, course of dealing or otherwise all of which are hereby excluded to the fullest extent permitted by law.

(2)	The Owner does not warrant that the Software will meet your requirements or that the operation of the Software will be uninterrupted or error-free or that defects in the Software will be corrected.  You shall load and use the Software at your own risk and in no event will the Owner be liable to you for any loss or damage of any kind (except personal injury or death resulting from the Owner's negligence) including lost profits or consequential loss arising from your use of or inability to use the Software or from errors or deficiencies in it whether caused by negligence or otherwise.

(3)	Any liability of the Owner pursuant to this licence shall be limited to the purchase price or registration fee paid.

Law

This Agreement shall be governed by English law.

If you have any questions concerning this Agreement please write to McCallum Whyman Associates Limited trading as MWA Software at PO Box 37, Alresford, Hampshire, SO24 9ZF, England.


PRICING INFORMATION

JPEG Component Library Source Licence	12 pounds sterling (US$20)

US dollar prices are for indicative pricing only and assume an exchange rate of one pound = $1.66.  All prices are VAT exclusive. UK VAT (currently 17.5%) will be

charged for all UK residents and EC residents that are not VAT registered or do provide a VAT number as proof of registration.

How To Register


HOW TO REGISTER

See Also - Secure Registration

Registration may be made by FAX, Letter Post or EMail. For FAX and Letter Post registrations, a Registration Form is provided in the File "regform.txt" for you to EMail or print out (FAX or letter post), complete, and send to MWA Software. You may also register via Compuserve's Shareware Registration facility (GO SWREG) - Registration ID 15235. The software is registered under the name "MWA JPEG Component Library".

Visa, Mastercard, Eurocard and JCB are accepted as payment mechanisms. International money orders in pounds sterling and cheques drawn on UK Bank Accounts are also accepted. US Dollar denominated checks are also acceptable provided that an additional 10% is added to the purchase price to allow for the additional Bank Charge. Please make cheques payable to McCallum Whyman Associates Ltd.

EMail registrations should be sent to:   Internet:	sales@mwassocs.demon.co.uk, or   Compuserve:	100041,315

FAX:   UK: 01962 735581   Int: +44 1962 735581

MWA Software, P.O.Box 37, Alresford, Hants, SO24 9ZF, ENGLAND

All registrations are accepted on the basis that the registered user will be deemed to have accepted and be bound by the licence conditions for the registered versions of JPEG component library as recorded in the file reg-lnce.txt supplied with the evaluation version of the software.


Secure Registration by EMail

There are two routes by which you can EMail your credit card details to MWA Software without incurring the risk of sending a credit card number in clear across the Internet. One route is to use the encryption mechanism provided by pkzip. The other is to use PGP.

pkzip encryption will generally be good enough to avoid detection by the so called "sniffer" programs that are understood to monitor EMail communications, looking for numbers that look like credit cards. However, it is not believe to be good enough to resist a determined attack by someone who has access to the necessary skills in cryptography and a powerful enough computer. On the other hand PGP is understood to offer a very strong level of protection. MWA Software makes no recommendations as to which is the better approach. It is for you to decide based on your own location and concerns.


Secure Transmission using pkzip.

pkzip can encrypt files in a .zip archive using a simple password. To register for the JPEG Component Library by EMail when using pkzip as your encryption engine:

1.	Using the file "regform.txt" as a template, complete a registration form for the JPEG Component Library. Remember to include your credit card details, billing address and your name as it appears on your credit card.

2.	Choose a password. Opening a dictionary at some random page is often a good way to do this. For example, let's assume that you choose NERVOUS as your password.

3.	Compress and encrypt the modified regform.txt using pkzip and the -s option to encrypt. For example, with NERVOUS as your password, use the command line:

pkzip -sNERVOUS regform regform.txt

This will create regform.zip containing your compressed and encryted registration details.

4.	EMail regform.zip to MWA Software. Your own EMail utility will usually have a way to send binary attachments to an EMail message. If you do not have such a capability then you can use the J-Write Text Editor (also available from MWA Software) to uuencode a binary file into a text form suitable for attaching to an EMAil message. This feature is available from the File|Merge menu item. The MWA Software EMail address is sales@mwassocs.demon.co.uk. Set the subject to "JPEG Registration"

5.	Send the password you choose at step 2 in a separate EMail to MWA Software. For best protection, use our Compuserve EMail address:

6.	100041.315@compuserve.com

Set the subject to "re: JPEG Registration"


Secure Transmission using PGP

PGP is a powerful data encryption tool that has been made publicly available by its author "Phillip Zimmermann". It is sufficiently good to attract the attentions of various governments' agencies and you should be aware that in certain countries the use of such encryption software is a criminal offence. MWA Software only uses PGP to decrypt registrations and does not send encrypted EMail. Having said that, the international version of PGP can be obtained from:

http://www.ifi.uio.no/pgp/

The following URL is also a good source of information about PGP, including information on how to get the more limited US version.

http://www.arc.unm.edu/~drosoff/pgp/pgp.html

To encrypt a registration using PGP, do the following:

1.	Using the file "regform.txt" as a template, complete a registration form for the JPEG Component Library. Remember to include your credit card details, billing address and your name as it appears on your credit card.

2.	Encrypt regform.txt using PGP and the MWA public key. This is provided in the file "mwakey.asc", which should be in the same archive as this file. This will typically be performed by the following commands (the ; indicates the start of a comment):

pgp -ka mwakey.asc	;add MWA key to your public keyring
pgp -ea regform.txt "MWA Software"	;encrypt and encode for EMail
pgp -kr "MWA Software"	;remove the MWA key from your keyring
The above will have created the encrypted file "regform.pgp". This is a text file and may be sent as part of a normal EMail to MWA Software:

sales@mwassocs.demon.co.uk

Set the subject to "JPEG Registration"

If you have any reason to doubt the validity of the MWA key, request an up-to-date version by EMail to the above address, with a subject of "Key Verification Request".

Thank you for registering for the JPEG Component Library.


ABOUT THE COMPONENT LIBRARY

The JPEG Component Library provides two additional non-visual components for use under either Delphi 1.0, 2.0, 3.0 and C++Builder 1 and 3. It also provides a Data Aware JPEG Image component which may be used to save and access JPEG encoded images in a database blob field. A corresponding printable component is also provided so that you may print images from a database using Quick Reports.

The two non-visual components are TJPEGFileCompressor and TJPEGFileDecompressor. These support compression of images to JPEG Format and decompression respectively. The data aware component isTDBJPEGImage, and the printable component isTQRDBJPEGImage.

Simply installing these components JPEG enables the Delphi IDE. The components register themselves as supporting .jpg files and the JPEG compression format and, when you come to load an image into a TImage Picture, the JPEG format will be found amongst the list of supported file formats. An image loaded from a JPEG source can also be saved back to JPEG. These components support the JPEG File Interchange Format (JFIF).

These two components also support TImage at run-time too. As at design time, if TJPEGFileDecompressor is included in your project, then calling TImage.Picture.LoadFromFile when the file extension is .jpg will automatically invoke the JPEG decompressor. You can also explicitly call TJPEGFileDecompressor to load a JPEG image from any file.

TJPEGFileCompressor can be used to save a TImage.Picture in JPEG format, and can handle pictures that are either bitmaps or metafiles. It can also compress a device independent bitmap, and change the size of bitmaps before compression.

TDBJPEGImage is linked to a database blob field and also uses TJPEGFileDecompressor and TJPEGFileCompressor to save and load JPEG encoded images from the Blob Field. Use of the JPEG compressor and decompressor components can be implicit if the default parameter settings are sufficient. On the other hand, the reference may be explicit to copies of these components with non-default parameter settings. TQRDBJPEGImage can be used to print a JPEG Image using Quick Reports 2.

This software uses original software for JPEG developed by the Independent JPEG Group (see ftp://ftp.uu.net/graphics/jpeg). The IDG have made available a library of generic 'C' code supporting JPEG compression and decompression and have permitted its free use provided the source is acknowledged. The IDG code has been modified for use with Delphi and MS Windows and is provided as compiled object files. Optionally, they may be separately compiled into a dll.

An interface to this software is provided by the unit jpeglib.pas. This is encapsulated as a set of Delphi components in the unit mwajpeg.pas, which also supports the mapping of the environment independent image format expected by the IJG code into MS Windows bitmap and metafile formats.

When you purchase a licence to this product, you purchase a licence for the source code to the mwajpeg and jpeglib units and the right to include binaries derived from them in your own products without having to pay additional royalties. You also have a right to freely distribute the mwjpeg and mwjpeg32 dlls (if used), and copies of the modified 'C' source is also included in the registered version. Support is also provided by EMail albeit without a guaranteed response time.


Units

The MWA JPEG Component Library consists of five units:

MWAJPEG	This unit encapsulates the JPEG Compression/Decompression library and defines the two main Delphi Components exported by the library.
JPEGLIB	This is the interface unit to the JPEG Compression/Decompression library
JPEGREG1/ JPEGREG2	This unit contains the Register procedure used to install the components. It may be modified in order to change the palette on which the components are installed. By default, this is the “Additional” palette. JPEGREG1 is used with Quick Reports 1 (and when Quck Reports is not installed) and JPEGREG2 with Quick Report 2.
MWADBJPG	This unit defines the TDBJPEGImage control.
MWAQRJPG	This unit defines the TQRDBJPEGImage control.


USING THE JPEG DEMO APPLICATION
USING THE JPEG DEMO APPLICATIONS

Two demo applications are provided. A JPEG Viewer application demonstrates the opening and saving JPEG image files and conversion to and from bitmap files (.bmp) and from Windows Metafiles (.wmf). A database application demonstrates use of the data aware component.

The JPEG Viewer application may be found in the Examples\Viewer subdirectory created above (note that for Delphi 2 and C++Builder 1) there are two versions for Quick Reports 1 and 2, in the Q1 and Q2 subdirectories respectively). To activate, load the jpegdemo.dpr file into the IDE using the File|Open Project menu item. This provides a simple application that can open and save .jpg (JPEG), .bmp (Windows Bitmap) and .wmf (Windows metfaile) files, and copy and paste bitmaps and metafiles to and from the clipboard. To test out, simply compile and run the application.

To load and view a JPEG file, click on the open button and load the test.jpg file contained in the subdirectory created above. You can also try saving it to another file name (you can save it as either a JPEG or a bitmap). You can also use the demo application to convert windows bitmaps and metafiles to jpegs simply by opening the file containing them (or pasting from the clipboard) and saving them as jpegs. The viewer window can also be resized by simply dragging the bottom right hand corner with the mouse. Saving the image will save it at the new size.

The application also demonstrates a simple method for printing a JPEG Image using Quick Reports (even with no database).

You can also use the Object Inspector to see the properties published by the two JPEG components.

The JPEG database application may also be found in the Examples\db subdirectory created above. To activate, load the DBDemo.dpr file into the IDE using the File|Open Project menu item. This application is an extension of the Viewer and presents images held in an example database. The database records may be perused using the DBNavigator bar provided. It is still possible to save images from the database record and to replace/insert images from files or the clipboard. For Delphi 2 and C+++Builder 1, there are again two version of the application for Quick Reports 1 and 2. The application also demonstrates how to print a report including JPEG Images.


Classes

The JPEG Component Library defines the following classes:

TJPEGFileCompressor

TJPEGFileDecompressor

TDBJPEGImage

TQRDBJPEGImage


TJPEGFileCompressorProperties
Properties

Comment	DCTMethod	DensityUnit
GrayscaleOutput	OptimizeCoding	ProgressiveJPEG
Quality	RestartInterval	SmoothingFactor
Trace_Level	WriteAllTables	WriteJFIFHeader


TJPEGFileCompressorMethods
Methods

SavePictureToFile	SavePictureToStream
SaveDIBitmapToStream	SaveMetaFileToStream
SaveBitMapToStream	Abort
WriteMarker	SaveStretchedPictureToStream
SaveBitmapToFile	SaveStretchedPictureToFile
SaveMetafileToFile	SaveStretchedBitmapToFile


TJPEGFileCompressorEvents
Events

OnProgessReport	OnWriteMarkers


TJPEGFileCompressor Class

Properties	Methods	Events	Classes
Unit:	MWAJPEG

TJPEGFileCompressor can be used to save a TImage.Picture in JPEG format, and can handle pictures that are either bitmaps or metafiles. It can also compress a device independent bitmap.


TJPEGFileDecompressorProperties
Properties

DCTMethod	DitherMode	DoBlockSmoothing
DoFancyUpSampling	GrayScaleOutput	TwoPassQuantize
TraceLevel


TJPEGFileDecompressorMethods
Methods

Abort	LoadPictureFromResID
ConvertToDIB	LoadPictureFromStream
LoadPictureFromFile	ReadDIBitmapFromStream
LoadPictureFromResource	ReadBitMapFromStream


TJPEGFileDecompressorEvents
Events

OnJPEGComment	OnJPEGMarker	OnProgessReport


TJPEGFileDecompressor Class

Properties	Methods	Events	Classes
Unit:	MWAJPEG

If TJPEGFileDecompressor is included in your project, then calling TImage.Picture.LoadFromFile when the file extension is .jpg will automatically invoke the JPEG decompressor. You can also explicitly call TJPEGFileDecompressor to load a JPEG image from any file.


TDBJPEGImage
TDBJPEGImage Class

Properties	Methods	Classes
The TDBJPEGImage control displays a graphic image stored in JPEG format from a BLOB (binary large object) field of the current record of a dataset.

Unit: mwadbjpg

Description

Use TDBJPEGImage to represent the value of JPEG graphic fields. TDBJPEGImage allows a form to display graphical data from a dataset. TDBJPEGImage can allow the user to edit graphical data using the clipboard. While the application is running and the database image control has focus, users can cut, copy, and paste using the standard windows accelerator keys (Ctrl+X, Ctrl+C, and Ctrl+V). Users can return to the original state of the database image control by pressing Esc before moving to another record.


Properties

AutoDisplay	DataSource	JPEGCompressor
DataField	ReadOnly	JPEGDecompressor
Field


Methods

CopyToClipboard	CutToClipboard
PasteFromClipboard	LoadPicture


TQRDBJPEGImage

TQRDBJPEGImage is used to print images in JPEG format stored in binary (BLOB) fields on a Quick Reports 2 form. It is not used with Quick Reports 1. By default, Quick Reports 2 only comes with Delphi 3 and C++Builder 3. Delphi 2 and C++Builder 1 come with Quick Reports 1 and you will only have Quick Reports 2 with these products (and Delphi 1) if you are registered for the Professional Edition.

Like any Quick Reports Printable control, a TQRDBJPEGImage is placed on a report band to print a JPEG image held in a database field. The DataSet property is set to the dataset containing the image and the DataField property is set to the name of the field holding the JPEG Image.

If non-default decompression parameters are required, then the JPEGDecompressor should point to a TJPEGFileDecompressor object with the required parameter settings.

Note: for printing JPEG Images using Quick Reports 1, you should use the TDBJPEGImage control instead of TQRDBJPEGImage.


Comment Property
System::AnsiString Comment

Class: TJPEGFileCompressor

This comment is included in the compressed JPEG image. A typical use is to include a copyright message.


DCTMethod Property
Jpeglib::J_DCT_METHOD DCTMethod

Classes: TJPEGFileDecompressor and  TJPEGFileCompressor

Selects the algorithm used for the DCT quantisation step.  Choices are:

JDCT_ISLOW:	slow but accurate integer algorithm
JDCT_IFAST:	faster, less accurate integer method
JDCT_FLOAT:	floating-point method.
The FLOAT method is very slightly more accurate than the ISLOW method, but may give different results on different machines due to varying roundoff behaviour.  The integer methods should give the same results on all machines.  On machines with sufficiently fast FP hardware, the floating-point method may also be the fastest.  The IFAST method is considerably less accurate than the other two; its use is not recommended if high quality is a concern.


DensityUnit Property
Byte DensityUnit; Word X_Density; Word Y_Density;

Class: TJPEGFileCompressor

The resolution information to be written into the JFIF marker; not used otherwise.  density_unit may be 0 for unknown, 1 for dots/inch, or 2 for dots/cm.  The default values are 0,1,1 indicating square pixels of unknown size.


GrayscaleOutput Property
bool GrayscaleOutput;

Classes: TJPEGFileDecompressor and  TJPEGFileCompressor

If true then the image is converted to a grayscale image.


OptimizeCoding Property
bool OptimizeCoding;

Class: TJPEGFileCompressor

TRUE causes the compressor to compute optimal Huffman coding tables for the image.  This requires an extra pass over the data and therefore costs a good deal of space and time.  The default is false, which tells the compressor to use the supplied or default Huffman tables.  In most cases optimal tables save only a few percent of file size compared to the default tables.


ProgressiveJPEG Property
bool ProgressiveJPEG;

Class: TJPEGFileCompressor

Progressive JPEG rearranges the stored data into a series of scans of increasing quality.  In situations where a JPEG file is transmitted across a slow communications link, a decoder can generate a low-quality image very quickly from the first scan, then gradually improve the displayed quality as more scans are received.  The final image after all scans are complete is identical to that of a regular (sequential) JPEG file of the same quality setting.  Progressive JPEG files are often slightly smaller than equivalent sequential JPEG files, but the possibility of incremental display is the main reason for using progressive JPEG.

When this property is set to true a progressive JPEG file is generated using a default scan script generated by the JPEG library.


Quality Property
int Quality;

Class: TJPEGFileCompressor

JPEG quantisation tables appropriate for the indicated quality setting are generated.  The quality value is expressed on a 0..100 scale.


RestartInterval Property
Cardinal RestartInterval; int RestartInRows;

Class: TJPEGFileCompressor

To emit restart markers in the JPEG file, set one of these nonzero. Set RestartInterval to specify the exact interval in MCU blocks. Set RestartInRows to specify the interval in MCU rows.  (If RestartInRows is not 0, then RestartInterval is set after the image width in MCUs is computed.)  Defaults are zero (no restarts).


SmoothingFactor Property
int SmoothingFactor;

Class: TJPEGFileCompressor

If non-zero, the input image is smoothed; the value should be 1 for minimal smoothing to 100 for maximum smoothing.  The default is zero.


Trace_Level Property
int Trace_Level;

Classes: TJPEGFileDecompressor and  TJPEGFileCompressor

Controls the level of trace information reported. (set >= 3 to see more than the first warning message).


WriteAllTables Property
bool WriteAllTables;

Class: TJPEGFileCompressor

Set to True (default) to ensure that a proper JPEG Interchange stream is written. If false, then the quantisation and Huffman tables are not written to the JPEG file. This makes for a smaller file but creates difficulties for the decompressor unless some other way is found to transfer these tables.


WriteJFIFHeader Property
bool WriteJFIFHeader;

Class: TJPEGFileCompressor

If true (default) then a JFIF APP0 marker is emitted. The decompressor will then recognise it as a JFIF compatible stream.


SavePictureToFile Property
void __fastcall SavePictureToFile(Graphics::TPicture* Picture, const System::AnsiString FileName);

Class: TJPEGFileCompressor

Provided that the Picture holds a Bitmap or a Metafile image, it will be compressed to a JPEG and written out to the file "FileName".


SavePictureToStream Property
void __fastcall SavePictureToStream(Graphics::TPicture* Picture, Classes::TStream* Stream);

Class: TJPEGFileCompressor

Provided that the Picture holds a Bitmap or a Metafile image, it will be compressed to a JPEG and written out to the provided stream.


SaveBitMapToStream Property
void __fastcall SaveBitMapToStream(Graphics::TBitmap* Bitmap, Classes::TStream* Stream);

Class: TJPEGFileCompressor

The bitmap is compressed to a JPEG and written out to the provided stream.


SaveDIBitmapToStream Property
void __fastcall SaveDIBitmapToStream(Classes::TStream* Stream, const tagBITMAPINFO &jpeg_, char *bits);

Class: TJPEGFileCompressor

The device independent bitmap held in the memory block given by "bits", is compressed to a JPEG and written out to the provided stream. Note that the BitmapInfo structure is defined by the Windows API and defines the size and resolution of the bitmap and may also contain a colour map.


SaveMetaFileToStream Property
void __fastcall SaveMetaFileToStream(Graphics::TMetafile* MetaFile, Classes::TStream* Stream, long width, long height);

Class: TJPEGFileCompressor

The metafile is compressed to a JPEG and written out to the provided stream. Note that the height and width of the required image (in pixels) must also be provided.


WriteMarker Property
void __fastcall WriteMarker(int marker, const void *buf, int Count);

Class: TJPEGFileCompressor

This method may be called from the event "OnWriteMarkers" to write out data with a JPEG APPn marker. The actual marker is identified by the Marker parameter (e.g. to write out an APP1 marker, set Marker to one). The value data written out is contained in buf and contains Count bytes.


OnProgessReport Property
Classes::TNotifyEvent OnProgessReport

Classes: TJPEGFileDecompressor and  TJPEGFileCompressor

Called regularly during compression/decompression to enable a progress report to be maintained. The PercentDone integer property (read only) may be consulted to find out the percentage so far processed.


OnWriteMarkers Property
Classes::TNotifyEvent OnWriteMarkers

Class: TJPEGFileCompressor

This event occurs when it is permissible to output application specific markers to the JPEG data stream. See discussion of WriteMarker Method for details on how to do this.


DitherMode Property
Jpeglib::J_DITHER_MODE DitherMode

Class: TJPEGFileDecompressor

Selects color dithering method.  Supported values are:

JDITHER_NONE	no dithering: fast, very low quality
JDITHER_ORDERED	ordered dither: moderate speed and quality
JDITHER_FS	Floyd-Steinberg dither: slow, high quality
Default is JDITHER_FS.  (At present, ordered dither is implemented only in the single-pass, standard-colormap case.  If you ask for ordered dither when two_pass_quantize is TRUE or when you supply an external color map, you'll get F-S dithering.)


DoBlockSmoothing Property
bool DoBlockSmoothing

Class: TJPEGFileDecompressor

If TRUE, interblock smoothing is applied in early stages of decoding progressive JPEG files; if FALSE, not.  Default is true.  Early progression stages look "fuzzy" with smoothing, "blocky" without.


DoFancyUpSampling Property
bool DoFancyUpSampling

Class: TJPEGFileDecompressor

If TRUE, do careful upsampling of chroma components.  If FALSE, a faster but sloppier method is used.  Default is true.  The visual impact of the sloppier method is often very small.


TwoPassQuantize Property
bool TwoPassQuantize

Class: TJPEGFileDecompressor

If TRUE, an extra pass over the image is made to select a custom colour map for the image.  This usually looks a lot better than the one-size-fits-all colourmap that is used otherwise.  Default is true.  Ignored when the application supplies its own colour map.


LoadPictureFromFile Property
void __fastcall LoadPictureFromFile(Graphics::TPicture* p0, const System::AnsiString p1);

Class: TJPEGFileDecompressor

Opens the file identified by FileName which is assumed to contain a JPEG image in the JFIF format. This is decoded into a windows bitmap and loaded into the supplied Picture object.


ConvertToDIB Property
void __fastcall ConvertToDIB(Classes::TStream* p0, Classes::TStream* p1, TJPEGOutputType p2);

Class: TJPEGFileDecompressor

Converts a JPEG compressed image Windows Device Independent bitmap contained in the Source stream to a Windows Device Independent bitmap written to the destination stream.

The format of the DIB is determined by the setting of OutputType.


TJPEGOutputType  Property
TJPEGOutputType =

(jp24bit,	{24 bit bitmap}
jp8bit,	{56 colour bitmap}
jp4bit,	{6 colour bitmap}
jpGrayscale);	{Gyscale}
Determines the bitmap resolution.


LoadPictureFromStream Property
void __fastcall LoadPictureFromStream(Graphics::TPicture* Picture, Classes::TStream* Stream);

Class: TJPEGFileDecompressor

The source stream is assumed to contain a JPEG image in the JFIF format. This is decoded into a windows bitmap and loaded into the supplied Picture object.


LoadPictureFromResource method
void __fastcall LoadPictureFromResource(Graphics::TPicture* Picture, int Instance, const System::AnsiString ResName);

Class: TJPEGFileDecompressor

This method is used to read a JPEG Image from a user defined resource bound into the program (identified by the ResName) and load it into the specified Picture. Although the same can be achieved by loading a JPEG into (e.g. a TImage) at design time, the image will then be saved (as a resource) and bound into the .exe as a much larger bitmap. Separately providing the JPEG image as a user defined resource and loading it at run-time can reduced significantly the size of the final .exe.

See also How to make a JPEG Image into a user defined resource.


LoadPictureFromResID Method
void __fastcall LoadPictureFromResID(Graphics::TPicture* Picture, int Instance, int ResID);

Class: TJPEGFileDecompressor

This method is used to read a JPEG Image from a user defined resource bound into the program (identified by the ResID) and load it into the specified Picture. Although the same can be achieved by loading a JPEG into (e.g. a TImage) at design time, the image will then be saved (as a resource) and bound into the .exe as a much larger bitmap. Separately providing the JPEG image as a user defined resource and loading it at run-time can reduced significantly the size of the final .exe.

See also How to make a JPEG Image into a user defined resource.


ReadBitMapFromStream Property
Graphics::TBitmap* __fastcall ReadBitMapFromStream(Classes::TStream* Stream);

Class: TJPEGFileDecompressor

The source stream is assumed to contain a JPEG image in the JFIF format. This is decoded into a windows bitmap and returned as a TBitmap object.


ReadDIBitmapFromStream Property
void __fastcall ReadDIBitmapFromStream(Classes::TStream* Stream, tagBITMAPINFO &jpeg_, TJPEGOutputType

OutputType, int & bits);

Class: TJPEGFileDecompressor

The source stream is assumed to contain a JPEG image in the JFIF format. This is decoded into a windows device independent bitmap and returned in the memory block given by bits. The output type is determined as above and the information describing the bitmap size, resolution and colour map is returned in the Windows APS BitMapInfo structure.


OnJPEGComment Property
TJPEGCommentEvent OnJPEGComment

 typedef void __fastcall (__closure *TJPEGCommentEvent)(TJPEGBase* sender, char * comment);

Class: TJPEGFileDecompressor

This event occurs when a comment is found in the JPEG compressed image. The comment is extracted and provided as a parameter to the event handler.


OnJPEGMarker Property
TJPEGMarkerEvent OnJPEGMarker

 typedef void __fastcall (__closure *TJPEGMarkerEvent)(TJPEGBase* sender, int Marker, bool &done);

Class: TJPEGFileDecompressor

This event occurs when any other JPEG marker is found in the JPEG image (except for APP1 the JFIF marker). The marker is identified by the Marker parameter (range 1..13), and the response method may read successive bytes from the stream after the marker by calling the GetByte method (this is a parameterless function that returns a single byte value). Note that marker processing is application specific.

If the marker is not processed, then the response method should return with Done set to false. The marker text will then be skipped, otherwise, Done should be set to true to indicate that the response method has handled the marker itself.


Abort
virtual void __fastcall Abort(void);

Classes: TJPEGFileDecompressor and  TJPEGFileCompressor

The Abort method may be called to abandon a compression or decompression operation. It must be called from the same thread as the compression or decompression operation. Practically, this limits its use to an event handler (e.g. OnProgressReport), when it may be used to abort the operation, perhaps in response to a user cancellation request.


procedure SaveStretchedPictureToStream
void __fastcall SaveStretchedPictureToStream(Graphics::TPicture* Picture, int width, int height, Classes::TStream* Stream);

Class: TJPEGFileCompressor

The provided Bitmap is stretched to the specified width and height, and then compressed to a JPEG and written out to the stream.

Note that the image processing is carried out at the current screen resolution. In order to get the best results, you should set your display adapter to the best resolution and colour depth supported by your display adapter/monitor.


SaveStretchedBitmapToFile
void __fastcall SaveStretchedBitmapToFile(Graphics::TBitmap* bitmap, int width, int height, const System::AnsiString FileName);

Class: TJPEGFileCompressor

The provided Bitmap is stretched to the specified width and height, and then compressed to a JPEG and written out to the file "FileName".

Note that the image processing is carried out at the current screen resolution. In order to get the best results, you should set your display adapter to the best resolution and colour depth supported by your display adapter/monitor.


SaveStretchedPictureToFile
procedure SaveStretchedPictureToFile(Picture: TPicture; width, height: integer; const FileName: string);

Class: TJPEGFileCompressor

Provided that the Picture holds a Bitmap or a Metafile image, it will be stretched to the specified width and height, and then compressed to a JPEG and written out to the file "FileName".

Note that the image processing is carried out at the current screen resolution. In order to get the best results, you should set your display adapter to the best resolution and colour depth supported by your display adapter/monitor.


SaveMetafileToFile
void __fastcall SaveMetafileToFile(Graphics::TMetafile* metafile, int width, int height, const System::AnsiString string);

Class: TJPEGFileCompressor

The metafile is compressed to a JPEG and written out to the file "FileName". Note that the height and width of the required image (in pixels) must also be provided.

Note that the image processing is carried out at the current screen resolution. In order to get the best results, you should set your display adapter to the best resolution and colour depth supported by your display adapter/monitor.


SaveBitmapToFile
void __fastcall SaveBitmapToFile(Graphics::TBitmap* bitmap, const System::AnsiString FileName);

Class: TJPEGFileCompressor

The provided Bitmap is compressed to a JPEG and written out to the file "FileName".


Resize
extern Graphics::TBitmap* __fastcall ReSizeBitmap(Graphics::TBitmap* bitmap, int width, int height);

ReSizeBitmap is a utility function to resize a bitmap. The bitmap is copied  to a new TBitmap object and resized to the specified width and height using the Windows StretchBlt API function, and returned as the function result.


MetaToBitmap
extern Graphics::TBitmap* __fastcall MetaToBitmap(Graphics::TMetafile* metafile, long Width, long Height);

MetaFileToBitmap is a utility function that renders a metafile using the current display device and returns the result as a bitmap with the specified width and height.


CropBitmap
extern Graphics::TBitmap* __fastcall CropBitmap(Graphics::TBitmap* bitmap, int width, int height, const Windows::TRect &Clip);

CropBitmap is a utility function that is used to copy a portion of an existing bitmap (given by the rectangle "Clip" to a new bitmap returned as the result of the function. The newly created bitmap can also be resized. "width and "height" specify the width and height of the new bitmap. If the bitmap is to be the same size as the Clip, then widh should be set to Clip.Right-Clip.Left and height to Clip.Bottom-Clip.Top.


AutoDisplay Property
__property bool AutoDisplay = {read=FAutoDisplay, write=FAutoDisplay, default=1};

Class : TDBJPEGImage

If AutoDisplay is True (the default value), the image automatically displays new data when the underlying BLOB field changes (such as when moving to a new record). If AutoDisplay is False, the image clears whenever the underlying BLOB field changes. To display the data, the user can double-click on the control or select it and press Enter. In addition, calling the LoadPicture method ensures that the control is showing data. Change the value of AutoDisplay to False if the automatic loading of BLOB fields seems to take too long.


property JPEGCompressor: TJPEGFileCompressor read FJPEGCompressor write FJPEGCompressor;
__property Mwajpeg::TJPEGFileCompressor* JPEGCompressor = {read=FJPEGCompressor, write=FJPEGCompressor, nodefault};

Class : TDBJPEGImage

By default, a JPEG Compressor component is created with default parameters. If non-default parameters are required, then a TJPEGFileCompressor component should be created with the required parameters and assigned to this property.


property JPEGDecompressor: TJPEGFileDecompressor;
__property Mwajpeg::TJPEGFileDecompressor* JPEGDecompressor = {read=FJPEGDecompressor, write=FJPEGDecompressor, nodefault};

Class : TDBJPEGImage

By default, a JPEG Decompressor component is created with default parameters. If non-default parameters are required, then a TJEPGFileDecompressor component should be created with the required parameters and assigned to this property.


property DataField: string;
__property System::AnsiString DataField = {read=GetDataField, write=SetDataField, nodefault};

Class : TDBJPEGImage

Set to the required field name (must be a Blob field).


property DataSource: TDataSource;
__property Db::TDataSource* DataSource = {read=GetDataSource, write=SetDataSource, nodefault};

Class : TDBJPEGImage

Set to the data source for the dataset.


property ReadOnly: boolean;
__property bool ReadOnly = {read=GetReadOnly, write=SetReadOnly, nodefault};

Class : TDBJPEGImage

When set prevents changes to the data field.


property Field: TField;
__property Db::TField* Field = {read=GetField, nodefault};

Class : TDBJPEGImage

This property provides access to the field named by DataField.


procedure LoadPicture;
void __fastcall LoadPicture(void);

Class : TDBJPEGImage

If the value of the AutoDisplay property is False, the image of a database image control is not automatically loaded. If AutoDisplay is False, control when the image is loaded at runtime by calling LoadPicture when the image should appear in the control.


procedure CopyToClipboard;
void __fastcall CopyToClipboard(void);

Class : TDBJPEGImage

Use CopyToClipboard to put a copy of the graphic specified by the Picture property in the Clipboard.


procedure CutToClipboard;
void __fastcall CutToClipboard(void);

Class : TDBJPEGImage

Use the CutToClipboard method to delete the image in the control when copying it to the Clipboard. CutToClipboard gives the associated field a null value.


procedure PasteFromClipboard;
void __fastcall PasteFromClipboard(void);

Class : TDBJPEGImage

Use PasteFromClipboard to set the field value to an image stored in the Clipboard.


How to make a JPEG Image into a user defined resource

The methods LoadPictureFromResource and LoadPictureFromResID provide ways of loading a JPEG Image at run time into a TPicture from a user defined resource. (An example is provided by the Viewer Demo program’s about box).

Such a resource is simply binary data linked into the same .exe file as the program and accessed at run-time by either a name or a numeric identifier. It is created using the command line tool BRCC32.EXE - although the use of this tool is fortunately automated through the Project Manager and the project’s make file.

To create such a resource, you must first create a text file (you may use any available text editor such as Notepad), containing a line for each image that you want to make into a resource. This line will be in the form:

<name> JPEG DISCARDABLE <jpegfilename>

The <name> can be any unique string (that is if you bind in multiple JPEG images, each must have a different name), and the <jpegfilename> is simply the filename and path (including extension) of the file containing the JPEG Image. Alternatively, <name> can be a unique number (> 256).

For example, if the JPEG Image is in the file “MyImage.jpg” (in the current directory) and you decide to name it “MyPhoto”. Then this line will read:

MyPhoto JPEG DISCARDABLE MyImage.jpg

Save this text file in the same directory as the project .cpp files and give it a name with the extension “.rc” (e.g. “MyPhoto.rc”). This .rc file should now be “added” to your project using the IDE’s Project Manager (remember to change the “File Type” to Resource Files (*.rc) in the Open Dialog!). The .rc file is otherwise added to your project in the same way that you would add a .cpp file.

All you have to do now is to compile your program and load the resource!


INSTALLATION INSTRUCTIONS

Installation is straightforward. The JPEG Component Library is distributed in a .zip archive; separate versions are provided for use with Delphi 1.0, 2.0 and 3.0, and C++Builder 1 and 3. Make sure you have the correct version and then:

1.	Create a new sub-directory in your delphi directory (the actual name is unimportant - call it jpeg if you can't think of anything better) and copy the remaining files contained in the .zip file into this new subdirectory. You should aim to preserve the directory names held in the zip - if you are using pkunzip them use the -d option when unzipping the files. Note that if you do use a different directory from that suggested then you will have to modify the demo programs' .mak files to change the search path for the JPEG components.

2.	iii. Start the C++Builder IDE and choose the Component|Install Packages menu item. Click on the "Add" button and browse for the mwjpegc3.bpl file you just copied to the new subdirectory. Click on OK. The package will now be installed. By default the JPEG components are placed on the "Additional" tab, TDBJPEGImage is on the Data Controls tab, and TQRDBJPEGImage is on the QReports tab.

You should now restart C++Builder before trying to load a JPEG Image at Design Time.

Use the demo application to learn how they are used.