Exemple #1
0
        public void WriteTo(Stream stream, SwfFormat swfFormat)
        {
            var outputWriter = new SwfStreamWriter(stream);

            if (swfFormat != SwfFormat.FWS)
            {
                var res = new MemoryStream();
                WriteTo(res, SwfFormat.FWS);
                res.Seek(0, SeekOrigin.Begin);
                Compress(res, stream, swfFormat);
            }
            else
            {
                var mem    = new MemoryStream();
                var writer = new SwfStreamWriter(mem);
                writer.WriteSwfHeader(Header);
                var bin = new SwfTagSerializer(this);
                foreach (var tag in Tags)
                {
                    var tagData = bin.GetTagData(tag);
                    writer.WriteTagData(tagData);
                }
                mem.Seek(0, SeekOrigin.Begin);

                outputWriter.WriteSwfFileInfo(new SwfFileInfo {
                    Format     = SwfFormat.FWS,
                    FileLength = (uint)(mem.Length + 8),
                    Version    = FileInfo.Version
                });
                mem.WriteTo(stream);
            }
            outputWriter.Flush();
            stream.Flush();
        }
Exemple #2
0
        public void WriteBodyTo(Stream mem)
        {
            var writer = new SwfStreamWriter(mem);

            writer.WriteSwfHeader(Header);
            var bin = new SwfTagSerializer(this);

            foreach (var tag in Tags)
            {
                var tagData = bin.GetTagData(tag);

                if (ReserializeAbcOnly && tag is not DoABCTag)
                {
                    tagData.Data = tag.OriginalData;
                }

                writer.WriteTagData(tagData);
            }
        }
Exemple #3
0
        public void WriteTo(Stream stream, bool compress)
        {
            var outputWriter = new SwfStreamWriter(stream);

            if (compress) {
                var res = new MemoryStream();
                WriteTo(res, false);
                res.Seek(0, SeekOrigin.Begin);
                Compress(res, stream);
            } else {
                var mem = new MemoryStream();
                var writer = new SwfStreamWriter(mem);
                writer.WriteSwfHeader(Header);
                var bin = new SwfTagSerializer(this);
                foreach (var tag in Tags) {
                    var tagData = bin.GetTagData(tag);
                    writer.WriteTagData(tagData);
                }
                mem.Seek(0, SeekOrigin.Begin);

                outputWriter.WriteSwfFileInfo(new SwfFileInfo {
                    Format = "FWS",
                    FileLength = (uint)(mem.Length + 8),
                    Version = FileInfo.Version
                });
                mem.WriteTo(stream);
            }
            outputWriter.Flush();
            stream.Flush();
        }