Flush() публичный Метод

Flushes this instance.
public Flush ( ) : void
Результат void
Пример #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();
        }
Пример #2
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);

            int length = 0;
            if (soundData != null)
                length += soundData.Length;
            RecordHeader rh = new RecordHeader(TagCode, length);
            rh.WriteTo(w);

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

            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)
        {
            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();
        }
Пример #4
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();
        }
Пример #5
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();
        }
Пример #6
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();
        }
        /// <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();
        }
Пример #8
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.fontId);

            //TODO: calcule offset !!
            if (offsetTable != null)
            {
                IEnumerator offsets = offsetTable.GetEnumerator();
                while (offsets.MoveNext())
                    w.Write((ushort)offsets.Current);
            }

            ShapeWithStyle.NumFillBits = 0;
            ShapeWithStyle.NumLineBits = 0;
            glyphShapesTable.WriteTo(w);

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Пример #9
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((ushort)0);
            if (password != null)
                w.Write(this.Password);

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Пример #10
0
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void UpdateData(byte version)
        {
            if (version < this.versionCompatibility)
                return;

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

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

            w.Write(this.shapeId);
            rect.WriteTo(w);
            shape.WriteTo(w);

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Пример #11
0
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void UpdateData(byte version)
        {
            if (version < VersionCompatibility)
                return;

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

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

            w.Write(this.characterId);
            if (rect != null)
                rect.WriteTo(w);
            if (matrix != null)
                matrix.WriteTo(w);

            w.Write(TextRecordCollection.GLYPH_BITS);
            w.Write(TextRecordCollection.ADVANCE_BITS);

            if (textRecords != null)
            {
                IEnumerator records = textRecords.GetEnumerator();
                while (records.MoveNext())
                    ((TextRecord)records.Current).WriteTo(w);
            }
            w.Write((byte)0);

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Пример #12
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);

            int lenght = 2 + url.Length;
            if (exportedCharacters != null)
                lenght += Assert.GetSizeOf(exportedCharacters);

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

            w.Write(url);
            w.Write((ushort)exportedCharacters.Count);

            IEnumerator asserts = exportedCharacters.GetEnumerator();
            while (asserts.MoveNext())
            {
                Assert assert = (Assert)asserts.Current;
                assert.WriteTo(w);
            }

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Пример #13
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.streamId);
            w.Write(this.frameNum);
            if (video != null)
                video.WriteTo(w);

            // write to data array
            w.Flush();
            _data = m.ToArray();
        }
Пример #14
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);
            if (buttonColorTransform != null)
                buttonColorTransform.WriteTo(w);

            w.Flush();
            // write to data array
            _data = m.ToArray();
        }
Пример #15
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();
        }
Пример #16
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();
        }
Пример #17
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();
        }
Пример #18
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();
        }
Пример #19
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();
        }
Пример #20
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();
        }
Пример #21
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();
        }
Пример #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, 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();
        }
Пример #23
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();
        }
Пример #24
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();
        }
Пример #25
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();
        }
Пример #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(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();
        }
Пример #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();
        }
Пример #28
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();
        }
Пример #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();
        }
Пример #30
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();
        }