Ejemplo n.º 1
0
        //WARNING: Reads without event flags
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        public void Read(SwfReader reader)
        {
            uint len = reader.ReadUInt32();

            if ((Flags & SwfEventFlags.KeyPress) != 0)
            {
                KeyCode = reader.ReadUInt8();
            }
            //TODO: use len
            _actions.Read(reader);
        }
Ejemplo n.º 2
0
        public virtual void Read(SwfReader reader, bool alpha)
        {
            SpreadMode        = (SwfSpreadMode)reader.ReadUB(2);
            InterpolationMode = (SwfInterpolationMode)reader.ReadUB(2);
            int n = (int)reader.ReadUB(4);

            Ratios = new byte[n];
            Colors = new Color[n];
            for (int i = 0; i < n; ++i)
            {
                Ratios[i] = reader.ReadUInt8();
                Colors[i] = alpha ? reader.ReadRGBA() : reader.ReadRGB();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads flash movie from specified stream.
        /// </summary>
        /// <param name="input">input stream to load.</param>
        /// <param name="options">options to decode tags.</param>
        public void Load(Stream input, SwfTagDecodeOptions options)
        {
            var reader = new SwfReader(input)
            {
                TagDecodeOptions = options
            };

            //File Header
            var sig = reader.ReadASCII(3);

            // "FWS" or "CWS" for ZLIB compressed files (v6.0 or later)
            if (sig != "FWS" && sig != "CWS" && sig != "ZWS")
            {
                throw new BadImageFormatException("Not a valid SWF (Flash) file signature");
            }

            _version           = reader.ReadUInt8(); // file version
            reader.FileVersion = _version;
            uint fileLength = reader.ReadUInt32();   // file length

            //Debug.WriteLine(string.Format("SWF File Length = {0}", fileLength));

            // If the file is compressed, this is where the ZLIB decompression ("inflate") begins
            if (sig[0] == 'C')
            {
                reader.Stream = Zip.Uncompress(input);
            }
            else if (sig[0] == 'Z')             // LZMA since v13
            {
                // reader.Stream = new MemoryStream(Compression.Lzma.Decompress(input));
                throw new NotImplementedException();
            }

            //Movie Header
            var frameSize = reader.ReadRect();

            _frameSize.Width  = frameSize.Width.FromTwips();
            _frameSize.Height = frameSize.Height.FromTwips();
            _frameRate        = reader.ReadFixed16();
            _frameCount       = reader.ReadUInt16();

            //Movie Content
            _tags.Read(reader);
        }