Esempio n. 1
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendBits(0, 2); // reserved
            w.AppendBit(IsSyncStop);
            w.AppendBit(IsSyncNoMultiple);
            w.AppendBit(HasEnvelope);
            w.AppendBit(HasLoops);
            w.AppendBit(HasOutPoint);
            w.Align();

            if (HasInPoint)
            {
                w.AppendUI32(InPoint);
            }
            if (HasOutPoint)
            {
                w.AppendUI32(OutPoint);
            }
            if (HasLoops)
            {
                w.AppendUI16(LoopCount);
            }
            if (HasEnvelope)
            {
                w.AppendByte((byte)LoopCount);
                uint count = (uint)EnvelopeRecords.Length;
                for (int i = 0; i < EnvelopeRecords.Length; i++)
                {
                    w.AppendUI32(EnvelopeRecords[i].Pos44);
                    w.AppendUI16(EnvelopeRecords[i].LeftLevel);
                    w.AppendUI16(EnvelopeRecords[i].RightLevel);
                }
            }
        }
Esempio n. 2
0
        public void ToSwf(SwfWriter w, bool useAlpha)
        {
            w.AppendUI16(this.Width);
            w.AppendBits((uint)this.StartCapStyle, 2);
            w.AppendBits((uint)this.JoinStyle, 2);
            w.AppendBit(this.HasFillFlag);
            w.AppendBit(this.NoHScaleFlag);
            w.AppendBit(this.NoVScaleFlag);
            w.AppendBit(this.PixelHintingFlag);
            w.AppendBits(0, 5);
            w.AppendBit(this.NoClose);
            w.AppendBits((uint)this.EndCapStyle, 2);

            if (this.JoinStyle == JoinStyle.MiterJoin)
            {
                w.AppendFixed8_8(this.MiterLimitFactor);
            }

            if (this.HasFillFlag)
            {
                this.FillStyle.ToSwf(w);
            }
            else
            {
                w.AppendByte(Color.R);
                w.AppendByte(Color.G);
                w.AppendByte(Color.B);
                if (useAlpha)
                {
                    w.AppendByte(Color.A);
                }
            }
        }
Esempio n. 3
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendBits(0, 4);
            switch (PlaybackSoundRate)
            {
            case 55000:
                w.AppendBits(0, 2);
                break;

            case 11000:
                w.AppendBits(1, 2);
                break;

            case 22000:
                w.AppendBits(2, 2);
                break;

            case 44000:
                w.AppendBits(3, 2);
                break;
            }
            w.AppendBit(PlaybackSoundSize == 16u);
            w.AppendBit(IsStereo);
            w.AppendBits((uint)StreamSoundCompression, 4);

            switch (StreamSoundRate)
            {
            case 55000:
                w.AppendBits(0, 2);
                break;

            case 11000:
                w.AppendBits(1, 2);
                break;

            case 22000:
                w.AppendBits(2, 2);
                break;

            case 44000:
                w.AppendBits(3, 2);
                break;
            }
            w.AppendBit(StreamSoundSize == 16u);
            w.AppendBit(StreamIsStereo);
            w.Align();

            w.AppendUI16(StreamSoundSampleCount);

            if (StreamSoundCompression == SoundCompressionType.MP3)
            {
                w.AppendUI16(LatencySeek);
            }

            w.ResetLongTagLength(this.TagType, start);
        }
Esempio n. 4
0
        public void ToSwf(SwfWriter w, bool useAlpha)
        {
            w.AppendBit(HasAddTerms);
            w.AppendBit(HasMultTerms);
            uint bits = SwfWriter.MinimumBits(RMultTerm, GMultTerm, BMultTerm, AMultTerm, RAddTerm, GAddTerm, BAddTerm, AAddTerm);

            w.AppendBits(bits, 4);

            if (HasMultTerms)
            {
                w.AppendSignedNBits(RMultTerm, bits);
                w.AppendSignedNBits(GMultTerm, bits);
                w.AppendSignedNBits(BMultTerm, bits);
                if (useAlpha)
                {
                    w.AppendSignedNBits(AMultTerm, bits);
                }
            }
            if (HasAddTerms)
            {
                w.AppendSignedNBits(RAddTerm, bits);
                w.AppendSignedNBits(GAddTerm, bits);
                w.AppendSignedNBits(BAddTerm, bits);
                if (useAlpha)
                {
                    w.AppendSignedNBits(AAddTerm, bits);
                }
            }

            w.Align();
        }
Esempio n. 5
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.GetURL2);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendBits((uint)SendVarsMethod, 2);
            w.AppendBits(0, 4);
            w.AppendBit(TargetIsSprite);
            w.AppendBit(LoadVariables);
            w.Align();
        }
Esempio n. 6
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.GotoFrame2);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendBits(0, 6);
            w.AppendBit(SceneBiasFlag);
            w.AppendBit(PlayFlag);
            w.Align();
            if (SceneBiasFlag)
            {
                w.AppendUI16(SceneBias);
            }
        }
Esempio n. 7
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)NumZoneData);

            w.AppendFixedNBits(AlignmentCoordinate1, 16);
            w.AppendFixedNBits(Range1, 16);
            w.AppendFixedNBits(AlignmentCoordinate2, 16);
            w.AppendFixedNBits(Range2, 16);

            w.AppendBits(0, 6); // reserved
            w.AppendBit(ZoneMaskX);
            w.AppendBit(ZoneMaskY);

            w.Align();
        }
Esempio n. 8
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)NumZoneData);

            w.AppendFixedNBits(AlignmentCoordinate1, 16);
            w.AppendFixedNBits(Range1, 16);
            w.AppendFixedNBits(AlignmentCoordinate2, 16);
            w.AppendFixedNBits(Range2, 16);

            w.AppendBits(0, 6); // reserved
            w.AppendBit(ZoneMaskX);
            w.AppendBit(ZoneMaskY);

            w.Align();
        }
Esempio n. 9
0
        public void ToSwf(SwfWriter w, ref uint fillBits, ref uint lineBits, ShapeType shapeType)
        {
            w.AppendBit(true);
            w.AppendBit(false);

            uint bits = SwfWriter.MinimumBits(ControlX, ControlY, AnchorX, AnchorY);

            bits = bits < 2 ? 2 : bits; // min 2 bits
            w.AppendBits(bits - 2, 4);

            w.AppendSignedNBits(ControlX, bits);
            w.AppendSignedNBits(ControlY, bits);
            w.AppendSignedNBits(AnchorX, bits);
            w.AppendSignedNBits(AnchorY, bits);
        }
Esempio n. 10
0
        public void ToSwf(SwfWriter w, bool isSwf6Plus)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendBit(HasClipActions);
            w.AppendBit(HasClipDepth);
            w.AppendBit(HasName);
            w.AppendBit(HasRatio);
            w.AppendBit(HasColorTransform);
            w.AppendBit(HasMatrix);
            w.AppendBit(HasCharacter);
            w.AppendBit(Move);

            w.AppendUI16(Depth);

            if (HasCharacter)
            {
                w.AppendUI16(Character);
            }
            if (HasMatrix)
            {
                Matrix.ToSwf(w);
            }
            if (HasColorTransform)
            {
                ColorTransform.ToSwf(w, true);
            }
            if (HasRatio)
            {
                w.AppendUI16(Ratio);
            }
            if (HasName)
            {
                w.AppendString(Name);
            }
            if (HasClipDepth)
            {
                w.AppendUI16(ClipDepth);
            }

            if (HasClipActions)
            {
                ClipActions.ToSwf(w, isSwf6Plus);
            }

            //w.ResetLongTagLength(this.TagType, start, true);
            // this may be always long tag?
            if (HasClipActions || HasName)
            {
                w.ResetLongTagLength(this.TagType, start, true); // flash always makes long tags is clip actions are present
            }
            else
            {
                w.ResetLongTagLength(this.TagType, start);
            }
        }
Esempio n. 11
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(ButtonId);
            w.AppendBits(0, 7);
            w.AppendBit(TrackAsMenu);
            w.AppendUI16(ActionOffset); // todo: calc offset

            for (int i = 0; i < Characters.Count; i++)
            {
                Characters[i].ToSwf(w);
            }
            w.AppendByte(0);

            if (ActionOffset > 0)
            {
                ButtonCondActions[ButtonCondActions.Count - 1].CondActionSize = 0;
                for (int i = 0; i < ButtonCondActions.Count; i++)
                {
                    ButtonCondActions[i].ToSwf(w);
                }
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
Esempio n. 12
0
        public void ToSwf(SwfWriter w, uint glyphBits, uint advanceBits, bool hasAlpha)
        {
            w.AppendBit(TextRecordType);
            w.AppendBits(StyleFlagsReserved, 3);
            w.AppendBit(StyleFlagsHasFont);
            w.AppendBit(StyleFlagsHasColor);
            w.AppendBit(StyleFlagsHasYOffset);
            w.AppendBit(StyleFlagsHasXOffset);
            w.Align();

            if (StyleFlagsHasFont)
            {
                w.AppendUI16(FontID);
            }
            if (StyleFlagsHasColor)
            {
                w.AppendByte(TextColor.R);
                w.AppendByte(TextColor.G);
                w.AppendByte(TextColor.B);
                if (hasAlpha)
                {
                    w.AppendByte(TextColor.A);
                }
            }
            if (StyleFlagsHasXOffset)
            {
                w.AppendInt16(XOffset);
            }
            if (StyleFlagsHasYOffset)
            {
                w.AppendInt16(YOffset);
            }
            if (StyleFlagsHasFont)
            {
                w.AppendUI16(TextHeight);
            }

            w.AppendByte((byte)GlyphEntries.Length);

            for (int i = 0; i < GlyphEntries.Length; i++)
            {
                w.AppendBits(GlyphEntries[i].GlyphIndex, glyphBits);
                w.AppendSignedNBits(GlyphEntries[i].GlyphAdvance, advanceBits);
            }
            w.Align();
        }
Esempio n. 13
0
        public void ToSwf(SwfWriter w, ref uint fillBits, ref uint lineBits, ShapeType shapeType)
        {
            w.AppendBit(true);
            w.AppendBit(true);
            uint bits = SwfWriter.MinimumBits(DeltaX, DeltaY);

            bits = bits < 2 ? 2 : bits; // min 2 bits

            w.AppendBits(bits - 2, 4);
            if (DeltaX != 0 && DeltaY != 0)
            {
                w.AppendBit(true);
                w.AppendSignedNBits(DeltaX, bits);
                w.AppendSignedNBits(DeltaY, bits);
            }
            else if (DeltaX == 0)
            {
                w.AppendBit(false);
                w.AppendBit(true);
                w.AppendSignedNBits(DeltaY, bits);
            }
            else
            {
                w.AppendBit(false);
                w.AppendBit(false);
                w.AppendSignedNBits(DeltaX, bits);
            }
        }
Esempio n. 14
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);             // rewrite len after tag

            w.AppendUI16(this.ShapeId);
            this.ShapeBounds.ToSwf(w);
            this.EdgeBounds.ToSwf(w);

            w.AppendBits(0, 6);
            w.AppendBit(this.UsesNonScalingStrokes);
            w.AppendBit(this.UsesScalingStrokes);
            this.Shapes.ToSwf(w, ShapeType.DefineShape4);
            w.Align();

            w.ResetLongTagLength(this.TagType, start, true);
        }
Esempio n. 15
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendUI16(CondActionSize);
            w.AppendBit(CondIdleToOverDown);
            w.AppendBit(CondOutDownToIdle);
            w.AppendBit(CondOutDownToOverDown);
            w.AppendBit(CondOverDownToOutDown);
            w.AppendBit(CondOverDownToOverUp);
            w.AppendBit(CondOverUpToOverDown);
            w.AppendBit(CondOverUpToIdle);
            w.AppendBit(CondIdleToOverUp);
            w.AppendBits(CondKeyPress, 7);
            w.AppendBit(CondOverDownToIdle);

            ActionRecords.ToSwf(w);
        }
Esempio n. 16
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.DefineFunction2);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendString(FunctionName);
            w.AppendUI16((uint)Parameters.Count);
            w.AppendByte((byte)RegisterCount);

            w.AppendBit((Preloads & PreloadFlags.Parent) > 0);
            w.AppendBit((Preloads & PreloadFlags.Root) > 0);
            w.AppendBit(SuppressSuperFlag);
            w.AppendBit((Preloads & PreloadFlags.Super) > 0);
            w.AppendBit(SuppressArgumentsFlag);
            w.AppendBit((Preloads & PreloadFlags.Arguments) > 0);
            w.AppendBit(SuppressThisFlag);
            w.AppendBit((Preloads & PreloadFlags.This) > 0);
            w.AppendBits(0, 7);
            w.AppendBit((Preloads & PreloadFlags.Global) > 0);

            foreach (KeyValuePair <uint, string> d in Parameters)
            {
                w.AppendByte((byte)d.Key);
                w.AppendString(d.Value);
            }

            w.AppendUI16(CodeSize); // temp
            long startPos = w.Position;

            for (int i = 0; i < Statements.Count; i++)
            {
                Statements[i].ToSwf(w);
            }

            // adjust code size
            long curPos = w.Position;

            if (codeSize != (curPos - startPos))
            {
                codeSize   = (uint)(curPos - startPos);
                w.Position = startPos - 2;
                w.AppendUI16(CodeSize); // acutal
                w.Position = curPos;
            }
        }
Esempio n. 17
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendBits(0, 2);
            w.AppendBit(ButtonHasBlendMode);
            w.AppendBit(ButtonHasFilterList);
            w.AppendBit(ButtonStateHitTest);
            w.AppendBit(ButtonStateDown);
            w.AppendBit(ButtonStateOver);
            w.AppendBit(ButtonStateUp);

            w.AppendUI16(CharacterID);
            w.AppendUI16(PlaceDepth);
            PlaceMatrix.ToSwf(w);

            if (containerTag == TagType.DefineButton2)
            {
                ColorTransform.ToSwf(w, true);

                if (ButtonHasFilterList)
                {
                    w.AppendByte((byte)FilterList.Count);
                    for (int i = 0; i < FilterList.Count; i++)
                    {
                        FilterList[i].ToSwf(w);
                    }
                }
                if (ButtonHasBlendMode)
                {
                    w.AppendByte((byte)BlendMode);
                }
            }
        }
Esempio n. 18
0
        public void ToSwf(SwfWriter w)
        {
            bool scale = (this.ScaleX != 1) || (this.ScaleY != 1);

            w.AppendBit(scale);
            if (scale)
            {
                uint bits = SwfWriter.MinimumBits((int)(this.ScaleX * 0x10000), (int)(this.ScaleY * 0x10000));
                w.AppendBits(bits, 5);
                w.AppendFixedNBits(this.ScaleX, bits);
                w.AppendFixedNBits(this.ScaleY, bits);
            }

            bool rotate = (this.Rotate0 != 0) || (this.Rotate1 != 0);

            w.AppendBit(rotate);
            if (rotate)
            {
                uint bits = SwfWriter.MinimumBits((int)(this.Rotate0 * 0x10000), (int)(this.Rotate1 * 0x10000));
                w.AppendBits(bits, 5);
                w.AppendFixedNBits(this.Rotate0, bits);
                w.AppendFixedNBits(this.Rotate1, bits);
            }

            // translate
            uint minbits = 0;

            if (this.TranslateX != 0 || this.TranslateY != 0)
            {
                minbits = SwfWriter.MinimumBits((int)this.TranslateX, (int)this.TranslateY);
            }
            w.AppendBits(minbits, 5);
            w.AppendBits((uint)(this.TranslateX), minbits);
            w.AppendBits((uint)(this.TranslateY), minbits);

            w.Align();
        }
Esempio n. 19
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(SoundId);

            w.AppendBits((uint)SoundFormat, 4);
            switch (SoundRate)
            {
            case 5512:
                w.AppendBits(0, 2);
                break;

            case 11025:
                w.AppendBits(1, 2);
                break;

            case 22050:
                w.AppendBits(2, 2);
                break;

            case 44100:
                w.AppendBits(3, 2);
                break;
            }
            w.AppendBit(SoundSize == 16U);
            w.AppendBit(IsStereo);
            w.Align();

            w.AppendUI32(SoundSampleCount);
            w.AppendBytes(SoundData);

            w.ResetLongTagLength(this.TagType, start);
        }
Esempio n. 20
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(ButtonId);
            w.AppendBits(0, 7);
            w.AppendBit(TrackAsMenu);
            w.AppendUI16(ActionOffset); // todo: calc offset

            for (int i = 0; i < Characters.Count; i++)
            {
                Characters[i].ToSwf(w);
            }
            w.AppendByte(0);

            if(ActionOffset > 0)
            {
                ButtonCondActions[ButtonCondActions.Count - 1].CondActionSize = 0;
                for (int i = 0; i < ButtonCondActions.Count; i++)
                {
                    ButtonCondActions[i].ToSwf(w);
                }
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
Esempio n. 21
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true); // rewrite len after tag

            w.AppendUI16(this.ShapeId);
            this.ShapeBounds.ToSwf(w);
            this.EdgeBounds.ToSwf(w);

            w.AppendBits(0, 6);
            w.AppendBit(this.UsesNonScalingStrokes);
            w.AppendBit(this.UsesScalingStrokes);
            this.Shapes.ToSwf(w, ShapeType.DefineShape4);
            w.Align();

            w.ResetLongTagLength(this.TagType, start, true);
        }
Esempio n. 22
0
        public void ToSwf(SwfWriter w, ref uint fillBits, ref uint lineBits, ShapeType shapeType)
        {
            // TypeFlag				UB[1]	Non-edge record flag. Always 0.
            // StateNewStyles		UB[1]	New styles flag. Used by DefineShape2 and DefineShape3 only.
            // StateLineStyle		UB[1]	Line style change flag.
            // StateFillStyle1		UB[1]	Fill style 1 change flag.
            // StateFillStyle0		UB[1]	Fill style 0 change flag.
            // StateMoveTo			UB[1]	Move to flag.

            if (shapeType == ShapeType.Glyph)
            {
                w.AppendBit(false);
                w.AppendBit(false);   //this.HasNewStyles);

                w.AppendBit(false);   //HasLineStyle);
                w.AppendBit(false);   //HasFillStyle1);
                w.AppendBit(HasFillStyle0);
                w.AppendBit(HasMove); //HasMove);

                if (HasMove)
                {
                    // not relative moves
                    uint bits = SwfWriter.MinimumBits(this.MoveDeltaX, this.MoveDeltaY);
                    w.AppendBits(bits, 5);
                    w.AppendSignedNBits(this.MoveDeltaX, bits);
                    w.AppendSignedNBits(this.MoveDeltaY, bits);
                }

                if (HasFillStyle0)
                {
                    w.AppendBits(this.FillStyle0, fillBits);
                }
            }
            else
            {
                w.AppendBit(false);
                w.AppendBit(this.HasNewStyles);

                w.AppendBit(HasLineStyle);
                w.AppendBit(HasFillStyle1);
                w.AppendBit(HasFillStyle0);
                w.AppendBit(HasMove);

                if (HasMove)
                {
                    uint bits = SwfWriter.MinimumBits(this.MoveDeltaX, this.MoveDeltaY);
                    w.AppendBits(bits, 5);
                    w.AppendSignedNBits(this.MoveDeltaX, bits);
                    w.AppendSignedNBits(this.MoveDeltaY, bits);
                }

                if (HasFillStyle0)
                {
                    w.AppendBits(this.FillStyle0, fillBits);
                }

                if (HasFillStyle1)
                {
                    w.AppendBits(this.FillStyle1, fillBits);
                }

                if (HasLineStyle)
                {
                    w.AppendBits(this.LineStyle, lineBits);
                }

                if (HasNewStyles)
                {
                    w.Align();
                    FillStyles.ToSwf(w, shapeType);
                    LineStyles.ToSwf(w, shapeType);

                    fillBits = SwfWriter.MinimumBits((uint)FillStyles.FillStyles.Count);
                    lineBits = SwfWriter.MinimumBits((uint)LineStyles.LineStyles.Count);;

                    w.AppendBits(fillBits, 4);
                    w.AppendBits(lineBits, 4);
                }
            }
        }
Esempio n. 23
0
        public void ToSwf(SwfWriter w, ref uint fillBits, ref uint lineBits, ShapeType shapeType)
        {
            w.AppendBit(true);
            w.AppendBit(false);

            uint bits = SwfWriter.MinimumBits(ControlX, ControlY, AnchorX, AnchorY);
            bits = bits < 2 ? 2 : bits; // min 2 bits
            w.AppendBits(bits - 2, 4);

            w.AppendSignedNBits(ControlX, bits);
            w.AppendSignedNBits(ControlY, bits);
            w.AppendSignedNBits(AnchorX, bits);
            w.AppendSignedNBits(AnchorY, bits);
        }
Esempio n. 24
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.DefineFunction2);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendString(FunctionName);
            w.AppendUI16((uint)Parameters.Count);
            w.AppendByte((byte)RegisterCount);

            w.AppendBit((Preloads & PreloadFlags.Parent) > 0);
            w.AppendBit((Preloads & PreloadFlags.Root) > 0);
            w.AppendBit(SuppressSuperFlag);
            w.AppendBit((Preloads & PreloadFlags.Super) > 0);
            w.AppendBit(SuppressArgumentsFlag);
            w.AppendBit((Preloads & PreloadFlags.Arguments) > 0);
            w.AppendBit(SuppressThisFlag);
            w.AppendBit((Preloads & PreloadFlags.This) > 0);
            w.AppendBits(0, 7);
            w.AppendBit((Preloads & PreloadFlags.Global) > 0);

            foreach (KeyValuePair<uint, string> d in Parameters)
            {
                w.AppendByte((byte)d.Key);
                w.AppendString(d.Value);
            }

            w.AppendUI16(CodeSize); // temp
            long startPos = w.Position;

            for (int i = 0; i < Statements.Count; i++)
            {
                Statements[i].ToSwf(w);
            }

            // adjust code size
            long curPos = w.Position;
            if (codeSize != (curPos - startPos))
            {
                codeSize = (uint)(curPos - startPos);
                w.Position = startPos - 2;
                w.AppendUI16(CodeSize); // acutal
                w.Position = curPos;
            }
        }
Esempio n. 25
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(CharacterID);
            Bounds.ToSwf(w);

            w.AppendBit(HasText);
            w.AppendBit(WordWrap);
            w.AppendBit(Multiline);
            w.AppendBit(Password);
            w.AppendBit(ReadOnly);
            w.AppendBit(HasTextColor);
            w.AppendBit(HasMaxLength);
            w.AppendBit(HasFont);
            w.AppendBit(false);// resreved
            w.AppendBit(AutoSize);
            w.AppendBit(HasLayout);
            w.AppendBit(NoSelect);
            w.AppendBit(Border);
            w.AppendBit(false);// resreved
            w.AppendBit(HTML);
            w.AppendBit(UseOutlines);

            if (HasFont)
            {
                w.AppendUI16(FontID);
                w.AppendUI16(FontHeight);
            }
            if (HasTextColor)
            {
                w.AppendByte((byte)TextColor.R);
                w.AppendByte((byte)TextColor.G);
                w.AppendByte((byte)TextColor.B);
                w.AppendByte((byte)TextColor.A);
            }
            if (HasMaxLength)
            {
                w.AppendUI16(MaxLength);
            }
            if (HasLayout)
            {
                w.AppendByte((byte)Align);
                w.AppendUI16(LeftMargin);
                w.AppendUI16(RightMargin);
                w.AppendUI16(Indent);
                w.AppendUI16((uint)Leading);
            }

            w.AppendString(VariableName);

            if (HasText)
            {
                w.AppendString(InitialText);
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
Esempio n. 26
0
 public void ToSwf(SwfWriter w, ref uint fillBits, ref uint lineBits, ShapeType shapeType)
 {
     w.AppendBit(false);
     w.AppendBits(0, 5);
 }
Esempio n. 27
0
        public void ToSwf(SwfWriter w, ref uint fillBits, ref uint lineBits, ShapeType shapeType)
        {
            w.AppendBit(true);
            w.AppendBit(true);
            uint bits = SwfWriter.MinimumBits(DeltaX, DeltaY);
            bits = bits < 2 ? 2 : bits; // min 2 bits

            w.AppendBits(bits - 2, 4);
            if (DeltaX != 0 && DeltaY != 0)
            {
                w.AppendBit(true);
                w.AppendSignedNBits(DeltaX, bits);
                w.AppendSignedNBits(DeltaY, bits);
            }
            else if (DeltaX == 0)
            {
                w.AppendBit(false);
                w.AppendBit(true);
                w.AppendSignedNBits(DeltaY, bits);
            }
            else
            {
                w.AppendBit(false);
                w.AppendBit(false);
                w.AppendSignedNBits(DeltaX, bits);
            }
        }
Esempio n. 28
0
 /*
     ENDSHAPERECORD
     Field		Type	Comment
     TypeFlag	UB[1]	Non-edge record flag. Always 0.
     EndOfShape	UB[5]	End of shape flag. Always 0.
  */
 public void ToSwf(SwfWriter w)
 {
     w.AppendBit(false);
     w.AppendBits(0, 5);
 }
Esempio n. 29
0
 public void ToSwf(SwfWriter w, ref uint fillBits, ref uint lineBits, ShapeType shapeType)
 {
     w.AppendBit(false);
     w.AppendBits(0, 5);
 }
Esempio n. 30
0
        public void ToSwf(SwfWriter w, bool useAlpha)
        {
            w.AppendUI16(this.Width);
            w.AppendBits((uint)this.StartCapStyle, 2);
            w.AppendBits((uint)this.JoinStyle, 2);
            w.AppendBit(this.HasFillFlag);
            w.AppendBit(this.NoHScaleFlag);
            w.AppendBit(this.NoVScaleFlag);
            w.AppendBit(this.PixelHintingFlag);
            w.AppendBits(0, 5);
            w.AppendBit(this.NoClose);
            w.AppendBits((uint)this.EndCapStyle, 2);

            if (this.JoinStyle == JoinStyle.MiterJoin)
            {
                w.AppendFixed8_8(this.MiterLimitFactor);
            }

            if (this.HasFillFlag)
            {
                this.FillStyle.ToSwf(w);
            }
            else
            {
                w.AppendByte(Color.R);
                w.AppendByte(Color.G);
                w.AppendByte(Color.B);
                if (useAlpha)
                {
                    w.AppendByte(Color.A);
                }
            }
        }
Esempio n. 31
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(FontId);

            w.AppendBit(FontFlagsHasLayout);
            w.AppendBit(FontFlagsShiftJIS);
            w.AppendBit(FontFlagsSmallText);
            w.AppendBit(FontFlagsANSI);
            w.AppendBit(FontFlagsWideOffsets);
            w.AppendBit(FontFlagsWideCodes);
            w.AppendBit(FontFlagsItalic);
            w.AppendBit(FontFlagsBold);
            w.Align();

            w.AppendByte((byte)LanguageCode);
            w.AppendByte((byte)(FontName.Length + 1)); // add trailing /0
            w.AppendString(FontName, (uint)FontName.Length);

            w.AppendUI16(NumGlyphs);
            for (int i = 0; i < this.NumGlyphs; i++)
            {
                if (this.FontFlagsWideOffsets)
                {
                    w.AppendUI32(this.OffsetTable[i]);
                }
                else
                {
                    w.AppendUI16(this.OffsetTable[i]);
                }
            }

            if (this.FontFlagsWideOffsets)
            {
                w.AppendUI32(this.CodeTableOffset);
            }
            else
            {
                w.AppendUI16(this.CodeTableOffset);
            }

            for (int i = 0; i < this.NumGlyphs; i++)
            {
                GlyphShapeTable[i].ToSwf(w);
            }

            for (int i = 0; i < this.NumGlyphs; i++)
            {
                w.AppendUI16(this.CodeTable[i]);
            }

            if (this.FontFlagsHasLayout)
            {
                w.AppendInt16(FontAscent);
                w.AppendInt16(FontDescent);
                w.AppendInt16(FontLeading);

                for (int i = 0; i < this.NumGlyphs; i++)
                {
                    w.AppendInt16(this.FontAdvanceTable[i]);
                }

                for (int i = 0; i < this.NumGlyphs; i++)
                {
                    this.FontBoundsTable[i].ToSwf(w);
                }

                w.AppendUI16(this.KerningCount);

                if(this.FontFlagsWideCodes)
                {
                    for (int i = 0; i < this.KerningCount; i++)
                    {
                        w.AppendUI16(this.FontKerningTable[i].FontKerningCode1);
                        w.AppendUI16(this.FontKerningTable[i].FontKerningCode2);
                        w.AppendInt16(this.FontKerningTable[i].FontKerningAdjustment);
                    }
                }
                else
                {
                    for (int i = 0; i < this.KerningCount; i++)
                    {
                        w.AppendByte((byte)this.FontKerningTable[i].FontKerningCode1);
                        w.AppendByte((byte)this.FontKerningTable[i].FontKerningCode2);
                        w.AppendInt16(this.FontKerningTable[i].FontKerningAdjustment);
                    }
                }
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
Esempio n. 32
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(CharacterID);
            Bounds.ToSwf(w);

            w.AppendBit(HasText);
            w.AppendBit(WordWrap);
            w.AppendBit(Multiline);
            w.AppendBit(Password);
            w.AppendBit(ReadOnly);
            w.AppendBit(HasTextColor);
            w.AppendBit(HasMaxLength);
            w.AppendBit(HasFont);
            w.AppendBit(false);// resreved
            w.AppendBit(AutoSize);
            w.AppendBit(HasLayout);
            w.AppendBit(NoSelect);
            w.AppendBit(Border);
            w.AppendBit(false);// resreved
            w.AppendBit(HTML);
            w.AppendBit(UseOutlines);

            if (HasFont)
            {
                w.AppendUI16(FontID);
                w.AppendUI16(FontHeight);
            }
            if (HasTextColor)
            {
                w.AppendByte((byte)TextColor.R);
                w.AppendByte((byte)TextColor.G);
                w.AppendByte((byte)TextColor.B);
                w.AppendByte((byte)TextColor.A);
            }
            if (HasMaxLength)
            {
                w.AppendUI16(MaxLength);
            }
            if (HasLayout)
            {
                w.AppendByte((byte)Align);
                w.AppendUI16(LeftMargin);
                w.AppendUI16(RightMargin);
                w.AppendUI16(Indent);
                w.AppendUI16((uint)Leading);
            }

            w.AppendString(VariableName);

            if (HasText)
            {
                w.AppendString(InitialText);
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
Esempio n. 33
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendBits(0, 2); // reserved
            w.AppendBit(IsSyncStop);
            w.AppendBit(IsSyncNoMultiple);
            w.AppendBit(HasEnvelope);
            w.AppendBit(HasLoops);
            w.AppendBit(HasOutPoint);
            w.Align();

            if (HasInPoint)
            {
                w.AppendUI32(InPoint);
            }
            if (HasOutPoint)
            {
                w.AppendUI32(OutPoint);
            }
            if (HasLoops)
            {
                w.AppendUI16(LoopCount);
            }
            if (HasEnvelope)
            {
                w.AppendByte((byte)LoopCount);
                uint count = (uint)EnvelopeRecords.Length;
                for (int i = 0; i < EnvelopeRecords.Length; i++)
                {
                    w.AppendUI32(EnvelopeRecords[i].Pos44);
                    w.AppendUI16(EnvelopeRecords[i].LeftLevel);
                    w.AppendUI16(EnvelopeRecords[i].RightLevel);
                }
            }
        }
Esempio n. 34
0
        public void ToSwf(SwfWriter w)
        {
            bool scale = (this.ScaleX != 1) || (this.ScaleY != 1);
            w.AppendBit(scale);
            if (scale)
            {
                uint bits = SwfWriter.MinimumBits((int)(this.ScaleX * 0x10000), (int)(this.ScaleY * 0x10000));
                w.AppendBits(bits, 5);
                w.AppendFixedNBits(this.ScaleX, bits);
                w.AppendFixedNBits(this.ScaleY, bits);
            }

            bool rotate = (this.Rotate0 != 0) || (this.Rotate1 != 0);
            w.AppendBit(rotate);
            if (rotate)
            {
                uint bits = SwfWriter.MinimumBits((int)(this.Rotate0 * 0x10000), (int)(this.Rotate1 * 0x10000));
                w.AppendBits(bits, 5);
                w.AppendFixedNBits(this.Rotate0, bits);
                w.AppendFixedNBits(this.Rotate1, bits);
            }

            // translate
            uint minbits = 0;
            if (this.TranslateX != 0 || this.TranslateY != 0)
            {
                minbits = SwfWriter.MinimumBits((int)this.TranslateX, (int)this.TranslateY);
            }
            w.AppendBits(minbits, 5);
            w.AppendBits((uint)(this.TranslateX), minbits);
            w.AppendBits((uint)(this.TranslateY), minbits);

            w.Align();
        }
Esempio n. 35
0
        public void ToSwf(SwfWriter w, bool useAlpha)
        {
            w.AppendBit(HasAddTerms);
            w.AppendBit(HasMultTerms);
            uint bits = SwfWriter.MinimumBits(RMultTerm, GMultTerm, BMultTerm, AMultTerm, RAddTerm, GAddTerm, BAddTerm, AAddTerm);
            w.AppendBits(bits, 4);

            if (HasMultTerms)
            {
                w.AppendSignedNBits(RMultTerm, bits);
                w.AppendSignedNBits(GMultTerm, bits);
                w.AppendSignedNBits(BMultTerm, bits);
                if (useAlpha)
                {
                    w.AppendSignedNBits(AMultTerm, bits);
                }
            }
            if (HasAddTerms)
            {
                w.AppendSignedNBits(RAddTerm, bits);
                w.AppendSignedNBits(GAddTerm, bits);
                w.AppendSignedNBits(BAddTerm, bits);
                if (useAlpha)
                {
                    w.AppendSignedNBits(AAddTerm, bits);
                }
            }

            w.Align();
        }
Esempio n. 36
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendBits(0, 4);
            switch (PlaybackSoundRate)
            {
                case 55000:
                    w.AppendBits(0, 2);
                    break;
                case 11000:
                    w.AppendBits(1, 2);
                    break;
                case 22000:
                    w.AppendBits(2, 2);
                    break;
                case 44000:
                    w.AppendBits(3, 2);
                    break;
            }
            w.AppendBit(PlaybackSoundSize == 16u);
            w.AppendBit(IsStereo);
            w.AppendBits((uint)StreamSoundCompression, 4);

            switch (StreamSoundRate)
            {
                case 55000:
                    w.AppendBits(0, 2);
                    break;
                case 11000:
                    w.AppendBits(1, 2);
                    break;
                case 22000:
                    w.AppendBits(2, 2);
                    break;
                case 44000:
                    w.AppendBits(3, 2);
                    break;
            }
            w.AppendBit(StreamSoundSize == 16u);
            w.AppendBit(StreamIsStereo);
            w.Align();

            w.AppendUI16(StreamSoundSampleCount);

            if (StreamSoundCompression == SoundCompressionType.MP3)
            {
                w.AppendUI16(LatencySeek);
            }

            w.ResetLongTagLength(this.TagType, start);
        }
Esempio n. 37
0
        /*
         *      ENDSHAPERECORD
         *      Field		Type	Comment
         *      TypeFlag	UB[1]	Non-edge record flag. Always 0.
         *      EndOfShape	UB[5]	End of shape flag. Always 0.
         */

        public void ToSwf(SwfWriter w)
        {
            w.AppendBit(false);
            w.AppendBits(0, 5);
        }
Esempio n. 38
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(FontId);

            w.AppendBit(FontFlagsHasLayout);
            w.AppendBit(FontFlagsShiftJIS);
            w.AppendBit(FontFlagsSmallText);
            w.AppendBit(FontFlagsANSI);
            w.AppendBit(FontFlagsWideOffsets);
            w.AppendBit(FontFlagsWideCodes);
            w.AppendBit(FontFlagsItalic);
            w.AppendBit(FontFlagsBold);
            w.Align();

            w.AppendByte((byte)LanguageCode);
            w.AppendByte((byte)(FontName.Length + 1)); // add trailing /0
            w.AppendString(FontName, (uint)FontName.Length);

            w.AppendUI16(NumGlyphs);
            for (int i = 0; i < this.NumGlyphs; i++)
            {
                if (this.FontFlagsWideOffsets)
                {
                    w.AppendUI32(this.OffsetTable[i]);
                }
                else
                {
                    w.AppendUI16(this.OffsetTable[i]);
                }
            }


            if (this.FontFlagsWideOffsets)
            {
                w.AppendUI32(this.CodeTableOffset);
            }
            else
            {
                w.AppendUI16(this.CodeTableOffset);
            }

            for (int i = 0; i < this.NumGlyphs; i++)
            {
                GlyphShapeTable[i].ToSwf(w);
            }

            for (int i = 0; i < this.NumGlyphs; i++)
            {
                w.AppendUI16(this.CodeTable[i]);
            }

            if (this.FontFlagsHasLayout)
            {
                w.AppendInt16(FontAscent);
                w.AppendInt16(FontDescent);
                w.AppendInt16(FontLeading);

                for (int i = 0; i < this.NumGlyphs; i++)
                {
                    w.AppendInt16(this.FontAdvanceTable[i]);
                }

                for (int i = 0; i < this.NumGlyphs; i++)
                {
                    this.FontBoundsTable[i].ToSwf(w);
                }

                w.AppendUI16(this.KerningCount);

                if (this.FontFlagsWideCodes)
                {
                    for (int i = 0; i < this.KerningCount; i++)
                    {
                        w.AppendUI16(this.FontKerningTable[i].FontKerningCode1);
                        w.AppendUI16(this.FontKerningTable[i].FontKerningCode2);
                        w.AppendInt16(this.FontKerningTable[i].FontKerningAdjustment);
                    }
                }
                else
                {
                    for (int i = 0; i < this.KerningCount; i++)
                    {
                        w.AppendByte((byte)this.FontKerningTable[i].FontKerningCode1);
                        w.AppendByte((byte)this.FontKerningTable[i].FontKerningCode2);
                        w.AppendInt16(this.FontKerningTable[i].FontKerningAdjustment);
                    }
                }
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
Esempio n. 39
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.GotoFrame2);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendBits(0, 6);
            w.AppendBit(SceneBiasFlag);
            w.AppendBit(PlayFlag);
            w.Align();
            if (SceneBiasFlag)
            {
                w.AppendUI16(SceneBias);
            }
        }
Esempio n. 40
0
        public void ToSwf(SwfWriter w, uint glyphBits, uint advanceBits, bool hasAlpha)
        {
            w.AppendBit(TextRecordType);
            w.AppendBits(StyleFlagsReserved, 3);
            w.AppendBit(StyleFlagsHasFont);
            w.AppendBit(StyleFlagsHasColor);
            w.AppendBit(StyleFlagsHasYOffset);
            w.AppendBit(StyleFlagsHasXOffset);
            w.Align();

            if (StyleFlagsHasFont)
            {
                w.AppendUI16(FontID);
            }
            if (StyleFlagsHasColor)
            {
                w.AppendByte(TextColor.R);
                w.AppendByte(TextColor.G);
                w.AppendByte(TextColor.B);
                if (hasAlpha)
                {
                    w.AppendByte(TextColor.A);
                }
            }
            if (StyleFlagsHasXOffset)
            {
                w.AppendInt16(XOffset);
            }
            if (StyleFlagsHasYOffset)
            {
                w.AppendInt16(YOffset);
            }
            if (StyleFlagsHasFont)
            {
                w.AppendUI16(TextHeight);
            }

            w.AppendByte((byte)GlyphEntries.Length);

            for (int i = 0; i < GlyphEntries.Length; i++)
            {
                w.AppendBits(GlyphEntries[i].GlyphIndex, glyphBits);
                w.AppendSignedNBits(GlyphEntries[i].GlyphAdvance, advanceBits);
            }
            w.Align();
        }
Esempio n. 41
0
        public override void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendBit(HasClipActions);
            w.AppendBit(HasClipDepth);
            w.AppendBit(HasName);
            w.AppendBit(HasRatio);
            w.AppendBit(HasColorTransform);
            w.AppendBit(HasMatrix);
            w.AppendBit(HasCharacter);
            w.AppendBit(Move);

            w.AppendBits(0, 5);             // reserved
            w.AppendBit(PlaceFlagHasCacheAsBitmap);
            w.AppendBit(PlaceFlagHasBlendMode);
            w.AppendBit(PlaceFlagHasFilterList);

            w.AppendUI16(Depth);

            if (HasCharacter)
            {
                w.AppendUI16(Character);
            }
            if (HasMatrix)
            {
                Matrix.ToSwf(w);
            }
            if (HasColorTransform)
            {
                ColorTransform.ToSwf(w, true);
            }
            if (HasRatio)
            {
                w.AppendUI16(Ratio);
            }
            if (HasName)
            {
                w.AppendString(Name);
            }
            if (HasClipDepth)
            {
                w.AppendUI16(ClipDepth);
            }

            if (PlaceFlagHasFilterList)
            {
                w.AppendByte((byte)FilterList.Count);
                for (int i = 0; i < FilterList.Count; i++)
                {
                    FilterList[i].ToSwf(w);
                }
            }
            if (PlaceFlagHasBlendMode)
            {
                w.AppendByte((byte)BlendMode);
            }


            if (HasClipActions)
            {
                //todo: ClipActions = new ClipActions();
            }

            w.ResetLongTagLength(this.TagType, start);
        }
Esempio n. 42
0
        public void ToSwf(SwfWriter w, ref uint fillBits, ref uint lineBits, ShapeType shapeType)
        {
            // TypeFlag				UB[1]	Non-edge record flag. Always 0.
            // StateNewStyles		UB[1]	New styles flag. Used by DefineShape2 and DefineShape3 only.
            // StateLineStyle		UB[1]	Line style change flag.
            // StateFillStyle1		UB[1]	Fill style 1 change flag.
            // StateFillStyle0		UB[1]	Fill style 0 change flag.
            // StateMoveTo			UB[1]	Move to flag.

            if (shapeType == ShapeType.Glyph)
            {
                w.AppendBit(false);
                w.AppendBit(false);//this.HasNewStyles);

                w.AppendBit(false);//HasLineStyle);
                w.AppendBit(false);//HasFillStyle1);
                w.AppendBit(HasFillStyle0);
                w.AppendBit(HasMove);//HasMove);

                if (HasMove)
                {
                    // not relative moves
                    uint bits = SwfWriter.MinimumBits(this.MoveDeltaX, this.MoveDeltaY);
                    w.AppendBits(bits, 5);
                    w.AppendSignedNBits(this.MoveDeltaX, bits);
                    w.AppendSignedNBits(this.MoveDeltaY, bits);
                }

                if (HasFillStyle0)
                {
                    w.AppendBits(this.FillStyle0, fillBits);
                }
            }
            else
            {
                w.AppendBit(false);
                w.AppendBit(this.HasNewStyles);

                w.AppendBit(HasLineStyle);
                w.AppendBit(HasFillStyle1);
                w.AppendBit(HasFillStyle0);
                w.AppendBit(HasMove);

                if (HasMove)
                {
                    uint bits = SwfWriter.MinimumBits(this.MoveDeltaX, this.MoveDeltaY);
                    w.AppendBits(bits, 5);
                    w.AppendSignedNBits(this.MoveDeltaX, bits);
                    w.AppendSignedNBits(this.MoveDeltaY, bits);
                }

                if (HasFillStyle0)
                {
                    w.AppendBits(this.FillStyle0, fillBits);
                }

                if (HasFillStyle1)
                {
                    w.AppendBits(this.FillStyle1, fillBits);
                }

                if (HasLineStyle)
                {
                    w.AppendBits(this.LineStyle, lineBits);
                }

                if (HasNewStyles)
                {
                    w.Align();
                    FillStyles.ToSwf(w, shapeType);
                    LineStyles.ToSwf(w, shapeType);

                    fillBits = SwfWriter.MinimumBits((uint)FillStyles.FillStyles.Count);
                    lineBits = SwfWriter.MinimumBits((uint)LineStyles.LineStyles.Count); ;

                    w.AppendBits(fillBits, 4);
                    w.AppendBits(lineBits, 4);
                }
            }
        }
Esempio n. 43
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.GetURL2);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendBits((uint)SendVarsMethod, 2);
            w.AppendBits(0, 4);
            w.AppendBit(TargetIsSprite);
            w.AppendBit(LoadVariables);
            w.Align();
        }
Esempio n. 44
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendUI16(CondActionSize);
            w.AppendBit(CondIdleToOverDown);
            w.AppendBit(CondOutDownToIdle);
            w.AppendBit(CondOutDownToOverDown);
            w.AppendBit(CondOverDownToOutDown);
            w.AppendBit(CondOverDownToOverUp);
            w.AppendBit(CondOverUpToOverDown);
            w.AppendBit(CondOverUpToIdle);
            w.AppendBit(CondIdleToOverUp);
            w.AppendBits(CondKeyPress, 7);
            w.AppendBit(CondOverDownToIdle);

            ActionRecords.ToSwf(w);
        }
Esempio n. 45
0
        public void ToSwf(SwfWriter w, bool isSwf6Plus)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendBit(HasClipActions);
            w.AppendBit(HasClipDepth);
            w.AppendBit(HasName);
            w.AppendBit(HasRatio);
            w.AppendBit(HasColorTransform);
            w.AppendBit(HasMatrix);
            w.AppendBit(HasCharacter);
            w.AppendBit(Move);

            w.AppendUI16(Depth);

            if (HasCharacter)
            {
                w.AppendUI16(Character);
            }
            if (HasMatrix)
            {
                Matrix.ToSwf(w);
            }
            if (HasColorTransform)
            {
                ColorTransform.ToSwf(w, true);
            }
            if (HasRatio)
            {
                w.AppendUI16(Ratio);
            }
            if (HasName)
            {
                w.AppendString(Name);
            }
            if (HasClipDepth)
            {
                w.AppendUI16(ClipDepth);
            }

            if (HasClipActions)
            {
                ClipActions.ToSwf(w, isSwf6Plus);
            }

            //w.ResetLongTagLength(this.TagType, start, true);
            // this may be always long tag?
            if (HasClipActions || HasName)
            {
                w.ResetLongTagLength(this.TagType, start, true); // flash always makes long tags is clip actions are present
            }
            else
            {
                w.ResetLongTagLength(this.TagType, start);
            }
        }
Esempio n. 46
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(SoundId);

            w.AppendBits((uint)SoundFormat, 4);
            switch (SoundRate)
            {
                case 5512:
                    w.AppendBits(0, 2);
                    break;
                case 11025:
                    w.AppendBits(1, 2);
                    break;
                case 22050:
                    w.AppendBits(2, 2);
                    break;
                case 44100:
                    w.AppendBits(3, 2);
                    break;
            }
            w.AppendBit(SoundSize == 16U);
            w.AppendBit(IsStereo);
            w.Align();

            w.AppendUI32(SoundSampleCount);
            w.AppendBytes(SoundData);

            w.ResetLongTagLength(this.TagType, start);
        }
Esempio n. 47
0
        public override void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendBit(HasClipActions);
            w.AppendBit(HasClipDepth);
            w.AppendBit(HasName);
            w.AppendBit(HasRatio);
            w.AppendBit(HasColorTransform);
            w.AppendBit(HasMatrix);
            w.AppendBit(HasCharacter);
            w.AppendBit(Move);

            w.AppendBits(0, 5); // reserved
            w.AppendBit(PlaceFlagHasCacheAsBitmap);
            w.AppendBit(PlaceFlagHasBlendMode);
            w.AppendBit(PlaceFlagHasFilterList);

            w.AppendUI16(Depth);

            if (HasCharacter)
            {
                w.AppendUI16(Character);
            }
            if (HasMatrix)
            {
                Matrix.ToSwf(w);
            }
            if (HasColorTransform)
            {
                ColorTransform.ToSwf(w, true);
            }
            if (HasRatio)
            {
                w.AppendUI16(Ratio);
            }
            if (HasName)
            {
                w.AppendString(Name);
            }
            if (HasClipDepth)
            {
                w.AppendUI16(ClipDepth);
            }

            if (PlaceFlagHasFilterList)
            {
                w.AppendByte((byte)FilterList.Count);
                for (int i = 0; i < FilterList.Count; i++)
                {
                    FilterList[i].ToSwf(w);
                }
            }
            if (PlaceFlagHasBlendMode)
            {
                w.AppendByte((byte)BlendMode);
            }

            if (HasClipActions)
            {
                //todo: ClipActions = new ClipActions();
            }

            w.ResetLongTagLength(this.TagType, start);
        }