swfstreams.int
上传用户:raido2005
上传日期:2022-06-22
资源大小:5044k
文件大小:5k
- //*******************************************************//
- // //
- // DelphiFlash.com //
- // Copyright (c) 2004-2008 FeatherySoft, Inc. //
- // info@delphiflash.com //
- // //
- //*******************************************************//
- // Description: Streams for reading and writing of SWF file
- // Last update: 12 mar 2008
- {$I defines.inc}
- unit SWFStreams;
- interface
- Uses Windows, Classes, SysUtils,
- {$IFDEF XMLSupport}
- SWFStrings, XMLDoc, XMLIntf, SWFXMLTools,
- {$ENDIF}
- SWFConst, Contnrs, SWFObjects;
- type
- TSWFTagInfo = class (TObject)
- BodySize: LongInt;
- FramePlace: Word;
- isLongSize: Boolean;
- Position: LongInt;
- SubTags: TObjectList;
- selfDestroy: boolean;
- SWFObject: TSWFObject;
- TagID: Word;
- constructor Create(ID: word; automake: boolean = true);
- destructor Destroy; override;
- function GetFullSize: LongInt;
- end;
- TBasedSWFStream = class;
- TProgressWorkType = (pwtReadStream, pwtMakeStream, pwtCompressStream, pwtLoadXML, pwtParseXML, pwtSaveXML);
- TSWFProgressEvent = procedure (sender: TBasedSWFStream; Percent: byte; WT: TProgressWorkType) of object;
- TSWFParseTagBodyEvent = procedure (sender: TSWFTagInfo; var Parse: boolean) of object;
- TSWFProcessTagEvent = procedure (sender: TSWFObject; var Process: boolean) of object;
- TSWFRenameObjectEvent = procedure (sender: TSWFObject; var newname: string) of object;
- // ================== TBasedSWFStream =========================
- TBasedSWFStream = class (TObject)
- public
- SWFHeader: TSWFHeader;
- constructor Create; overload; virtual;
- constructor Create(XMin, YMin, XMax, YMax: integer; fps: single; sc: TSWFSystemCoord = scTwips); overload; virtual;
- destructor Destroy; override;
- function FramePos(num: word): longint; virtual; abstract;
- function GetHeaderSize: Integer;
- procedure MakeStream; virtual; abstract;
- procedure MoveResource(ToFrame, StartFrom, EndFrom: integer); virtual; abstract;
- procedure SaveToFile(fn: string);
- procedure SaveToStream(Stream: TStream);
- procedure SetSWFRect(v: TRect);
- procedure WriteHeader(stream: TStream; part: TSWFHeaderPart = hpAll);
- {$IFDEF XMLSupport}
- function LoadFromXML(XML: IXMLDocument; asNew: boolean): boolean; virtual; abstract;
- function LoadFromXMLFile(fname: string; asNew: boolean): boolean;
- function LoadFromXMLString(const source: string; asNew: boolean): boolean;
- property XMLReadWriteSettings: TXMLReadWriteSettings read FXMLReadWriteSettings write FXMLReadWriteSettings;
- {$ENDIF}
- property BodyStream: TStream read GetBodyStream write SetBodyStream;
- property Compressed: Boolean read FCompressed write SetCompressed;
- property FPS: Single read GetFPS write SetFPS;
- property FramesCount: Word read SWFHeader.FramesCount;
- property Height: Integer read GetHeight write SetHeight;
- property MovieRect: TRect read GetSWFRect write SWFHeader.MovieRect;
- property MultCoord: Byte read FMultCoord write FMultCoord;
- property SystemCoord: TSWFSystemCoord read FSystemCoord write SetSystemCoord;
- property Version: Byte read SWFHeader.Version write SetVersion;
- property Width: Integer read GetWidth write SetWidth;
- property OnProgress: TSWFProgressEvent read FOnProgress write FOnProgress;
- end;
- TSWFStreamReader = class (TBasedSWFStream)
- public
- constructor Create(fn: string); overload;
- constructor Create(stream: TStream); overload;
- destructor Destroy; override;
- function CheckSWF(stest: TStream): Boolean;
- procedure DeleteTagByID(Place, Obj: boolean; ID: word);
- procedure DeleteTagByName(Place, Obj: boolean; name: string);
- function FindIDFromName(name: string): word;
- function FindObjectFromID(ID: word): TSWFObject;
- function FindObjectFromName(name: string): TSWFObject;
- function FindPlaceFromID(ID: word): TSWFPlaceObject;
- function FindPlaceFromName(name: string): TSWFPlaceObject2;
- function FindTagFromID(ID: word): longint;
- function FindTagFromObject(Obj: TSWFObject): longint;
- function FindTagFromName(name: string): longint;
- function FramePos(num: word): longint; override;
- function GetMinVersion: Byte;
- procedure LoadFromFile(fn: string);
- procedure LoadFromStream(stream: TStream);
- function LoadHeader(src: TStream; part: TSWFHeaderPart = hpAll): Integer;
- procedure MakeStream; override;
- procedure MoveResource(ToFrame, StartFrom, EndFrom: integer); override;
- procedure ReadBody(ParseTagData, ParseActionData: boolean);
- procedure Rename(prefix: string);
- function Renumber(start: word): Word;
- {$IFDEF XMLSupport}
- procedure SaveToXML(XML: IXMLDocument);
- procedure SaveToXMLFile(fname: string);
- function LoadFromXML(XML: IXMLDocument; asNew: boolean): boolean; override;
- {$ENDIF}
- property IsSWF: Boolean read FIsSWF;
- property OnParseTagBody: TSWFParseTagBodyEvent read FOnParseTagBody write FOnParseTagBody;
- property OnRenameObject: TSWFRenameObjectEvent read FOnRenameObject write FOnRenameObject;
- property OnRenumberTag: TSWFProcessTagEvent read FOnRenumberTag write FOnRenumberTag;
- property TagInfo[index: word]: TSWFTagInfo read GetTagInfo;
- property TagList: TObjectList read FTagList;
- end;
- implementation