Пример #1
0
 /// <summary>
 /// Writes to a binary writer.
 /// </summary>
 /// <param name="writer">Writer.</param>
 public void WriteTo(BufferedBinaryWriter writer)
 {
     writer.WriteUBits(0, 1);
     writer.WriteUBits((uint)red, 5);
     writer.WriteUBits((uint)green, 5);
     writer.WriteUBits((uint)blue, 5);
 }
Пример #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);

            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();
        }
Пример #3
0
		/// <summary>
		/// Writes to.
		/// </summary>
		/// <param name="binaryWriter">Binary writer.</param>
		public void WriteTo(BufferedBinaryWriter binaryWriter)
		{
            binaryWriter.SynchBits();
            bool hasScale = HasScale();
            bool hasRotate = HasRotate();

            binaryWriter.WriteBoolean(hasScale);
            if (hasScale)
            {
                uint nScaleBits = GetScaleBitsNum();
                binaryWriter.WriteUBits(nScaleBits, 5);
                binaryWriter.WriteFBits(matrix[0, 0], nScaleBits);
                binaryWriter.WriteFBits(matrix[1, 1], nScaleBits);
            }

            binaryWriter.WriteBoolean(hasRotate);
            if (hasRotate)
            {
                uint nRotateBits = GetRotateBitsNum();
                binaryWriter.WriteUBits(nRotateBits, 5);
                binaryWriter.WriteFBits(matrix[1, 0], nRotateBits);
                binaryWriter.WriteFBits(matrix[0, 1], nRotateBits);
            }
            
            uint nTranslateBits = GetTranslateBitsNum();
            binaryWriter.WriteUBits(nTranslateBits, 5);
            binaryWriter.WriteSBits((int)matrix[0, 2], nTranslateBits);
            binaryWriter.WriteSBits((int)matrix[1, 2], nTranslateBits);
            binaryWriter.SynchBits();
        }
Пример #4
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();
        }
Пример #5
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.SynchBits();
            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();
        }
Пример #6
0
        /// <summary>
        /// Writes to binary writer.
        /// </summary>
        /// <param name="writer">Writer.</param>
        public void WriteTo(BufferedBinaryWriter writer)
        {
            writer.WriteUBits(0, 2);
            writer.WriteBoolean(syncStop);
            writer.WriteBoolean(syncNoMultiple);
            writer.WriteBoolean(HasEnvelope);
            writer.WriteBoolean(HasLoops);
            writer.WriteBoolean(HasOutPoint);
            writer.WriteBoolean(HasInPoint);

            if (HasInPoint)
            {
                writer.Write(inPoint);
            }
            if (HasOutPoint)
            {
                writer.Write(outPoint);
            }
            if (HasLoops)
            {
                writer.Write(loopCount);
            }

            if (HasEnvelope)
            {
                writer.Write((byte)envelopeRecord.Count);
                IEnumerator envelopes = envelopeRecord.GetEnumerator();
                while (envelopes.MoveNext())
                {
                    ((SoundEnvelope)envelopes.Current).WriteTo(writer);
                }
            }
        }
Пример #7
0
        /// <summary>
        /// Writes to.
        /// </summary>
        /// <param name="writer">Writer.</param>
        public override void WriteTo(BufferedBinaryWriter writer)
        {
            base.WriteTo(writer);
            uint numBits = GetNumBits();

            writer.WriteUBits(numBits - 2, 4);

            bool generalLineFlag = HasGeneralLine();

            writer.WriteBoolean(generalLineFlag);

            if (generalLineFlag)
            {
                writer.WriteSBits(deltaX, numBits);
                writer.WriteSBits(deltaY, numBits);
            }
            else
            {
                bool vertLineFlag = HasVerticalLine();
                writer.WriteBoolean(vertLineFlag);
                if (!vertLineFlag)
                {
                    writer.WriteSBits(deltaX, numBits);
                }
                else
                {
                    writer.WriteSBits(deltaY, numBits);
                }
            }
        }
Пример #8
0
        /// <summary>
        /// Writes to a binary writer.
        /// </summary>
        /// <param name="writer">Writer.</param>
        public void WriteTo(BufferedBinaryWriter writer)
        {
            uint nBits = GetNumBits();

            writer.WriteUBits(nBits, 5);
            writer.WriteSBits(xMin, nBits);
            writer.WriteSBits(xMax, nBits);
            writer.WriteSBits(yMin, nBits);
            writer.WriteSBits(yMax, nBits);
        }
Пример #9
0
        /// <summary>
        /// Writes to a binary writer.
        /// </summary>
        /// <param name="writer">Writer.</param>
        public override void WriteTo(BufferedBinaryWriter writer)
        {
            base.WriteTo(writer);
            uint numBits = GetNumBits();

            writer.WriteUBits(numBits - 2, 4);
            writer.WriteSBits(controlDeltaX, numBits);
            writer.WriteSBits(controlDeltaY, numBits);
            writer.WriteSBits(anchorDeltaX, numBits);
            writer.WriteSBits(anchorDeltaY, numBits);
        }
Пример #10
0
        /// <summary>
        /// Writes to a binary writer.
        /// </summary>
        /// <param name="writer">Writer.</param>
        public void WriteTo(BufferedBinaryWriter writer)
        {
            writer.SynchBits();
            writer.WriteUBits(ShapeWithStyle.NumFillBits, 4);
            writer.WriteUBits(ShapeWithStyle.NumLineBits, 4);

            ShapeRecord lastShape = this.GetLastOne();

            if (lastShape != null && !(lastShape is EndShapeRecord))
            {
                this.Add(new EndShapeRecord());
            }

            IEnumerator shapes = this.GetEnumerator();

            while (shapes.MoveNext())
            {
                ((ShapeRecord)shapes.Current).WriteTo(writer);
            }
        }
Пример #11
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();
        }
Пример #12
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);
                }
            }
        }
Пример #13
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();
        }
Пример #14
0
        /// <summary>
        /// Writes to a binary writer.
        /// </summary>
        /// <param name="writer">Writer.</param>
        /// <param name="buttonType">Button type.</param>
        public void WriteTo(BufferedBinaryWriter writer, TagCodeEnum buttonType)
        {
            writer.WriteUBits(0, 4);
            writer.WriteBoolean(buttonStateHitTest);
            writer.WriteBoolean(buttonStateDown);
            writer.WriteBoolean(buttonStateOver);
            writer.WriteBoolean(buttonStateUp);

            writer.Write(this.characterId);
            writer.Write(this.placeDepth);
            if (placeMatrix != null)
            {
                placeMatrix.WriteTo(writer);
            }
            if (colorTransform != null && buttonType == TagCodeEnum.DefineButton2)
            {
                colorTransform.WriteTo(writer);
            }
        }
Пример #15
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();
        }
Пример #16
0
        /// <summary>
        /// Writes to.
        /// </summary>
        /// <param name="writer">Writer.</param>
        public override void WriteTo(BufferedBinaryWriter writer)
        {
            base.WriteTo(writer);
            bool stateNewStyle   = HasNewStyle();
            bool stateLineStyle  = HasLineStyle();
            bool stateFillStyle0 = HasFillStyle0();
            bool stateFillStyle1 = HasFillStyle1();
            bool stateMoveTo     = HasMoveTo();

            writer.WriteBoolean(stateNewStyle);
            writer.WriteBoolean(stateLineStyle);
            writer.WriteBoolean(stateFillStyle1);
            writer.WriteBoolean(stateFillStyle0);
            writer.WriteBoolean(stateMoveTo);

            if (stateMoveTo)
            {
                uint moveBitsNum = GetMoveNumBits();
                writer.WriteUBits(moveBitsNum, 5);
                writer.WriteSBits(moveDeltaX, moveBitsNum);
                writer.WriteSBits(moveDeltaY, moveBitsNum);
            }

            if (stateFillStyle0)
            {
                writer.WriteUBits((uint)fillStyle0, ShapeWithStyle.NumFillBits);
            }
            if (stateFillStyle1)
            {
                writer.WriteUBits((uint)fillStyle1, ShapeWithStyle.NumFillBits);
            }
            if (stateLineStyle)
            {
                writer.WriteUBits((uint)lineStyle, ShapeWithStyle.NumLineBits);
            }

            if (stateNewStyle)
            {
                fillStyles.WriteTo(writer);
                lineStyles.WriteTo(writer);
                ShapeWithStyle.NumFillBits = BufferedBinaryWriter.GetNumBits((uint)fillStyles.Count);
                ShapeWithStyle.NumLineBits = BufferedBinaryWriter.GetNumBits((uint)lineStyles.Count);
                writer.WriteUBits(ShapeWithStyle.NumFillBits, 4);
                writer.WriteUBits(ShapeWithStyle.NumLineBits, 4);
            }
        }
Пример #17
0
        /// <summary>
        /// Writes to.
        /// </summary>
        /// <param name="writer">Writer.</param>
        public void WriteTo(BufferedBinaryWriter writer)
        {
            writer.SynchBits();
            writer.WriteBoolean(hasAddTerms);
            writer.WriteBoolean(hasMultTerms);
            uint nBits = GetNumBits();

            writer.WriteUBits(nBits, 4);

            if (hasMultTerms)
            {
                writer.WriteSBits(redMultTerms, nBits);
                writer.WriteSBits(greenMultTerms, nBits);
                writer.WriteSBits(blueMultTerms, nBits);
            }
            if (hasAddTerms)
            {
                writer.WriteSBits(redAddTerms, nBits);
                writer.WriteSBits(greenAddTerms, nBits);
                writer.WriteSBits(blueAddTerms, nBits);
            }
            writer.SynchBits();
        }
Пример #18
0
 /// <summary>
 /// Writes to.
 /// </summary>
 /// <param name="writer">Writer.</param>
 public void WriteTo(BufferedBinaryWriter writer)
 {
     writer.WriteUBits(glyphIndex, TextRecordCollection.GLYPH_BITS);
     writer.WriteSBits(glyphAdvance, TextRecordCollection.ADVANCE_BITS);
 }
Пример #19
0
 /// <summary>
 /// Writes to.
 /// </summary>
 /// <param name="writer">Writer.</param>
 public override void WriteTo(BufferedBinaryWriter writer)
 {
     base.WriteTo(writer);
     writer.WriteUBits(0, 5);
 }