Recurity.Swf.StraightEdgeRecord.Parse C# (CSharp) Метод

Parse() публичный Метод

public Parse ( Stream inout, BitStream bits ) : void
inout Stream
bits BitStream
Результат void
        public override void Parse(Stream inout, BitStream bits)
        {
            this._numbits = (UInt32)bits.GetBits(4);

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

            if (this._generalLineFlag)
            {
                this._deltaX = (Int32)bits.GetBitsSigned((UInt32)this._numbits + 2);
                this._deltaY = (Int32)bits.GetBitsSigned((UInt32)this._numbits + 2);
            }
            else
            {
                this._vertLineFlag = (0 != bits.GetBits(1)) ? true : false;

                if (this._vertLineFlag)
                {
                    this._deltaY = (Int32)bits.GetBitsSigned((UInt32)this._numbits + 2);
                }
                else
                {
                    this._deltaX = (Int32)bits.GetBitsSigned((UInt32)this._numbits + 2);
                }
            }
        }

Usage Example

Пример #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <param name="caller"></param>
        public virtual void TryParseShapeRecords(MemoryStream input, TagTypes caller)
        {
            BitStream bits = new BitStream(input);

            this._shapeRecords = new List<ShapeRecord>();

            StyleChangeRecord tempSCR = new StyleChangeRecord(this._SwfVersion);
            StraightEdgeRecord tempSER = new StraightEdgeRecord(this._SwfVersion);
            CurvedEdgeRecord tempCER = new CurvedEdgeRecord(this._SwfVersion);

            byte fiveBits = 0;
            bool endShapeRecordSeen = false;
            int numberOfStyleChanges = 0;

            UInt16 localNumFillBits = this._numFillBits;
            UInt16 localNumLineBits = this._numLineBits;

            do
            {
                bool typeFlag = (0 != bits.GetBits(1)) ? true : false;

                if (typeFlag)
                {
                    bool straightFlag = Convert.ToBoolean(bits.GetBits(1));

                    if (straightFlag)
                    {
                        tempSER = new StraightEdgeRecord(this._SwfVersion);
                        tempSER.Parse(input, bits);
                        this._shapeRecords.Add(tempSER);
                    }
                    else
                    {
                        tempCER = new CurvedEdgeRecord(this._SwfVersion);
                        tempCER.Parse(input, bits);
                        this._shapeRecords.Add(tempCER);
                    }
                }
                else
                {
                    fiveBits = (byte)bits.GetBits(5);

                    if (0 == fiveBits)
                    {
                        endShapeRecordSeen = true;
                    }
                    else
                    {
                        tempSCR = new StyleChangeRecord(this._SwfVersion);
                        tempSCR.Parse(input, bits, fiveBits, caller, ref localNumFillBits, ref localNumLineBits, 0 == numberOfStyleChanges ? true : false);
                        numberOfStyleChanges += 1;
                        this._shapeRecords.Add(tempSCR);
                    }
                }
            }
            while (!endShapeRecordSeen);
            bits.Reset();
        }