SwfDotNet.IO.Tags.Types.TextRecord.ReadData C# (CSharp) Method

ReadData() public method

Reads the data.
public ReadData ( BufferedBinaryReader binaryReader, bool &endOfRecordsFlag, TagCodeEnum tagCodeEnum ) : void
binaryReader SwfDotNet.IO.Utils.BufferedBinaryReader Binary reader.
endOfRecordsFlag bool End of records flag.
tagCodeEnum TagCodeEnum Tag code enum.
return void
        public void ReadData(BufferedBinaryReader binaryReader, ref bool endOfRecordsFlag, 
            TagCodeEnum tagCodeEnum)
        {
            binaryReader.SynchBits();
            bool textRecordType = binaryReader.ReadBoolean();
            binaryReader.ReadUBits(3);

            bool styleFlagsHasFont = binaryReader.ReadBoolean();
            bool styleFlagsHasColor = binaryReader.ReadBoolean();
            bool styleFlagsHasYOffset = binaryReader.ReadBoolean();
            bool styleFlagsHasXOffset = binaryReader.ReadBoolean();

            if (textRecordType == false)
            {
                endOfRecordsFlag = true;
                return;
            }

            fontId = 0;
            if (styleFlagsHasFont)
                fontId = binaryReader.ReadUInt16();

            textColor = null;
            if (styleFlagsHasColor)
            {
                if (tagCodeEnum == TagCodeEnum.DefineText2)
                {
                    textColor = new RGBA();
                    textColor.ReadData(binaryReader);
                }
                else
                {
                    textColor = new RGB();
                    textColor.ReadData(binaryReader);
                }
            }

            xOffset = 0;
            if (styleFlagsHasXOffset)
                xOffset = binaryReader.ReadInt16();

            yOffset = 0;
            if (styleFlagsHasYOffset)
                yOffset = binaryReader.ReadInt16();

            textHeight = 0;
            if (styleFlagsHasFont)
                textHeight = binaryReader.ReadUInt16();

            byte glyphCount = binaryReader.ReadByte();
            if (glyphCount > 0)
            {
                if (glyphEntries == null)
                    glyphEntries = new GlyphEntryCollection();
                else
                    glyphEntries.Clear();

                for (int i = 0; i < glyphCount; i++)
                {
                    GlyphEntry glyphEntry = new GlyphEntry();
                    glyphEntry.ReadData(binaryReader);
                    glyphEntries.Add(glyphEntry);
                }
            }
        }

Usage Example

コード例 #1
0
ファイル: DefineText.cs プロジェクト: foresightbrand/brandqq
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void ReadData(byte version, BufferedBinaryReader binaryReader)
        {
            RecordHeader rh = new RecordHeader();
            rh.ReadData(binaryReader);

            characterId = binaryReader.ReadUInt16();
            if (rect == null)
                rect = new Rect();
            rect.ReadData(binaryReader);

            if (matrix == null)
                matrix = new Matrix();
            matrix.ReadData(binaryReader);

            TextRecordCollection.GLYPH_BITS = binaryReader.ReadByte();
            TextRecordCollection.ADVANCE_BITS = binaryReader.ReadByte();

            if (textRecords == null)
                textRecords = new TextRecordCollection();
            else
                textRecords.Clear();
            bool endOfRecordsFlag = false;
            while (!endOfRecordsFlag)
            {
                TextRecord textRecord = new TextRecord();
                textRecord.ReadData(binaryReader, ref endOfRecordsFlag, (TagCodeEnum)this.TagCode);
                if (!endOfRecordsFlag)
                    textRecords.Add(textRecord);
            }
        }