Unit GIFImage

Classes

TGIFAppExtensionClass -
TGIFAppExtNSLoop - ****************************************************************************** ** ** TGIFAppExtNSLoop **
TGIFApplicationExtension -
TGIFBlock - ****************************************************************************** ** ** TGIFUnknownAppExtension **
TGIFColorMap -
TGIFCommentExtension - ****************************************************************************** ** ** TGIFCommentExtension **
TGIFExtension - To avoid warning about hiding base class constructor
TGIFExtensionClass -
TGIFExtensionList - ****************************************************************************** ** ** TGIFSubImage **
TGIFGraphicControlExtension -
TGIFHeader - actual ratio = (AspectRatio + 15) / 64
TGIFImage -
TGIFImageList - ****************************************************************************** ** ** TGIFImage **
TGIFItem - ****************************************************************************** ** ** TGIFItem **
TGIFList - ****************************************************************************** ** ** TGIFList **
TGIFPainter -
TGIFSubImage - Bit fields
TGIFTextExtension -
TGIFTrailer - ****************************************************************************** ** ** TGIFTrailer **
TGIFUnknownAppExtension -

Functions

Register - ****************************************************************************** ** ** Design Time support ** *******************************************************************************) // Dummy component registration for design time support of GIFs in TImage

****************************************************************************** ** ** Design Time support **
WebPalette - ****************************************************************************** ** ** Utility routines ** *******************************************************************************) // WebPalette creates a 216 color uniform palette a.

Types

PColorMap
PGIFPainter
TColorMap
TDisposalMethod
TGIFApplicationRec
TGIFAuthenticationCode
TGIFColor
TGIFDrawOption
TGIFDrawOptions
TGIFExtensionType
TGIFGCERec
TGIFIdentifierCode
TGIFPlainTextExtensionRec
TGIFSeverity
TGIFVersion
TGIFVersionRec
TGIFWarning
TImageDescriptor
TLogicalScreenDescriptor

Constants

GIFMaxColors
GIFVersions

Variables

DoAutoDither
GIFDefaultDelay
GIFDelayExp
GIFImageDefaultDrawOptions
GIFImageDefaultThreadPriority
GIFMaximumDelay
GIFMinimumDelay


Functions


procedure Register;

****************************************************************************** ** ** Design Time support ** *******************************************************************************) // Dummy component registration for design time support of GIFs in TImage

****************************************************************************** ** ** Design Time support **


function WebPalette: HPalette;

****************************************************************************** ** ** Utility routines ** *******************************************************************************) // WebPalette creates a 216 color uniform palette a.k.a. the Netscape Palette

****************************************************************************** ** ** Utilities **


Types


PColorMap = ^TColorMap

PGIFPainter = ^TGIFPainter
Note: if goAsync is not set then goDirectDraw should be set. Otherwise the image will not be displayed.
TColorMap = packed array[0..GIFMaxColors-1] of TGIFColor;

TDisposalMethod = (dmNone, dmNoDisposal, dmBackground, dmPrevious);

TGIFApplicationRec = record
Identifier : TGIFIdentifierCode;
Authentication : TGIFAuthenticationCode;
end;

TGIFAuthenticationCode = array[0..2] of char;

TGIFColor = record
Red : byte;
Green : byte;
Blue : byte;
end;
****************************************************************************** ** ** TGIFColorMap ** *******************************************************************************) // One way to do it: // TBaseColor = (bcRed, bcGreen, bcBlue); // TGIFColor = array[bcRed..bcBlue] of BYTE; // Another way:
TGIFDrawOption =
    (goAsync,			// Asyncronous draws (paint in thread)
     goTransparent,		// Transparent draws
     goAnimate,			// Animate draws
     goLoop,			// Loop animations
     goLoopContinously,		// Ignore loop count and loop forever
     goValidateCanvas,		// Validate canvas in threaded paint ***NOT IMPLEMENTED***
     goDirectDraw,		// Draw() directly on canvas
     goDither,			// Dither to Netscape palette
     goAutoDither		// Only dither on 256 color systems
    );

TGIFDrawOptions = set of TGIFDrawOption
Only dither on 256 color systems
TGIFExtensionType = BYTE
****************************************************************************** ** ** TGIFExtension **
TGIFGCERec = record
BlockSize : byte;
PackedFields : Byte;
DelayTime : Word;
TransparentColorIndex : Byte;
Terminator : Byte;
end;
****************************************************************************** ** ** TGIFGraphicControlExtension ** *******************************************************************************) // Graphic Control Extension block a.k.a GCE
TGIFIdentifierCode = array[0..7] of char;
****************************************************************************** ** ** TGIFApplicationExtension **
TGIFPlainTextExtensionRec = record
BlockSize : byte;
Left : Word;
Top : Word;
Width : Word;
Height : Word;
CellWidth : Byte;
CellHeight : Byte;
TextFGColorIndex : Byte;
TextBGColorIndex : Byte;
end;
****************************************************************************** ** ** TGIFTextExtension **
TGIFSeverity = (gsInfo, gsWarning, gsError);
Severity level as indicated in the Warning methods and the OnWarning event
TGIFVersion = (gvUnknown, gv87a, gv89a);
* GIFMaximumDelay: Maximum delay when painter is running in main thread (goAsync is not set). This value guarantees that a very long and slow GIF does not hang the system. (1000 = 10000 mS = 10 Seconds
TGIFVersionRec = array[0..2] of char;

TGIFWarning = procedure(Sender: TObject; Severity: TGIFSeverity; Message: string) of object

TImageDescriptor = record
Separator : byte;
Left : word;
Top : word;
Width : word;
Height : word;
PackedFields : byte;
end;

TLogicalScreenDescriptor = record
ScreenWidth : word;
ScreenHeight : word;
PackedFields : byte;
BackgroundColorIndex : byte;
AspectRatio : byte;
end;
****************************************************************************** ** ** TGIFHeader **

Constants

GIFMaxColors = 256

****************************************************************************** ** ** Misc constants and support types **

GIFVersions = ('87a', '89a')


Variables

DoAutoDither : boolean = False

DoAutoDither is set to True in the initializaion section if the desktop DC supports 256 colors or less. It can be modified in your application to disable/enable Auto Dithering

GIFDefaultDelay : integer = 10

Delay multiplier in mS. Tweaked. {$ENDIF} * GIFDelayExp: The following delay values should all be multiplied by this value to calculate the effective time (in mS). According to the GIF specs, this value should be 10. Since our paint routines are much faster than Mozilla's, you might need to increase this value if your animations loops too fast. The optimal value is impossible to determine since it depends on the speed of the CPU, the viceo card, memory and many other factors.

GIFDelayExp : integer = 12

Max number of colors supported by GIF Don't bother changing this value!

GIFImageDefaultDrawOptions : TGIFDrawOptions = [goAsync, goLoop, goTransparent, goAnimate, goDither, goAutoDither]

Default options for TGIFImage.DrawOptions.

GIFImageDefaultThreadPriority : TThreadPriority = tpNormal

WARNING! Do not use goAsync and goDirectDraw unless you have absolute control of the destination canvas. TGIFPainter will continue to write on the canvas even after the canvas has been deleted, unless *you* prevent it. The goValidateCanvas option will fix this problem if it is ever implemented. Default painter thread priority

GIFMaximumDelay : integer = 1000

Minimum delay (from Mozilla source). Tweaked. {$ENDIF} * GIFMinimumDelay: The minumum delay used in the Mozilla source is 10mS. This corresponds to a value of 1. However, since our paint routines are much faster than Mozilla's, a value of 3 or 4 gives better results.

GIFMinimumDelay : integer = 4

* GIFDefaultDelay: Default animation delay. This value is used if no GCE is defined. (10 = 100 mS