The header contains those informations:
/// <summary> /// Read swf (header and tags), this is the only /// public method of <see cref="SwfDotNet.IO.SwfReader">SwfReader</see> /// with <see cref="SwfDotNet.IO.SwfReader.Close">Close</see> and /// <see cref="SwfDotNet.IO.SwfReader.ReadSwfHeader">ReadSwfHeader</see> methods. /// The returned <see cref="SwfDotNet.IO.Swf">Swf</see> object contains swf headers informations and the /// tags list. /// </summary> public Swf ReadSwf() { // compressed swf? if (br.PeekChar() == 'C') { Inflate(); } SwfHeader header = new SwfHeader(); header.ReadData(br); this.version = header.Version; tagList = new BaseTagCollection(); bool readEndTag = false; //necessary for the 1 more byte bug while (br.BaseStream.Position < br.BaseStream.Length && !readEndTag) { BaseTag b = SwfReader.ReadTag(this.version, this.br, this.tagList); if (b != null) { if (b is EndTag) { readEndTag = true; } tagList.Add(b); } } ; br.Close(); return(new Swf(header, tagList)); }
/// <summary> /// Creates a new <see cref="Swf"/> instance. /// </summary> public Swf() { this.header = new SwfHeader(); this.tagList = new BaseTagCollection(); this.tagList.TagAdded += new TagAddedEvent(tagList_TagAdded); Init(); }
/// <summary> /// Writes the (compressed or uncompressed) swf data to a stream. /// The stream gets flushed and closed afterwards. /// </summary> /// <param name="swf">Swf</param> public void Write(Swf swf) { if (swf == null) { return; } // add EndTag is is not the last one BaseTag lastTag = swf.Tags.GetLastOne(); if (lastTag == null || !(lastTag is EndTag)) { swf.Tags.Add(new EndTag()); } // update tag lengths to adapt to bytecode length swf.UpdateData(); SwfHeader header = swf.Header; // ASCII seems to be ok for Flash 5 and 6+ as well BufferedBinaryWriter writer = new BufferedBinaryWriter(baseStream, System.Text.Encoding.GetEncoding("ascii")); BufferedBinaryWriter dataWriter = writer; bool isCompressed = (header.Signature[0] == 'C'); if (isCompressed && swf.Version >= 6) { // SharpZipLib makes it easy for us, simply // chain a Deflater into the stream DeflaterOutputStream def = new DeflaterOutputStream(baseStream); dataWriter = new BufferedBinaryWriter(def); } // writer header data, always uncompressed writer.WriteString(header.Signature, 3); writer.Write(swf.Version); writer.Write(swf.ByteCount); writer.Flush(); // write header data pt.2, using either // original stream or deflater stream header.Size.WriteTo(dataWriter); dataWriter.SynchBits(); dataWriter.WriteFWord(header.Fps, 8, 8); dataWriter.Write(header.Frames); // write tags data IEnumerator tags = swf.Tags.GetEnumerator(); while (tags.MoveNext()) { BaseTag tagToWrite = (BaseTag)tags.Current; dataWriter.Write(tagToWrite.Data); } // flush + close dataWriter.Flush(); dataWriter.Close(); }
/// <summary> /// Reads the SWF header only. /// This method don't read the complete content of the /// SWF file. Then, it provides the possibility to /// get faster header informations, and only it. /// </summary> /// <returns></returns> public SwfHeader ReadSwfHeader() { // compressed swf? if (br.PeekChar() == 'C') { Inflate(); } SwfHeader header = new SwfHeader(); header.ReadData(br); this.version = header.Version; tagList = new BaseTagCollection(); br.Close(); return(header); }
/// <summary> /// Creates a new <see cref="Swf"/> instance. /// </summary> /// <param name="header">Swf Header.</param> /// <param name="tagList">Swf Tag list sequence.</param> public Swf(SwfHeader header, BaseTagCollection tagList) { this.header = header; this.tagList = tagList; Init(); // count actions _actionCount = 0; foreach (BaseTag b in tagList) { _actionCount += b.ActionRecCount; if (b is DefineTag) { dictionnary.Add(b as DefineTag); } } }
/// <summary> /// Creates a new <see cref="Swf"/> instance. /// </summary> /// <param name="header">Swf Header.</param> /// <param name="tagList">Swf Tag list sequence.</param> public Swf(SwfHeader header, BaseTagCollection tagList) { this.header = header; this.tagList = tagList; Init(); // count actions _actionCount = 0; foreach (BaseTag b in tagList) { _actionCount += b.ActionRecCount; if (b is DefineTag) dictionnary.Add(b as DefineTag); } }
/// <summary> /// Reads the SWF header only. /// This method don't read the complete content of the /// SWF file. Then, it provides the possibility to /// get faster header informations, and only it. /// </summary> /// <returns></returns> public SwfHeader ReadSwfHeader() { // compressed swf? if (br.PeekChar()=='C') Inflate(); SwfHeader header = new SwfHeader(); header.ReadData(br); this.version = header.Version; tagList = new BaseTagCollection(); br.Close(); return header; }
/// <summary> /// Read swf (header and tags), this is the only /// public method of <see cref="SwfDotNet.IO.SwfReader">SwfReader</see> /// with <see cref="SwfDotNet.IO.SwfReader.Close">Close</see> and /// <see cref="SwfDotNet.IO.SwfReader.ReadSwfHeader">ReadSwfHeader</see> methods. /// The returned <see cref="SwfDotNet.IO.Swf">Swf</see> object contains swf headers informations and the /// tags list. /// </summary> public Swf ReadSwf() { // compressed swf? if (br.PeekChar()=='C') Inflate(); SwfHeader header = new SwfHeader(); header.ReadData(br); this.version = header.Version; tagList = new BaseTagCollection(); bool readEndTag = false; //necessary for the 1 more byte bug while (br.BaseStream.Position < br.BaseStream.Length && !readEndTag) { BaseTag b = SwfReader.ReadTag(this.version, this.br, this.tagList); if (b != null) { if (b is EndTag) readEndTag = true; tagList.Add(b); } }; br.Close(); return new Swf(header, tagList); }