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

            w.AppendString(FunctionName);
            w.AppendUI16((uint)Params.Length);
            for (int i = 0; i < Params.Length; i++)
            {
                w.AppendString(Params[i]);
            }

            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. 2
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. 3
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. 4
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. 5
0
        public void ToSwf(SwfWriter w)
        {
            if (IsCompressed)
            {
                w.AppendByte((byte)'C');
            }
            else
            {
                w.AppendByte((byte)'F');
            }
            w.AppendByte((byte)'W');
            w.AppendByte((byte)'S');

            w.AppendByte(this.Version);

            w.AppendUI32(this.FileLength);
            this.FrameSize.ToSwf(w);

            ushort frateWhole = (ushort)this.FrameRate;
            uint   frateDec   = (((uint)this.FrameRate * 0x100) & 0xFF);

            w.AppendUI16((uint)((frateWhole << 8) + frateDec));

            w.AppendUI16(this.FrameCount);
        }
Esempio n. 6
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. 7
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.WaitForFrame);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendUI16((uint)Frame);
            w.AppendByte((byte)SkipCount);
        }
Esempio n. 8
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.WaitForFrame);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendUI16((uint)Frame);
            w.AppendByte((byte)SkipCount);
        }
Esempio n. 9
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. 10
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. 11
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16((uint)Exports.Count);
            foreach (uint index in Exports.Keys)
            {
                w.AppendUI16(index);
                w.AppendString(Exports[index]);
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
Esempio n. 12
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. 13
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

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

            w.AppendUI16((uint)Exports.Count);
            foreach (uint index in Exports.Keys)
            {
                w.AppendUI16(index);
                w.AppendString(Exports[index]);
            }

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

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

            w.AppendString(Label);
        }
Esempio n. 16
0
        public virtual void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            uint len = (uint)Ids.Length;
            w.AppendUI16(len);

            for (int i = 0; i < len; i++)
            {
                w.AppendUI16(Ids[i]);
                w.AppendString(Names[i]);
            }

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

            w.AppendByte((byte)Register);
        }
Esempio n. 18
0
        public virtual void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

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

            w.AppendUI16(this.Character);
            w.AppendUI16(this.Depth);
            Matrix.ToSwf(w);
            if (HasColorTransform)
            {
                ColorTransform.ToSwf(w, false);
            }

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

            // todo: ctor missing
        }
Esempio n. 20
0
        public void ToSwf(SwfWriter w, bool isSwf6Plus)
        {
            if ((uint)ClipEvents == 0)
            {
                if (isSwf6Plus)
                {
                    w.AppendUI32(0);
                }
                else
                {
                    w.AppendUI16(0);
                }
            }
            else
            {
                w.AppendBits((uint)ClipEvents, 32);

                uint start = (uint)w.Position;
                w.AppendUI32(0);                 // write len after tag written

                if ((ClipEvents & ClipEvents.KeyPress) > 0)
                {
                    w.AppendByte(KeyCode);
                }
                ActionRecords.ToSwf(w);

                uint end = (uint)w.Position;
                w.Position = start;
                w.AppendUI32(end - start - 4);
                w.Position = end;
            }
        }
Esempio n. 21
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.SetTarget);
            w.AppendUI16(Length - 3); // don't incude def byte and len

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

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

            w.AppendUI16(SpriteId);
            w.AppendUI16(FrameCount);

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

            // note: Flash always writes this as a long tag.
            w.ResetLongTagLength(this.TagType, start, true);
        }
Esempio n. 24
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.GoToLabel);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendString(Label);
        }
Esempio n. 25
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.StoreRegister);
            w.AppendUI16(Length - 3); // don't incude this part

            w.AppendByte((byte)Register);
        }
Esempio n. 26
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. 27
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

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

            w.AppendUI16(CharacterId);

            if (!HasAlphaData)
            {
                if (!HasOwnTable)
                {
                    w.AppendByte(0xFF);
                    w.AppendByte(0xD8);

                    w.AppendBytes(JpegData);

                    w.AppendByte(0xFF);
                    w.AppendByte(0xD9);
                }
                else
                {
                    w.AppendBytes(JpegData);
                }
            }
            else
            {
                w.AppendUI32((uint)JpegData.Length);
                w.AppendBytes(JpegData);

                w.AppendBytes(CompressedAlphaData);
            }

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

            w.AppendInt16(BranchOffset);
        }
Esempio n. 29
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.GetURL);
            w.AppendUI16(Length - 3);// don't incude this part

            w.AppendString(UrlString);
            w.AppendString(TargetString);
        }
Esempio n. 30
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.GetURL);
            w.AppendUI16(Length - 3);// don't incude this part

            w.AppendString(UrlString);
            w.AppendString(TargetString);
        }
Esempio n. 31
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. 32
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

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

            w.AppendUI16(SpriteId);
            w.AppendUI16(FrameCount);

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

            // note: Flash always writes this as a long tag.
            w.ResetLongTagLength(this.TagType, start, true);
        }
Esempio n. 33
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. 34
0
        public virtual void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

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

            uint len = (uint)Ids.Length;

            w.AppendUI16(len);

            for (int i = 0; i < len; i++)
            {
                w.AppendUI16(Ids[i]);
                w.AppendString(Names[i]);
            }

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

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

            w.AppendUI16(ButtonId);

            w.AppendUI16(ButtonSoundChar0);
            ButtonSoundInfo0.ToSwf(w);
            w.AppendUI16(ButtonSoundChar1);
            ButtonSoundInfo1.ToSwf(w);
            w.AppendUI16(ButtonSoundChar2);
            ButtonSoundInfo2.ToSwf(w);
            w.AppendUI16(ButtonSoundChar3);
            ButtonSoundInfo3.ToSwf(w);

            w.ResetLongTagLength(this.TagType, start, true);
        }
Esempio n. 36
0
        public void ToSwf(SwfWriter w, bool isSwf6Plus)
        {
            w.AppendUI16(0); // reserved
            w.AppendBits((uint)ClipEvents, 32);

            for (int i = 0; i < ClipActionRecords.Count; i++)
            {
                ClipActionRecords[i].ToSwf(w, isSwf6Plus);
            }
        }
Esempio n. 37
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.Push);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            for (int i = 0; i < Values.Count; i++)
            {
                Values[i].ToSwf(w);
            }
        }
Esempio n. 38
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(ButtonId);
            ButtonColorTransform.ToSwf(w);

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

            w.AppendUI16(SampleCount);
            w.AppendBytes(SoundData);

            w.ResetLongTagLength(this.TagType, start);
        }
Esempio n. 40
0
        public void ToSwf(SwfWriter w, bool isSwf6Plus)
        {
            w.AppendUI16(0);             // reserved
            w.AppendBits((uint)ClipEvents, 32);

            for (int i = 0; i < ClipActionRecords.Count; i++)
            {
                ClipActionRecords[i].ToSwf(w, isSwf6Plus);
            }
        }
Esempio n. 41
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.ConstantPool);

            long lenPos = w.Position;

            w.AppendUI16(0); // length

            w.AppendUI16((uint)Constants.Length);

            for (int i = 0; i < Constants.Length; i++)
            {
                w.AppendString(Constants[i]);
            }
            long temp = w.Position;

            w.Position = lenPos;
            w.AppendUI16((uint)(temp - lenPos - 2)); // skip len bytes
            w.Position = temp;
        }
Esempio n. 42
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

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

            w.AppendUI16(SampleCount);
            w.AppendBytes(SoundData);

            w.ResetLongTagLength(this.TagType, start);
        }
Esempio n. 43
0
        public void ToSwf(SwfWriter w, bool useAlpha)
        {
            w.AppendUI16(this.Width);

            w.AppendByte(Color.R);
            w.AppendByte(Color.G);
            w.AppendByte(Color.B);
            if (useAlpha)
            {
                w.AppendByte(Color.A);
            }
        }
Esempio n. 44
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.Shapes.ToSwf(w, ShapeType.DefineShape3);
            w.Align();

            w.ResetLongTagLength(this.TagType, start, true);
        }
Esempio n. 45
0
        public void ToSwf(SwfWriter w)
        {
            uint len = 12;
            w.AppendTagIDAndLength(this.TagType, len, false);

            w.AppendUI16(TextId);
            w.AppendBits(UseFlashType, 2);
            w.AppendBits(GridFit, 3);
            w.AppendBits(0, 3); // reserved
            w.Align();

            w.AppendFixedNBits(Thickness, 32);
            w.AppendFixedNBits(Sharpness, 32);

            w.AppendByte(0); // reserved
        }
Esempio n. 46
0
        public void ToSwf(SwfWriter w, ShapeType shapeType)
        {
            if (LineStyles.Count > 0xFE)
            {
                w.AppendByte(0xFF);
                w.AppendUI16((uint)LineStyles.Count);
            }
            else
            {
                w.AppendByte((byte)LineStyles.Count);
            }

            bool useAlpha = shapeType > ShapeType.DefineShape2;
            for (int i = 0; i < LineStyles.Count; i++)
            {
                LineStyles[i].ToSwf(w, useAlpha);
            }
        }
Esempio n. 47
0
 public void ToSwf(SwfWriter w)
 {
     w.AppendTagIDAndLength(this.TagType, 2);
     w.AppendUI16(Character);
     w.AppendUI16(Depth);
 }
Esempio n. 48
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(FontId);
            w.AppendBits(CSMTableHint, 2);
            w.AppendBits(0, 6);
            w.Align();

            DefineFont2_3 font = Fonts[FontId];
            uint glyphCount = font.NumGlyphs;

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

            w.ResetLongTagLength(this.TagType, start, true);
        }
Esempio n. 49
0
 public void ToSwf(SwfWriter w, bool useAlpha)
 {
     w.AppendByte((byte)fillType);
     w.AppendUI16(CharacterId);
     Matrix.ToSwf(w);
 }
Esempio n. 50
0
 public void ToSwf(SwfWriter w)
 {
     w.AppendByte((byte)PrimitiveType);
     w.AppendUI16(Constant16Value);
 }
Esempio n. 51
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(ButtonId);

            w.AppendUI16(ButtonSoundChar0);
            ButtonSoundInfo0.ToSwf(w);
            w.AppendUI16(ButtonSoundChar1);
            ButtonSoundInfo1.ToSwf(w);
            w.AppendUI16(ButtonSoundChar2);
            ButtonSoundInfo2.ToSwf(w);
            w.AppendUI16(ButtonSoundChar3);
            ButtonSoundInfo3.ToSwf(w);

            w.ResetLongTagLength(this.TagType, start, true);
        }
Esempio n. 52
0
 public void ToSwf(SwfWriter w)
 {
     w.AppendByte((byte)ActionKind.GotoFrame);
     w.AppendUI16(Length - 3);// don't incude this part
     w.AppendInt16(Frame);
 }
Esempio n. 53
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. 54
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. 55
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. 56
0
        public virtual void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(this.Character);
            w.AppendUI16(this.Depth);
            Matrix.ToSwf(w);
            if (HasColorTransform)
            {
                ColorTransform.ToSwf(w, false);
            }

            w.ResetLongTagLength(this.TagType, start);
        }
Esempio n. 57
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. 58
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.Push);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            for (int i = 0; i < Values.Count; i++)
            {
                Values[i].ToSwf(w);
            }
        }
Esempio n. 59
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(CharacterId);
            w.AppendByte((byte)BitmapFormat);
            w.AppendUI16(Width);
            w.AppendUI16(Height);

            if (BitmapFormat == BitmapFormat.Colormapped8Bit) // 8-bit colormapped image
            {
                w.AppendByte((byte)(ColorCount - 1));

                uint colorBytes = HasAlpha ? (uint)4 : (uint)3;
                uint padWidth = this.Width + (4 - (this.Width % 4));
                uint unzippedSize = (this.ColorCount * colorBytes) + (padWidth * this.Height);

                byte[] mapData = new byte[unzippedSize];

                for (int i = 0; i < this.ColorCount; i++)
                {
                    mapData[i * colorBytes + 0] = ColorTable[i].R;
                    mapData[i * colorBytes + 1] = ColorTable[i].G;
                    mapData[i * colorBytes + 2] = ColorTable[i].B;
                    if (HasAlpha)
                    {
                        mapData[i * colorBytes + 3] = ColorTable[i].A;
                    }
                }

                int index = 0;
                int st = (int)(this.ColorCount * colorBytes);
                for (int i = st; i < unzippedSize; i++)
                {
                    if (((i - st) % padWidth) < this.Width)// exclude padding
                    {
                        mapData[i] = (byte)this.ColorData[index++];
                    }
                    else
                    {
                        mapData[i] = 0;
                    }
                }
                byte[] zipped = SwfWriter.ZipBytes(mapData);
                if(OrgBitmapData != null)
                {
                    w.AppendBytes(OrgBitmapData);
                }
                else
                {
                    w.AppendBytes(zipped);
                }

            }

            else if (BitmapFormat == BitmapFormat.RGB15Bit) // rbg 15
            {
                // todo: find a test file for rgb555
                uint colorBytes = 2;
                uint padWidth = this.Width * colorBytes;
                padWidth += (4 - padWidth) % 4;
                uint unzippedSize = (padWidth * this.Height) * colorBytes;

                byte[] mapData = new byte[unzippedSize];

                int index = 0;
                uint byteCount = padWidth * this.Height;
                for (uint i = 0; i < unzippedSize; i += colorBytes)
                {
                    byte rd = this.BitmapData[index].R;
                    byte gr = this.BitmapData[index].G;
                    byte bl = this.BitmapData[index].B;

                    byte b0 = 0;
                    byte b1 = 0;
                    b0 |= (byte)((rd & 0x7C) << 1);
                    b0 |= (byte)((gr & 0x03) << 6);
                    b1 |= (byte)((gr & 0xE0) >> 2);
                    b1 |= (byte)((bl & 0x1F) << 3);

                    mapData[i + 0] = b0;
                    mapData[i + 1] = b1;

                    index++;
                }
                byte[] zipped = SwfWriter.ZipBytes(mapData);
                if (OrgBitmapData != null)
                {
                    w.AppendBytes(OrgBitmapData);
                }
                else
                {
                    w.AppendBytes(zipped);
                }
            }

            else if (BitmapFormat == BitmapFormat.RGB24Bit) // RGB 24
            {
                uint colorBytes = HasAlpha ? (uint)4 : (uint)3;
                uint unzippedSize = (this.Width * this.Height) * colorBytes;

                byte[] mapData = new byte[unzippedSize];

                int index = 0;
                for (uint i = 0; i < unzippedSize; i += colorBytes)
                {
                    mapData[i + 0] = this.BitmapData[index].A;
                    mapData[i + 1] = this.BitmapData[index].R;
                    mapData[i + 2] = this.BitmapData[index].G;
                    if (HasAlpha)
                    {
                        mapData[i + 3] = this.BitmapData[index].B;
                    }
                    index++;
                }
                byte[] zipped = SwfWriter.ZipBytes(mapData);
                if (OrgBitmapData != null)
                {
                    w.AppendBytes(OrgBitmapData);
                }
                else
                {
                    w.AppendBytes(zipped);
                }
            }

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