Example #1
0
        MemoryStream DecompressSwfData(byte[] raw_swf_data)
        {
            var raw_reader = new SwfStreamReader(raw_swf_data);

            OriginalHeader = SwfShortHeader.Read(raw_reader);
            switch (OriginalHeader.Format)
            {
            case "FWS":
                return(new MemoryStream(raw_swf_data));

            case "CWS":
                var rest_stream = SwfStreamReader.DecompressZBytes(
                    raw_reader.ReadRest());
                var new_short_header = new SwfShortHeader {
                    Format     = "FWS",
                    Version    = OriginalHeader.Version,
                    FileLength = OriginalHeader.FileLength
                };
                var uncompressed_stream = new MemoryStream();
                SwfShortHeader.Write(new_short_header, uncompressed_stream);
                rest_stream.WriteTo(uncompressed_stream);
                uncompressed_stream.Position = 0;
                return(uncompressed_stream);

            default:
                throw new System.Exception(string.Format(
                                               "Unsupported swf format: {0}", OriginalHeader.Format));
            }
        }
Example #2
0
 void DecodeSwf(SwfStreamReader reader, System.Action <float> progress_act)
 {
     UncompressedHeader = SwfLongHeader.Read(reader);
     while (!reader.IsEOF)
     {
         if (progress_act != null)
         {
             progress_act((float)(reader.Position + 1) / reader.Length);
         }
         var tag = SwfTagBase.Read(reader);
         if (tag.TagType == SwfTagType.End)
         {
             break;
         }
         Tags.Add(tag);
     }
 }