Пример #1
0
        public byte[] ToByteArray()
        {
            var writer = new SwfWriter();

            bool compress = _allowCompression && _version >= MinVersionSupportedComression;

            //write header
            writer.Write(compress ? SigCWS : SigFWS);

            writer.WriteUInt8((byte)_version);     //file version

            //NOTE: Comment below is from SWF specification.
            //The FileLength field is the total length of the SWF file, including the header. If this is an
            //uncompressed SWF file (FWS signature), the FileLength field should exactly match the file
            //size. If this is a compressed SWF file (CWS signature), the FileLength field indicates the total
            //length of the file after decompression, and thus generally does not match the file size.

            var data = GetFileData();
            int len  = data.Length;

            if (compress)
            {
                data = Zip.Compress(data);
                //if (data.Length > len)
                //    len = data.Length;
            }

            writer.WriteUInt32((uint)(8 + len)); //file length
            writer.Write(data);

            data = writer.ToByteArray();
            return(data);
        }
Пример #2
0
        public void Write(SwfWriter writer)
        {
            WriteFlags(writer, Flags);

            var eventWriter = new SwfWriter {
                FileVersion = writer.FileVersion
            };

            if ((Flags & SwfEventFlags.KeyPress) != 0)
            {
                eventWriter.WriteUInt8(KeyCode);
            }
            _actions.Write(eventWriter);

            var eventData = eventWriter.ToByteArray();

            writer.WriteUInt32((uint)eventData.Length);
            writer.Write(eventData);
        }