Write() public method

Writes the specified value.
public Write ( bool value ) : void
value bool Value.
return void
Ejemplo n.º 1
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);
            if (Meta != null)
                w.Write(Meta);

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Writes to.
 /// </summary>
 /// <param name="writer">Writer.</param>
 public void WriteTo(BufferedBinaryWriter writer)
 {
     IEnumerator shorts = this.GetEnumerator();
     while (shorts.MoveNext())
         writer.Write((short)shorts.Current);
 }
Ejemplo n.º 3
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(this.soundId);
            w.WriteUBits(soundFormat, 4);
            w.WriteUBits(soundRate, 2);
            w.WriteUBits(soundSize, 1);
            w.WriteUBits(soundType, 1);

            w.Write(this.soundSampleCount);
            if (soundData != null)
                w.Write(this.soundData);

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Writes to a binary writer.
        /// </summary>
        /// <param name="writer">Writer.</param>
        public void WriteTo(BufferedBinaryWriter writer)
        {
            int count = this.Count;
            if (count < 0xFF)
                writer.Write((byte)count);
            else
            {
                writer.Write((byte)(0xFF));
                writer.Write((ushort)count);
            }

            IEnumerator fillStyles = this.GetEnumerator();
            while (fillStyles.MoveNext())
                ((FillStyle)fillStyles.Current).WriteTo(writer);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void UpdateData(byte version)
        {
            if (version < 2)
                return;

            // Compression process
            int lenghtOfCompressedBlock = 0;
            byte[] compressArray = null;
            MemoryStream unCompressedStream = new MemoryStream();
            BufferedBinaryWriter unCompressedWriter = new BufferedBinaryWriter(unCompressedStream);

            if (this._bitmapFormat == 3)
            {
                this._colorMapData.WriteTo(unCompressedWriter);
            }
            else if (this._bitmapFormat == 4 || this._bitmapFormat == 5)
            {
                this._bitmapColorData.WriteTo(unCompressedWriter);
            }

            MemoryStream compressedStream = new MemoryStream();
            DeflaterOutputStream ouput = new DeflaterOutputStream(compressedStream);
            byte[] unCompressArray = unCompressedStream.ToArray();
            ouput.Write(unCompressArray, 0, unCompressArray.Length);
            ouput.Finish();
            compressArray = compressedStream.ToArray();
            lenghtOfCompressedBlock = compressArray.Length;
            ouput.Close();
            unCompressedStream.Close();

            //Writing process
            MemoryStream m = new MemoryStream();
            BufferedBinaryWriter w = new BufferedBinaryWriter(m);

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

            rh.WriteTo(w);
            w.Write(this._characterId);
            w.Write(this._bitmapFormat);
            w.Write(this._bitmapWidth);
            w.Write(this._bitmapHeight);

            if (this._bitmapFormat == 3)
            {
                w.Write(this._bitmapColorTableSize);
                w.Write(compressArray);
            }
            else if (this._bitmapFormat == 4 || this._bitmapFormat == 5)
            {
                w.Write(compressArray);
            }

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Writes to binary writer.
 /// </summary>
 /// <param name="writer">Writer.</param>
 public void WriteTo(BufferedBinaryWriter writer)
 {
     int count = this.Count;
     if (count < 0xFF)
         writer.Write((byte)count);
     else
     {
         writer.Write((byte)(0xFF));
         writer.Write((ushort)count);
     }
     foreach (MorphFillStyle mFillStyle in this)
         mFillStyle.WriteTo(writer);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void UpdateData(byte version)
        {
            if (version < 5)
                return;

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

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

            if (exportedCharacters != null)
                w.Write((ushort)exportedCharacters.Count);
            else
                w.Write((ushort)0);

            if (exportedCharacters != null)
            {
                IEnumerator assertEnu = exportedCharacters.GetEnumerator();
                while (assertEnu.MoveNext())
                {
                    Assert assert = (Assert)assertEnu.Current;
                    assert.WriteTo(w);
                }
            }

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Ejemplo n.º 8
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();
        }
Ejemplo n.º 9
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();
        }
Ejemplo n.º 10
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, 2 + actionRecord.Length);

            rh.WriteTo(w);
            w.Write(spriteId);
            w.Write(actionRecord);

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Ejemplo n.º 11
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();
        }
Ejemplo n.º 12
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(this.buttonId);
            if (characters != null)
            {
                foreach (ButtonRecord buttRec in characters)
                    buttRec.WriteTo(w, TagCodeEnum.DefineButton);
            }
            byte end = 0;
            w.Write(end);
            if (actions != null)
                w.Write(actions);
            w.Write(end);

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Ejemplo n.º 13
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();
        }
Ejemplo n.º 14
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());

            rh.WriteTo(w);
            w.Write(characterId);
            if (jpegData != null)
                w.Write(Convert.ToUInt32(jpegData.Length));
            else
                w.Write((int)0);
            if (jpegData != null)
                w.Write(jpegData);
            if (alphaData != null)
                w.Write(alphaData);

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Ejemplo n.º 15
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());
            rh.WriteTo(w);

            w.Write(this.characterId);
            w.Write(this.numFrames);
            w.Write(this.width);
            w.Write(this.height);

            w.WriteUBits(0, 5);
            w.WriteUBits(videoFlagsDeblocking, 2);
            w.WriteBoolean(videoFlagsSmoothing);

            w.Write(this.codecId);

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Writes binary data to given BinaryWriter.
        /// </summary>
        /// <param name="w">binary writer</param>
        public void WriteTo(BufferedBinaryWriter w)
        {
            if ( longTag || (tagLength > 0x3e) )
            {
                byte[] b = BitConverter.GetBytes(
                    Convert.ToUInt16( (Convert.ToUInt16(tagCode) << 6) + 0x3F )
                );
                w.Write( b );

                uint len = tagLength;
                b = BitConverter.GetBytes(len);
                w.Write( b );
            }
            else
            {
                byte[] b = BitConverter.GetBytes(
                    Convert.ToUInt16( (Convert.ToUInt16(tagCode) << 6) + Convert.ToUInt16(tagLength) )
                );
                w.Write( b );
            }
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Writes to.
 /// </summary>
 /// <param name="writer">Writer.</param>
 public void WriteTo(BufferedBinaryWriter writer)
 {
     writer.Write((ushort)this.Count);
     IEnumerator kernings = this.GetEnumerator();
     while (kernings.MoveNext())
         ((KerningRecord)kernings.Current).WriteTo(writer);
 }
Ejemplo n.º 18
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.WriteUBits(0, 4);
            w.WriteUBits(playbackSoundRate, 2);
            w.WriteUBits(playbackSoundSize, 1);
            w.WriteUBits(playbackSoundType, 1);
            w.WriteUBits(streamSoundCompression, 4);
            w.WriteUBits(streamSoundRate, 2);
            w.WriteUBits(streamSoundSize, 1);
            w.WriteUBits(streamSoundType, 1);
            w.Write(streamSoundSampleCount);
            if (streamSoundCompression == 2)
                w.Write(latencySeek);

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Ejemplo n.º 19
0
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void UpdateData(byte version)
        {
            if (version < 7)
                return;

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

            RecordHeader rh = new RecordHeader(TagCode, 4);

            rh.WriteTo(w);
            w.Write(recursion);
            w.Write(timeout);

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Writes to a binary writer.
        /// </summary>
        /// <param name="writer">Writer.</param>
        public void WriteTo(BufferedBinaryWriter writer)
        {
            writer.SynchBits();

            writer.WriteBoolean(true);
            writer.WriteUBits(0, 3);

            bool styleFlagsHasFont = HasFont();
            bool styleFlagsHasColor = HasColor();
            bool styleFlagsHasYOffset = HasYOffset();
            bool styleFlagsHasXOffset = HasXOffset();

            writer.WriteBoolean(styleFlagsHasFont);
            writer.WriteBoolean(styleFlagsHasColor);
            writer.WriteBoolean(styleFlagsHasYOffset);
            writer.WriteBoolean(styleFlagsHasXOffset);

            if (styleFlagsHasFont)
                writer.Write(this.fontId);

            if (styleFlagsHasColor)
                this.textColor.WriteTo(writer);
            if (styleFlagsHasXOffset)
                writer.Write(this.xOffset);
            if (styleFlagsHasYOffset)
                writer.Write(this.yOffset);
            if (styleFlagsHasFont)
                writer.Write(this.textHeight);
            writer.Write((byte)this.glyphEntries.Count);

            if (this.glyphEntries != null)
            {
                IEnumerator glyphs = this.glyphEntries.GetEnumerator();
                while (glyphs.MoveNext())
                    ((GlyphEntry)glyphs.Current).WriteTo(writer);
            }
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Writes to a binary writer.
 /// </summary>
 /// <param name="writer">Writer.</param>
 public void WriteTo(BufferedBinaryWriter writer)
 {
     writer.Write(this.fillStyleType);
     if (fillStyleType == (byte)MorphFillStyleType.SolidFill)
     {
         if (startColor != null)
             this.startColor.WriteTo(writer);
         if (endColor != null)
             this.endColor.WriteTo(writer);
     }
     if (fillStyleType == (byte)MorphFillStyleType.LinearGradientFill ||
         fillStyleType == (byte)MorphFillStyleType.RadialGradientFill)
     {
         if (startGradientMatrix != null)
             startGradientMatrix.WriteTo(writer);
         if (endGradientMatrix != null)
             endGradientMatrix.WriteTo(writer);
         if (gradient != null)
             gradient.WriteTo(writer);
     }
     if (fillStyleType == (byte)MorphFillStyleType.LinearGradientFill ||
         fillStyleType == (byte)MorphFillStyleType.RadialGradientFill ||
         fillStyleType == (byte)MorphFillStyleType.RadialGradientFill ||
         fillStyleType == (byte)MorphFillStyleType.RadialGradientFill)
     {
         writer.Write(this.bitmapId);
         if (startBitmapMatrix != null)
             startBitmapMatrix.WriteTo(writer);
         if (endBitmapMatrix != null)
             endBitmapMatrix.WriteTo(writer);
     }
 }
Ejemplo n.º 22
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, 4);
            rh.WriteTo(w);

            w.Write(characterId);
            w.Write(depth);

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Ejemplo n.º 23
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());

            rh.WriteTo(w);
            w.Write(this.buttonId);
            w.WriteUBits(0, 7);
            w.WriteBoolean(trackAsMenu);
            w.Write(this.actionOffset);
            if (characters != null)
            {
                IEnumerator butts = characters.GetEnumerator();
                while (butts.MoveNext())
                {
                    ((ButtonRecord)butts.Current).WriteTo(w, TagCodeEnum.DefineButton2);
                    w.SynchBits();
                }
            }
            w.Write((byte)0);
            if (actions != null)
            {
                for (int i = 0; i < actions.Count; i++)
                {
                    ButtonCondaction buttCon = actions[i];
                    if (i == actions.Count - 1)
                        w.Write((ushort)0);
                    else
                    {
                        int size = buttCon.GetSizeOf();
                        w.Write((ushort)size);
                    }
                    buttCon.WriteTo(w);
                }
            }

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Writes to.
        /// </summary>
        /// <param name="writer">Writer.</param>
        public void WriteTo(BufferedBinaryWriter writer)
        {
            char[] codes = GetOrderedCodes();
            ShapeRecordCollection[] glyphs = GetOrderedGlyphs(codes);

            ShapeWithStyle.NumFillBits = 0;
            ShapeWithStyle.NumLineBits = 0;

            IEnumerator glyphsEnum = glyphs.GetEnumerator();
            while (glyphsEnum.MoveNext())
            {
                ShapeWithStyle.NumFillBits = 1;
                ((ShapeRecordCollection)glyphsEnum.Current).WriteTo(writer);
            }

            IEnumerator chars = codes.GetEnumerator();
            while (chars.MoveNext())
            {
                char c = (char)chars.Current;
                if (isWideCodes)
                    writer.Write((ushort)c);
                else
                    writer.Write((byte)c);
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Writes to a binary writer.
        /// </summary>
        /// <param name="writer">Writer.</param>
        public void WriteTo(BufferedBinaryWriter writer)
        {
            writer.Write(this.fillStyleType);

            if (fillStyleType == (byte)FillStyleType.SolidFill && rgbColor != null)
                rgbColor.WriteTo(writer);

            if (fillStyleType == (byte)FillStyleType.RadialGradientFill ||
                fillStyleType == (byte)FillStyleType.LinearGradientFill)
            {
                if (gradientMatrix != null)
                    gradientMatrix.WriteTo(writer);
                if (gradient != null)
                    gradient.WriteTo(writer);
            }

            if (fillStyleType == (byte)FillStyleType.RepeatingBitmapFill ||
                fillStyleType == (byte)FillStyleType.ClippedBitmapFill ||
                fillStyleType == (byte)FillStyleType.NonSmoothedClippedBitmap ||
                fillStyleType == (byte)FillStyleType.NonSmoothedRepeatingBitmap)
            {
                writer.Write(this.bitmapId);
                if (this.bitmapMatrix != null)
                    this.bitmapMatrix.WriteTo(writer);
            }
        }
Ejemplo n.º 26
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(characterId);
            w.Write(depth);
            if (this.matrix != null)
                this.matrix.WriteTo(w);
            if (this.colorTransform != null)
                this.colorTransform.WriteTo(w);

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Ejemplo n.º 27
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());

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

            w.SynchBits();
            if (this.startBounds != null)
                this.startBounds.WriteTo(w);
            w.SynchBits();
            if (this.endBounds != null)
                this.endBounds.WriteTo(w);

            w.Write(this.offset);
            if (this.morphFillStyles != null)
                this.morphFillStyles.WriteTo(w);
            if (this.morphLineStyles != null)
                this.morphLineStyles.WriteTo(w);

            ShapeWithStyle.NumFillBits = (uint)morphFillStyles.Count;
            ShapeWithStyle.NumLineBits = (uint)morphLineStyles.Count;

            if (this.startEdges != null)
                this.startEdges.WriteTo(w);
            if (this.endEdges != null)
                this.endEdges.WriteTo(w);

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Ejemplo n.º 28
0
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void UpdateData(byte version)
        {
            if (version < 2)
                return;

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

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

            rh.WriteTo(w);
            w.Write(this.buttonId);

            w.Write(this.buttonSoundChar);
            if (buttonSoundChar != 0 && buttonSoundInfo != null)
                buttonSoundInfo.WriteTo(w);

            w.Write(this.buttonSoundChar1);
            if (buttonSoundChar1 != 0 && buttonSoundInfo1 != null)
                buttonSoundInfo1.WriteTo(w);

            w.Write(this.buttonSoundChar2);
            if (buttonSoundChar2 != 0 && buttonSoundInfo2 != null)
                buttonSoundInfo2.WriteTo(w);

            w.Write(this.buttonSoundChar3);
            if (buttonSoundChar3 != 0 && buttonSoundInfo3 != null)
                buttonSoundInfo3.WriteTo(w);

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Ejemplo n.º 29
0
        /// <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();
        }
Ejemplo n.º 30
0
        /// <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();
        }