Class TBGRAAnimatedGif

Unit

Declaration

type TBGRAAnimatedGif = class(TGraphic)

Description

Class to read/write animated GIF, supports animated PNG as well when specified

Hierarchy

Overview

Fields

Public BackgroundMode: TGifBackgroundMode;
Public EraseColor: TColor;
Protected FDestroying: boolean;
Protected FImages: TGifSubImageArray;
Public LoopCount: Word;
Public LoopDone: Integer;

Methods

Public constructor Create; overload; override;
Public constructor Create(stream: TStream; AMaxImageCount: integer); overload;
Public constructor Create(stream: TStream); overload;
Public constructor Create(filenameUTF8: string); overload;
Public destructor Destroy; override;
Public function AddFrame(AImage: TFPCustomImage; X,Y: integer; ADelayMs: integer; ADisposeMode: TDisposeMode = dmErase; AHasLocalPalette: boolean = false; ADrawMode: TDrawMode = dmSetExceptTransparent; AOwned: boolean = false) : integer;
Public function AddFullFrame(AImage: TFPCustomImage; ADelayMs: integer; AHasLocalPalette: boolean = true; ADrawMode: TDrawMode = dmSetExceptTransparent; AOwned: boolean = false): integer;
Public function Duplicate: TBGRAAnimatedGif;
Public class function GetFileExtensions: string; override;
Public function MakeBitmapCopy(ABackground: TColor = clNone): TBitmap;
Protected function GetEmpty: boolean; override;
Protected function GetHeight: integer; override;
Protected function GetTransparent: boolean; override;
Protected function GetWidth: integer; override;
Public procedure Assign(ASource: TPersistent); override;
Public procedure Clear; override;
Public procedure DeleteFrame(AIndex: integer; AEnsureNextFrameDoesNotChange: boolean);
Public procedure Hide(Canvas: TCanvas; ARect: TRect); overload;
Public procedure InsertFrame(AIndex: integer; AImage: TFPCustomImage; X,Y: integer; ADelayMs: integer; ADisposeMode: TDisposeMode = dmErase; AHasLocalPalette: boolean = false; ADrawMode: TDrawMode = dmSetExceptTransparent; AOwned: boolean = false);
Public procedure InsertFullFrame(AIndex: integer; AImage: TFPCustomImage; ADelayMs: integer; AHasLocalPalette: boolean = true; ADrawMode: TDrawMode = dmSetExceptTransparent; AOwned: boolean = false);
Public procedure LoadFromFile(const AFilenameUTF8: string); override;
Public procedure LoadFromResource(AFilename: string);
Public procedure LoadFromStream(Stream: TStream; AMaxImageCount: integer); overload;
Public procedure LoadFromStream(Stream: TStream); overload; override;
Public procedure OptimizeFrames;
Public procedure Pause;
Public procedure ReplaceFullFrame(AIndex: integer; AImage: TFPCustomImage; ADelayMs: integer; AHasLocalPalette: boolean = true; ADrawMode: TDrawMode = dmSetExceptTransparent; AOwned: boolean = false);
Public procedure Resume;
Public procedure SaveToFile(const AFilenameUTF8: string); override;
Public procedure SaveToStream(Stream: TStream; AQuantizer: TBGRAColorQuantizerAny; ADitheringAlgorithm: TDitheringAlgorithm; AFormat: TBGRAImageFormat = ifGif); overload; virtual;
Public procedure SaveToStream(Stream: TStream; AFormat: TBGRAImageFormat); overload;
Public procedure SaveToStream(Stream: TStream); override; overload;
Public procedure SetSize(AWidth,AHeight: integer); virtual;
Public procedure Show(Canvas: TCanvas; ARect: TRect); overload;
Public procedure Update(Canvas: TCanvas; ARect: TRect); overload;
Protected procedure AssignImage(AImage: TFPCustomImage; AOwned: boolean);
Protected procedure AssignTo(Dest: TPersistent); override;
Protected procedure Changed(Sender: TObject); override;
Protected procedure CheckAnyFrame;
Protected procedure CheckSavable(AFormat: TBGRAImageFormat);
Protected procedure ClearViewer; virtual;
Protected procedure Draw(ACanvas: TCanvas; const Rect: TRect); override;
Protected procedure EnsureNextFrameRec(AIndex: integer);
Protected procedure LoadFromStreamAsGif(Stream: TStream; AMaxImageCount: integer);
Protected procedure LoadFromStreamAsPng(Stream: TStream; AMaxImageCount: integer);
Protected procedure LoadFromStreamAsStatic(Stream: TStream);
Protected procedure SaveToStreamAsGif(Stream: TStream; AQuantizer: TBGRAColorQuantizerAny; ADitheringAlgorithm: TDitheringAlgorithm); overload; virtual;
Protected procedure SaveToStreamAsPng(Stream: TStream; AQuantizer: TBGRAColorQuantizerAny; ADitheringAlgorithm: TDitheringAlgorithm); overload; virtual;
Protected procedure SaveToStreamAsPng(Stream: TStream);
Protected procedure SetHeight(Value: integer); override;
Protected procedure SetTransparent(Value: boolean); override;
Protected procedure SetWidth(Value: integer); override;

Properties

Public property AspectRatio: single read FAspectRatio write SetAspectRatio;
Public property AverageDelayMs: integer read GetAverageDelayMs;
Public property BackgroundColor: TColor Read FBackgroundColor write SetBackgroundColor;
Public property Bitmap: TBitmap Read GetBitmap;
Public property Count: integer Read GetCount;
Public property CurrentImage: integer Read FCurrentImage Write SetCurrentImage;
Public property FrameDelayMs[AIndex: integer]: integer read GetFrameDelayMs write SetFrameDelayMs;
Public property FrameDisposeMode[AIndex: integer]: TDisposeMode read GetFrameDisposeMode write SetFrameDisposeMode;
Public property FrameDrawMode[AIndex: integer]: TDrawMode read GetFrameDrawMode write SetFrameDrawMode;
Public property FrameHasLocalPalette[AIndex: integer]: boolean read GetFrameHasLocalPalette write SetFrameHasLocalPalette;
Public property FrameImage[AIndex: integer]: TBGRABitmap read GetFrameImage write SetFrameImage;
Public property FrameImagePos[AIndex: integer]: TPoint read GetFrameImagePos write SetFrameImagePos;
Public property Height: integer Read FHeight;
Public property MemBitmap: TBGRABitmap Read GetMemBitmap;
Public property Paused: boolean Read FPaused;
Public property TimeUntilNextImageMs: integer read GetTimeUntilNextImage;
Public property TotalAnimationTimeMs: Int64 read FTotalAnimationTime;
Public property Width: integer Read FWidth;

Description

Fields

Public BackgroundMode: TGifBackgroundMode;

This item has no description.

Public EraseColor: TColor;

This item has no description.

Protected FDestroying: boolean;

This item has no description.

Protected FImages: TGifSubImageArray;

This item has no description.

Public LoopCount: Word;

This item has no description.

Public LoopDone: Integer;

This item has no description.

Methods

Public constructor Create; overload; override;

This item has no description.

Public constructor Create(stream: TStream; AMaxImageCount: integer); overload;

This item has no description.

Public constructor Create(stream: TStream); overload;

This item has no description.

Public constructor Create(filenameUTF8: string); overload;

This item has no description.

Public destructor Destroy; override;

This item has no description.

Public function AddFrame(AImage: TFPCustomImage; X,Y: integer; ADelayMs: integer; ADisposeMode: TDisposeMode = dmErase; AHasLocalPalette: boolean = false; ADrawMode: TDrawMode = dmSetExceptTransparent; AOwned: boolean = false) : integer;

This item has no description.

Public function AddFullFrame(AImage: TFPCustomImage; ADelayMs: integer; AHasLocalPalette: boolean = true; ADrawMode: TDrawMode = dmSetExceptTransparent; AOwned: boolean = false): integer;

Add a frame that replaces completely the previous one

Public function Duplicate: TBGRAAnimatedGif;

This item has no description.

Public class function GetFileExtensions: string; override;

This item has no description.

Public function MakeBitmapCopy(ABackground: TColor = clNone): TBitmap;

This item has no description.

Protected function GetEmpty: boolean; override;

This item has no description.

Protected function GetHeight: integer; override;

This item has no description.

Protected function GetTransparent: boolean; override;

This item has no description.

Protected function GetWidth: integer; override;

This item has no description.

Public procedure Assign(ASource: TPersistent); override;

This item has no description.

Public procedure Clear; override;

This item has no description.

Public procedure DeleteFrame(AIndex: integer; AEnsureNextFrameDoesNotChange: boolean);

This item has no description.

Public procedure Hide(Canvas: TCanvas; ARect: TRect); overload;

This item has no description.

Public procedure InsertFrame(AIndex: integer; AImage: TFPCustomImage; X,Y: integer; ADelayMs: integer; ADisposeMode: TDisposeMode = dmErase; AHasLocalPalette: boolean = false; ADrawMode: TDrawMode = dmSetExceptTransparent; AOwned: boolean = false);

This item has no description.

Public procedure InsertFullFrame(AIndex: integer; AImage: TFPCustomImage; ADelayMs: integer; AHasLocalPalette: boolean = true; ADrawMode: TDrawMode = dmSetExceptTransparent; AOwned: boolean = false);

Insert at the specified AIndex a frame that replaces completely the previous one

Public procedure LoadFromFile(const AFilenameUTF8: string); override;

This item has no description.

Public procedure LoadFromResource(AFilename: string);

This item has no description.

Public procedure LoadFromStream(Stream: TStream; AMaxImageCount: integer); overload;

This item has no description.

Public procedure LoadFromStream(Stream: TStream); overload; override;

TGraphic

Public procedure OptimizeFrames;

This item has no description.

Public procedure Pause;

This item has no description.

Public procedure ReplaceFullFrame(AIndex: integer; AImage: TFPCustomImage; ADelayMs: integer; AHasLocalPalette: boolean = true; ADrawMode: TDrawMode = dmSetExceptTransparent; AOwned: boolean = false);

This item has no description.

Public procedure Resume;

This item has no description.

Public procedure SaveToFile(const AFilenameUTF8: string); override;

This item has no description.

Public procedure SaveToStream(Stream: TStream; AQuantizer: TBGRAColorQuantizerAny; ADitheringAlgorithm: TDitheringAlgorithm; AFormat: TBGRAImageFormat = ifGif); overload; virtual;

This item has no description.

Public procedure SaveToStream(Stream: TStream; AFormat: TBGRAImageFormat); overload;

There are some differences in the dispose modes and draw modes so some files cannot be directly saved from one format to the other:

PNG format is not limited to 256 colors, so there is no need for quantization even if it possible. When PNG has a palette, it applies to all frames, whereas for GIF, there can be a palette for each frame.

Public procedure SaveToStream(Stream: TStream); override; overload;

Save to a stream using GIF format

Public procedure SetSize(AWidth,AHeight: integer); virtual;

This item has no description.

Public procedure Show(Canvas: TCanvas; ARect: TRect); overload;

This item has no description.

Public procedure Update(Canvas: TCanvas; ARect: TRect); overload;

This item has no description.

Protected procedure AssignImage(AImage: TFPCustomImage; AOwned: boolean);

This item has no description.

Protected procedure AssignTo(Dest: TPersistent); override;

This item has no description.

Protected procedure Changed(Sender: TObject); override;

This item has no description.

Protected procedure CheckAnyFrame;

This item has no description.

Protected procedure CheckSavable(AFormat: TBGRAImageFormat);

This item has no description.

Protected procedure ClearViewer; virtual;

This item has no description.

Protected procedure Draw(ACanvas: TCanvas; const Rect: TRect); override;

TGraphic

Protected procedure EnsureNextFrameRec(AIndex: integer);

This item has no description.

Protected procedure LoadFromStreamAsGif(Stream: TStream; AMaxImageCount: integer);

This item has no description.

Protected procedure LoadFromStreamAsPng(Stream: TStream; AMaxImageCount: integer);

This item has no description.

Protected procedure LoadFromStreamAsStatic(Stream: TStream);

This item has no description.

Protected procedure SaveToStreamAsGif(Stream: TStream; AQuantizer: TBGRAColorQuantizerAny; ADitheringAlgorithm: TDitheringAlgorithm); overload; virtual;

This item has no description.

Protected procedure SaveToStreamAsPng(Stream: TStream; AQuantizer: TBGRAColorQuantizerAny; ADitheringAlgorithm: TDitheringAlgorithm); overload; virtual;

This item has no description.

Protected procedure SaveToStreamAsPng(Stream: TStream);

This item has no description.

Protected procedure SetHeight(Value: integer); override;

This item has no description.

Protected procedure SetTransparent(Value: boolean); override;

This item has no description.

Protected procedure SetWidth(Value: integer); override;

This item has no description.

Properties

Public property AspectRatio: single read FAspectRatio write SetAspectRatio;

linear blend only in PNG

Public property AverageDelayMs: integer read GetAverageDelayMs;

This item has no description.

Public property BackgroundColor: TColor Read FBackgroundColor write SetBackgroundColor;

This item has no description.

Public property Bitmap: TBitmap Read GetBitmap;

This item has no description.

Public property Count: integer Read GetCount;

This item has no description.

Public property CurrentImage: integer Read FCurrentImage Write SetCurrentImage;

This item has no description.

Public property FrameDelayMs[AIndex: integer]: integer read GetFrameDelayMs write SetFrameDelayMs;

This item has no description.

Public property FrameDisposeMode[AIndex: integer]: TDisposeMode read GetFrameDisposeMode write SetFrameDisposeMode;

This item has no description.

Public property FrameDrawMode[AIndex: integer]: TDrawMode read GetFrameDrawMode write SetFrameDrawMode;

This item has no description.

Public property FrameHasLocalPalette[AIndex: integer]: boolean read GetFrameHasLocalPalette write SetFrameHasLocalPalette;

This item has no description.

Public property FrameImage[AIndex: integer]: TBGRABitmap read GetFrameImage write SetFrameImage;

This item has no description.

Public property FrameImagePos[AIndex: integer]: TPoint read GetFrameImagePos write SetFrameImagePos;

This item has no description.

Public property Height: integer Read FHeight;

This item has no description.

Public property MemBitmap: TBGRABitmap Read GetMemBitmap;

This item has no description.

Public property Paused: boolean Read FPaused;

This item has no description.

Public property TimeUntilNextImageMs: integer read GetTimeUntilNextImage;

This item has no description.

Public property TotalAnimationTimeMs: Int64 read FTotalAnimationTime;

This item has no description.

Public property Width: integer Read FWidth;

This item has no description.