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

Parse() public method

Parses this object out of a stream
public Parse ( BitStream bits, byte glyphBits, byte advancedBits ) : void
bits BitStream
glyphBits byte
advancedBits byte
return void
        public void Parse(BitStream bits, byte glyphBits, byte advancedBits)
        {
            this._glyphBits = glyphBits;
            this._advancedBits = advancedBits;

            this._glyphIndex =   bits.GetBits((UInt32)glyphBits);
            this._glyphAdvance = bits.GetBitsSigned((UInt32)advancedBits);
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// Parses this object out of a stream
        /// </summary>
        public void Parse(Stream input, TagTypes caller, byte glyphBits, byte advancedBits, byte firstByte)
        {
            this._textRecordType = GetBit(firstByte, 0);
            bool reserved1 = GetBit(firstByte, 1);
            bool reserved2 = GetBit(firstByte, 2);
            bool reserved3 = GetBit(firstByte, 3);
            this._StyleFlagsHasFont = GetBit(firstByte, 4);
            this._StyleFlagsHasColor = GetBit(firstByte, 5);
            this._StyleFlagsHasYOffset = GetBit(firstByte, 6);
            this._StyleFlagsHasXOffset = GetBit(firstByte, 7);

            if (!this._textRecordType || (reserved1 || reserved2 || reserved3))
            {
                SwfFormatException e = new SwfFormatException("The first four bits have to have the static values {1,0,0,0} but set different.");
               Log.Error(this, e.Message);
                throw e;
            }

            BinaryReader br = new BinaryReader(input);

            if (this._StyleFlagsHasFont)
            {
                this._fontID = br.ReadUInt16();
            }

            if (this._StyleFlagsHasColor)
            {
                if (caller.Equals(TagTypes.DefineFont2) || caller.Equals(TagTypes.DefineText2))
                {
                    this._textColor = new Rgba(this._SwfVersion);
                    this._textColor.Parse(input);
                }
                else
                {
                    this._textColor.Parse(input);
                }
            }
            if (this._StyleFlagsHasXOffset)
            {
                this._xOffset = br.ReadInt16();
            }
            if (this._StyleFlagsHasYOffset)
            {
                this._yOffset = br.ReadInt16();
            }
            if (this._StyleFlagsHasFont)
            {
                this._textHeight = br.ReadUInt16();
            }

            this._glyphCount = br.ReadByte();

            BitStream bits = new BitStream(input);

            GlyphEntry tempGlyph = null;

            for (int i = 0; i < this._glyphCount; i++)
            {
                tempGlyph = new GlyphEntry(this._SwfVersion);
                tempGlyph.Parse(bits, glyphBits, advancedBits);
                this._glyphEntries.Add(tempGlyph);
            }
        }