Пример #1
0
        public void GetBitsTest()
        {
            var bits = new UnsignedBitsCount(0);

            bits.AddValue(127);
            bits.AddValue(260);
            bits.AddValue(15);
            bits.AddValue(514);
            Assert.AreEqual(10, bits.GetBits());
        }
Пример #2
0
        SwfTagData ISwfTagVisitor <ISwfStreamWriter, SwfTagData> .Visit(DefineText2Tag tag, ISwfStreamWriter writer)
        {
            writer.WriteUInt16(tag.CharacterID);
            writer.WriteRect(tag.TextBounds);
            writer.WriteMatrix(ref tag.TextMatrix);
            var glyphBitsCounter   = new UnsignedBitsCount(0);
            var advanceBitsCounter = new SignedBitsCount(0);

            foreach (var textRecord in tag.TextRecords)
            {
                foreach (var glyph in textRecord.Glyphs)
                {
                    glyphBitsCounter.AddValue(glyph.GlyphIndex);
                    advanceBitsCounter.AddValue(glyph.GlyphAdvance);
                }
            }
            var glyphBits   = glyphBitsCounter.GetBits();
            var advanceBits = advanceBitsCounter.GetBits();

            writer.WriteByte((byte)glyphBits);
            writer.WriteByte((byte)advanceBits);
            foreach (var textRecord in tag.TextRecords)
            {
                writer.WriteTextRecordRGBA(textRecord, glyphBits, advanceBits);
                writer.FlushBits();
            }
            writer.FlushBits();
            return(null);
        }