Recurity.Swf.MorphLineStyle2.Parse C# (CSharp) Method

Parse() public method

Parses this object out of a stream
public Parse ( Stream input ) : void
input Stream The input stream.
return void
        public override void Parse(Stream input)
        {
            BinaryReader br = new BinaryReader(input);

            this._startWidth = br.ReadUInt16();
            this._endWidth = br.ReadUInt16();

            BitStream bits = new BitStream(input);

            this._startCapStyle = (CapStyle)(Convert.ToByte(bits.GetBits(2)));
            this._joinstyle = (JoinStyle)(Convert.ToByte(bits.GetBits(2)));

            this._hasFillFlag = (0 != bits.GetBits(1) ? true : false);
            this._noHScale = (0 != bits.GetBits(1) ? true : false);
            this._noVScale = (0 != bits.GetBits(1) ? true : false);
            this._pixelHinting = (0 != bits.GetBits(1) ? true : false);

            bits.GetBits(5); // reserved must be null

            this._noClose = (0 != bits.GetBits(1) ? true : false);

            this._endCapStyle = (CapStyle)bits.GetBits(2);

            if (this._joinstyle.Equals(JoinStyle.Miter))
            {
                this._miterLimtiFactor = br.ReadUInt16();
            }
            if (!this._hasFillFlag)
            {
                this._startColor.Parse(input);
                this._endColor.Parse(input);
            }
            if (this._hasFillFlag)
            {
                //bits.Reset();
                this._fillStyle.Parse(input);
            }
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <param name="caller"></param>
        public override void Parse(Stream input, TagTypes caller)
        {
            BinaryReader br = new BinaryReader(input);

            this._lineStyleCount = br.ReadByte();

            if (caller.Equals(TagTypes.DefineMorphShape2))
            {
                if (this._lineStyleCount.Equals(0xFF))
                {
                    this._lineStyleCountExtended = br.ReadUInt16();

                    for (UInt16 i = 0; i < this._lineStyleCountExtended; i++)
                    {
                        MorphLineStyle2 temp = new MorphLineStyle2(this._SwfVersion);
                        temp.Parse(input);
                        this._lineStyles.Add(temp);
                    }
                }
                else
                {

                    for (byte i = 0; i < this._lineStyleCount; i++)
                    {
                        MorphLineStyle2 temp = new MorphLineStyle2(this._SwfVersion);
                        temp.Parse(input);
                        this._lineStyles.Add(temp);
                    }

                }
            }
            else if (caller.Equals(TagTypes.DefineMorphShape))
            {
                if (this._lineStyleCount.Equals(0xFF))
                {
                    this._lineStyleCountExtended = br.ReadUInt16();

                    for (UInt16 i = 0; i < this._lineStyleCountExtended; i++)
                    {
                        MorphLineStyle temp = new MorphLineStyle(this._SwfVersion);
                        temp.Parse(input);
                        this._lineStyles.Add(temp);
                    }
                }
                else
                {
                    MorphLineStyle temp = null;

                    for (byte i = 0; i < this._lineStyleCount; i++)
                    {
                        temp = new MorphLineStyle(this._SwfVersion);
                        temp.Parse(input);
                        this._lineStyles.Add(temp);
                    }
                }
            }
            else
            {
                Exception e = new Exception(" Only DefineMorphShape2 and DefineMorphShape can access MorphLineStyleArray ");
               Log.Error(this, e.Message);
                throw e;
            }
        }