WriteString() public method

Writes the string.
public WriteString ( string value ) : void
value string Value.
return void
コード例 #1
0
ファイル: SwfWriter.cs プロジェクト: Berenold/SwfExport
        /// <summary>
        /// Writes the (compressed or uncompressed) swf data to a stream.
        /// The stream gets flushed and closed afterwards.
        /// </summary>
        /// <param name="swf">Swf</param>
        public void Write(Swf swf)
        {
            if (swf == null)
                return;

            // add EndTag is is not the last one
            BaseTag lastTag = swf.Tags.GetLastOne();
            if (lastTag == null || !(lastTag is EndTag))
                swf.Tags.Add(new EndTag());

            // update tag lengths to adapt to bytecode length
            swf.UpdateData();
            SwfHeader header = swf.Header;

            // ASCII seems to be ok for Flash 5 and 6+ as well
            BufferedBinaryWriter writer = new BufferedBinaryWriter(baseStream, System.Text.Encoding.GetEncoding("ascii"));
            BufferedBinaryWriter dataWriter = writer;

            bool isCompressed = (header.Signature[0] == 'C');

            if (isCompressed && swf.Version >= 6)
            {
                // SharpZipLib makes it easy for us, simply
                // chain a Deflater into the stream
                DeflaterOutputStream def = new DeflaterOutputStream(baseStream);
                dataWriter = new BufferedBinaryWriter(def);
            }

            // writer header data, always uncompressed
            writer.WriteString(header.Signature, 3);
            writer.Write(swf.Version);
            writer.Write(swf.ByteCount);
            writer.Flush();

            // write header data pt.2, using either
            // original stream or deflater stream
            header.Size.WriteTo(dataWriter);
            dataWriter.SynchBits();
            dataWriter.WriteFWord(header.Fps, 8, 8);
            dataWriter.Write(header.Frames);

            // write tags data
            IEnumerator tags = swf.Tags.GetEnumerator();
            while (tags.MoveNext())
            {
                BaseTag tagToWrite = (BaseTag)tags.Current;
                dataWriter.Write(tagToWrite.Data);
            }

            // flush + close
            dataWriter.Flush();
            dataWriter.Close();
        }
コード例 #2
0
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void UpdateData(byte version)
        {
            if (version < 6)
                return;

            MemoryStream m = new MemoryStream();
            BufferedBinaryWriter w = new BufferedBinaryWriter(m);

            RecordHeader rh = new RecordHeader(TagCode, GetSizeOf(), true);

            rh.WriteTo(w);
            w.Write(this.fontId);
            w.Write((byte)this.fontName.Length);
            if (fontName != null)
                w.WriteString(this.fontName, (uint)this.fontName.Length);

            w.WriteUBits(0, 2);
            w.WriteBoolean(fontFlagsSmallText);
            w.WriteUBits(0, 2);
            w.WriteBoolean(fontFlagsItalic);
            w.WriteBoolean(fontFlagsBold);
            w.WriteBoolean(true);

            w.Write(this.languageCode);
            if (codeTable != null)
            {
                IEnumerator glyphs = codeTable.GetEnumerator();
                while (glyphs.MoveNext())
                    w.Write((ushort)glyphs.Current);
            }

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
コード例 #3
0
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void UpdateData(byte version)
        {
            if (version < 3)
                return;

            MemoryStream m = new MemoryStream();
            BufferedBinaryWriter w = new BufferedBinaryWriter(m);

            RecordHeader rh = new RecordHeader(TagCode, GetSizeOf(version));
            rh.WriteTo(w);

            if (name != null)
                w.WriteString(name, (uint)name.Length);
            if (version >= 6)
                w.Write((byte)1);

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
コード例 #4
0
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void UpdateData(byte version)
        {
            MemoryStream m = new MemoryStream();
            BufferedBinaryWriter w = new BufferedBinaryWriter(m);

            RecordHeader rh = new RecordHeader(TagCode, GetSizeOf());
            rh.WriteTo(w);

            w.Write(fontId);
            w.Write((byte)fontName.Length);
            if (fontName != null)
                w.WriteString(fontName, (uint)fontName.Length);

            w.WriteUBits(0, 2); //reserved
            w.WriteBoolean(fontFlagsSmallText);
            w.WriteBoolean(fontFlagsShiftJIS);
            w.WriteBoolean(fontFlagsAINSI);
            w.WriteBoolean(fontFlagsItalic);
            w.WriteBoolean(fontFlagsBold);
            w.WriteBoolean(fontFlagsWildCodes);

            if (!fontFlagsWildCodes)
            {
                for (int i = 0; i < codeTable.Length; i++)
                    w.Write((byte)codeTable[i]);
            }
            else
            {
                for (int i = 0; i < codeTable.Length; i++)
                    w.Write((ushort)codeTable[i]);
            }

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
コード例 #5
0
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void UpdateData(byte version)
        {
            if (version < 4)
                return;

            MemoryStream m = new MemoryStream();
            BufferedBinaryWriter w = new BufferedBinaryWriter(m);
            RecordHeader rh = new RecordHeader(TagCode, GetSizeOf());
            rh.WriteTo(w);

            w.Write(this.characterId);
            this.rect.WriteTo(w);

            w.SynchBits();
            if (initialText != null && initialText.Length > 0)
                w.WriteBoolean(true);
            else
                w.WriteBoolean(false);
            w.WriteBoolean(wordWrap);
            w.WriteBoolean(multiline);
            w.WriteBoolean(password);
            w.WriteBoolean(readOnly);
            if (textColor != null)
                w.WriteBoolean(true);
            else
                w.WriteBoolean(false);
            w.WriteBoolean(HasMaxLength);
            w.WriteBoolean(HasFont);
            w.SynchBits();

            w.WriteBoolean(false);
            w.WriteBoolean(autoSize);
            w.WriteBoolean(HasLayout);
            w.WriteBoolean(noSelect);
            w.WriteBoolean(border);
            w.WriteBoolean(false);
            w.WriteBoolean(html);
            w.WriteBoolean(usedOutlines);

            if (HasFont)
            {
                w.Write(fontId);
                w.Write(fontHeight);
            }
            if (HasTextColor)
                textColor.WriteTo(w);
            if (HasMaxLength)
                w.Write(maxLenght);
            if (HasLayout)
            {
                w.Write(align);
                w.Write(leftMargin);
                w.Write(rightMargin);
                w.Write(indent);
                w.Write(leading);
            }
            w.WriteString(variableName);
            if (HasText)
                w.WriteString(initialText);

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
コード例 #6
0
ファイル: DefineFont2Tag.cs プロジェクト: Berenold/SwfExport
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void UpdateData(byte version)
        {
            if (version < 2)
                return;

            bool fontFlagsWideOffsets = HasWideOffsets();
            bool fontFlagsHasLayout = HasLayoutInfo();
            bool fontFlagsWideCodes = HasWideCodes(version);
            if (glyphShapesTable != null)
                glyphShapesTable.IsWideCodes = fontFlagsWideCodes;

            MemoryStream m = new MemoryStream();
            BufferedBinaryWriter w = new BufferedBinaryWriter(m);

            RecordHeader rh = new RecordHeader(TagCode, GetSizeOf());
            rh.WriteTo(w);

            w.Write(fontId);

            w.WriteBoolean(fontFlagsHasLayout);
            w.WriteBoolean(fontFlagsShiftJIS);
            w.WriteBoolean(fontFlagsSmallText);
            w.WriteBoolean(fontFlagsANSI);
            w.WriteBoolean(fontFlagsWideOffsets);
            w.WriteBoolean(fontFlagsWideCodes);
            w.WriteBoolean(fontFlagsItalic);
            w.WriteBoolean(fontFlagsBold);
            if (version >= 6)
                w.Write((byte)languageCode);
            else
                w.Write((byte)0);
            w.Write((byte)(this.fontName.Length + 1));
            w.WriteString(fontName);

            int numGlyph = GetNumGlyphs();
            w.Write((ushort)numGlyph);

            glyphShapesTable.IsWideCodes = fontFlagsWideCodes;

            //Create the codetableoffset and offsettable
            int offsetTableSize = 0;
            if (fontFlagsWideOffsets)
                offsetTableSize = (numGlyph * 4) + 4;
            else
                offsetTableSize = (numGlyph * 2) + 2;

            char[] codes = glyphShapesTable.GetOrderedCodes();
            IEnumerator glyphsEnum = glyphShapesTable.GetOrderedGlyphs(codes).GetEnumerator();
            int currentOffset = 0;
            for (int i = 0; glyphsEnum.MoveNext(); i++)
            {
                long offset = offsetTableSize + currentOffset;
                if (fontFlagsWideOffsets)
                    w.Write((uint)offset);
                else
                    w.Write((ushort)offset);

                ShapeRecordCollection shapes = ((ShapeRecordCollection)glyphsEnum.Current);
                int shapeSize = shapes.GetSizeOf();
                currentOffset += shapeSize;
            }

            if (fontFlagsWideOffsets)
                w.Write((uint)(offsetTableSize + currentOffset));
            else
                w.Write((ushort)(offsetTableSize + currentOffset));

            glyphShapesTable.WriteTo(w);

            if (fontFlagsHasLayout)
            {
                w.Write(fontAscent);
                w.Write(fontDescent);
                w.Write(fontLeading);

                if (numGlyph > 0)
                {
                    fontAdvanceTable.WriteTo(w);
                    fontBoundsTable.WriteTo(w);
                    if (version >= 7)
                        w.Write((ushort)0);
                    else
                        fontKerningTable.WriteTo(w);
                }
            }

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
コード例 #7
0
ファイル: Assert.cs プロジェクト: Berenold/SwfExport
 /// <summary>
 /// Writes to.
 /// </summary>
 /// <param name="writer">Writer.</param>
 public void WriteTo(BufferedBinaryWriter writer)
 {
     writer.Write(tag);
     writer.WriteString(name);
 }
コード例 #8
0
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void UpdateData(byte version)
        {
            if (version < 3)
                return;

            MemoryStream m = new MemoryStream();
            BufferedBinaryWriter w = new BufferedBinaryWriter(m);

            RecordHeader rh = new RecordHeader(TagCode, GetSizeOf(version));
            rh.WriteTo(w);

            w.WriteBoolean(HasClipActions());
            w.WriteBoolean(HasClipDepth());
            w.WriteBoolean(HasName());
            w.WriteBoolean(HasRatio());
            w.WriteBoolean(HasColorTransform());
            w.WriteBoolean(HasMatrix());
            w.WriteBoolean(HasCharacter());
            w.WriteBoolean(placeFlagMove);

            w.Write(depth);
            if (HasCharacter())
                w.Write(characterId);
            if (HasMatrix())
                matrix.WriteTo(w);
            if (HasColorTransform())
                colorTransform.WriteTo(w);
            if (HasRatio())
                w.Write((ushort)(ratio * 65535.0f));
            if (HasName())
                w.WriteString(name);
            if (HasClipDepth())
                w.Write(clipDepth);

            if (HasClipActions())
            {
                w.Write(actionHead);
                // ClipActionRecords
                foreach (ClipActionRec clpA in clipActions)
                    w.Write(clpA.GetData(version));
                // ClipActionRecords end
                if (version >= 6)
                    w.Write((int)0);
                else
                    w.Write((short)0);
            }

            w.Flush();
            _data = m.ToArray();
        }