예제 #1
0
        internal SoundStreamHeadTag(SwfReader r)
            : base(TagType.SoundStreamHead2)
        {
            SoundId = soundIdCounter++;

            r.GetBits(4);             // reserved

            PlaybackSoundRate      = rates[r.GetBits(2)];
            PlaybackSoundSize      = r.GetBit() ? 16u : 0u;
            IsStereo               = r.GetBit();
            StreamSoundCompression = (SoundCompressionType)r.GetBits(4);             // Mp3 == 2

            StreamSoundRate = rates[r.GetBits(2)];
            StreamSoundSize = r.GetBit() ? 16u : 8u;
            StreamIsStereo  = r.GetBit();

            r.Align();

            StreamSoundSampleCount = r.GetUI16();

            if (StreamSoundCompression == SoundCompressionType.MP3)
            {
                LatencySeek = r.GetUI16();
            }
        }
예제 #2
0
 internal DefineSpriteTag(SwfReader r, byte swfVersion)
     : base(TagType.DefineSprite)
 {
     this.CharacterId = r.GetUI16();
     this.FrameCount  = r.GetUI16();
     ParseTags(r, swfVersion);
 }
예제 #3
0
 internal PlaceObjectTag(SwfReader r)
     : base(TagType.PlaceObject)
 {
     Character = r.GetUI16();
     Depth     = r.GetUI16();
     Matrix    = new Matrix(r);
 }
예제 #4
0
        internal DefineFunction2(SwfReader r, ConstantPool cp)
        {
            this.cp      = cp;
            FunctionName = r.GetString();
            uint paramCount = r.GetUI16();

            RegisterCount = (uint)r.GetByte();

            Preloads = PreloadFlags.Empty;
            if (r.GetBit())
            {
                Preloads |= PreloadFlags.Parent;
            }
            if (r.GetBit())
            {
                Preloads |= PreloadFlags.Root;
            }

            SuppressSuperFlag = r.GetBit();

            if (r.GetBit())
            {
                Preloads |= PreloadFlags.Super;
            }

            SuppressArgumentsFlag = r.GetBit();

            if (r.GetBit())
            {
                Preloads |= PreloadFlags.Arguments;
            }

            SuppressThisFlag = r.GetBit();

            if (r.GetBit())
            {
                Preloads |= PreloadFlags.This;
            }

            r.GetBits(7);             // reserved

            if (r.GetBit())
            {
                Preloads |= PreloadFlags.Global;
            }

            for (int i = 0; i < paramCount; i++)
            {
                uint   reg  = r.GetByte();
                string name = r.GetString();
                Parameters.Add(reg, name);
            }
            ActionContainer.CodeSize = r.GetUI16();
        }
예제 #5
0
        internal ExportAssetsTag(SwfReader r)
            : base(TagType.ExportAssets)
        {
            uint count = r.GetUI16();

            for (int i = 0; i < count; i++)
            {
                uint   index = r.GetUI16();
                string name  = r.GetString();
                Exports.Add(index, name);
            }
        }
예제 #6
0
        internal PlaceObjectTag(SwfReader r, uint tagEnd)
            : base(TagType.PlaceObject)
        {
            Character = r.GetUI16();
            Depth     = r.GetUI16();
            Matrix    = new Matrix(r);

            if (tagEnd != r.Position)
            {
                HasColorTransform = true;
                ColorTransform    = new ColorTransform(r, false);
            }
        }
예제 #7
0
        internal DefineButtonSound(SwfReader r)
            : base(TagType.DefineButtonSound)
        {
            ButtonId = r.GetUI16();

            ButtonSoundChar0 = r.GetUI16();
            ButtonSoundInfo0 = new SoundInfo(r);
            ButtonSoundChar1 = r.GetUI16();
            ButtonSoundInfo1 = new SoundInfo(r);
            ButtonSoundChar2 = r.GetUI16();
            ButtonSoundInfo2 = new SoundInfo(r);
            ButtonSoundChar3 = r.GetUI16();
            ButtonSoundInfo3 = new SoundInfo(r);
        }
예제 #8
0
        internal DefineFunction(SwfReader r, ConstantPool cp)
        {
            this.cp      = cp;
            FunctionName = r.GetString();
            uint paramCount = r.GetUI16();

            Params = new string[paramCount];
            for (int i = 0; i < paramCount; i++)
            {
                Params[i] = r.GetString();
            }

            CodeSize = r.GetUI16();
        }
예제 #9
0
 internal DefineFontName(SwfReader r)
     : base(TagType.DefineFontName)
 {
     FontID        = r.GetUI16();
     FontName      = r.GetString();
     FontCopyright = r.GetString();
 }
예제 #10
0
        internal LineStyle2(SwfReader r, ShapeType shapeType)
        {
            this.Width            = r.GetUI16();
            this.StartCapStyle    = (CapStyle)r.GetBits(2);
            this.JoinStyle        = (JoinStyle)r.GetBits(2);
            this.HasFillFlag      = r.GetBit();
            this.NoHScaleFlag     = r.GetBit();
            this.NoVScaleFlag     = r.GetBit();
            this.PixelHintingFlag = r.GetBit();
            r.GetBits(5);             // skip
            this.NoClose     = r.GetBit();
            this.EndCapStyle = (CapStyle)r.GetBits(2);

            if (this.JoinStyle == JoinStyle.MiterJoin)
            {
                this.MiterLimitFactor = (float)((r.GetByte() / 0x100) + r.GetByte());
            }

            if (this.HasFillFlag)
            {
                this.FillStyle = FillStyleArray.ParseFillStyle2(r, shapeType);
            }
            else
            {
                this.Color = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte());
            }
        }
예제 #11
0
        internal DefineSoundTag(SwfReader r, uint tagLen)
            : base(TagType.DefineSound)
        {
            SoundId     = r.GetUI16();
            SoundFormat = (SoundCompressionType)r.GetBits(4);
            uint sr = r.GetBits(2);

            switch (sr)
            {
            case 0:
                SoundRate = 5512;                         // ?
                break;

            case 1:
                SoundRate = 11025;
                break;

            case 2:
                SoundRate = 22050;
                break;

            case 3:
                SoundRate = 44100;
                break;
            }
            SoundSize = r.GetBit() ? 16U : 8U;
            IsStereo  = r.GetBit();
            r.Align();

            SoundSampleCount = r.GetUI32();
            // todo: this needs to decompress if mp3 etc
            SoundData = r.GetBytes(tagLen - 7);
        }
예제 #12
0
 internal SwfHeader(SwfReader r)
 {
     this.CompressionMode  = CompressionType.Error;
     this.CompressionRatio = 0;
     //byte[] __signature = r.GetBytes(3);
     this.Signature = r.GetString(3);
     //Signature = r.GetString(3);
     if (Signature == "CWS")
     {
         this.CompressionMode = CompressionType.ZLIB;
         uint __oldSize = r.Size;
         r.DecompressCWSSwf();
         uint __newSize = r.Size;
         this.CompressionRatio = ((double)__oldSize / (double)__newSize) * 100;
     }
     else if (Signature == "ZWS")
     {
         this.CompressionMode = CompressionType.LZMA;
         //r.DecompressZWSSwf
         uint __oldSize = r.Size;
         r.DecompressCWSSwf();
         uint __newSize = r.Size;
         this.CompressionRatio = (double)__oldSize / (double)__newSize;
     }
     else if (Signature == "FWS")
     {
         this.CompressionMode = CompressionType.None;
     }
     if (this.CompressionMode != CompressionType.Error)
     {
         this.Version    = r.GetByte();
         this.FileLength = r.GetUI32();
         this.FrameSize  = new Rect(r);
         UInt16 __frate = r.GetUI16();
         this.FrameRate  = (__frate >> 8) + ((__frate & 0xFF) / 0xFF);
         this.FrameCount = r.GetUI16();
     }
     else
     {
         this.Version    = 0;
         this.FileLength = 0;
         this.FrameSize  = new Rect(0, 0, 0, 0);
         this.FrameRate  = 0;
         this.FrameCount = 0;
     }
 }
예제 #13
0
 internal DefineShapeTag(SwfReader r)
     : base(TagType.DefineShape)
 {
     this.CharacterId = r.GetUI16();
     this.ShapeBounds = new Rect(r);
     this.Shapes      = new ShapeWithStyle(r, ShapeType.DefineShape1);
     r.Align();
 }
예제 #14
0
        internal PlaceObject2Tag(SwfReader r, byte swfVersion)
        {
            tagType           = TagType.PlaceObject2;
            HasClipActions    = r.GetBit();
            HasClipDepth      = r.GetBit();
            HasName           = r.GetBit();
            HasRatio          = r.GetBit();
            HasColorTransform = r.GetBit();
            HasMatrix         = r.GetBit();
            HasCharacter      = r.GetBit();
            Move = r.GetBit();

            Depth = r.GetUI16();

            if (HasCharacter)
            {
                Character = r.GetUI16();
            }
            if (HasMatrix)
            {
                Matrix = new Matrix(r);
            }
            if (HasColorTransform)
            {
                ColorTransform = new ColorTransform(r, true);
            }
            if (HasRatio)
            {
                Ratio = r.GetUI16();
            }
            if (HasName)
            {
                Name = r.GetString();
            }
            if (HasClipDepth)
            {
                ClipDepth = r.GetUI16();
            }

            if (HasClipActions)
            {
                ClipActions = new ClipActions(r, (swfVersion > 5));
            }
        }
예제 #15
0
        internal ConstantPool(SwfReader r)
        {
            uint len = r.GetUI16();

            Constants = new string[len];
            for (int i = 0; i < len; i++)
            {
                Constants[i] = r.GetString();
            }
        }
예제 #16
0
        internal SymbolClassTag(SwfReader r, uint tagLen)
            : base(TagType.SymbolClass)
        {
            TagLen = tagLen;
            Symbols.Clear();
            UInt16 __count = r.GetUI16();

            for (UInt16 __i = 0; __i < __count; __i++)
            {
                uint   __idref = r.GetUI16();
                String __name  = r.GetString();
                if (__idref == 0)
                {
                    this.topLevelClass = __name;
                }
                if (!Symbols.ContainsKey(__name))
                {
                    Symbols.Add(__name, __idref);
                }
            }
        }
예제 #17
0
 internal LineStyle(SwfReader r, bool useAlpha)
 {
     this.Width = r.GetUI16();
     if (useAlpha)
     {
         this.Color = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte());
     }
     else
     {
         this.Color = new RGBA(r.GetByte(), r.GetByte(), r.GetByte());
     }
 }
예제 #18
0
        internal SoundInfo(SwfReader r)
        {
            r.GetBits(2);             // reserved

            IsSyncStop       = r.GetBit();
            IsSyncNoMultiple = r.GetBit();
            HasEnvelope      = r.GetBit();
            HasLoops         = r.GetBit();
            HasOutPoint      = r.GetBit();

            r.Align();
            if (HasInPoint)
            {
                InPoint = r.GetUI32();
            }
            if (HasOutPoint)
            {
                OutPoint = r.GetUI32();
            }
            if (HasLoops)
            {
                LoopCount = r.GetUI16();
            }
            if (HasEnvelope)
            {
                uint count = (uint)r.GetByte();

                uint pos;
                uint left;
                uint right;
                EnvelopeRecords = new SoundEnvelope[count];
                for (int i = 0; i < count; i++)
                {
                    pos   = r.GetUI32();
                    left  = r.GetUI16();
                    right = r.GetUI16();
                    EnvelopeRecords[i] = new SoundEnvelope(pos, left, right);
                }
            }
        }
예제 #19
0
        internal DefineShape4Tag(SwfReader r)
            : base(TagType.DefineShape4)
        {
            this.CharacterId = r.GetUI16();
            this.ShapeBounds = new Rect(r);
            this.EdgeBounds  = new Rect(r);

            r.SkipBits(6);
            this.UsesNonScalingStrokes = r.GetBit();
            this.UsesScalingStrokes    = r.GetBit();
            this.Shapes = new ShapeWithStyle(r, ShapeType.DefineShape4);
            r.Align();
        }
예제 #20
0
        internal SoundStreamBlockTag(SwfReader r, uint tagLen)
            : base(TagType.SoundStreamBlock)
        {
            SampleCount = r.GetUI16();
            SoundData   = r.GetBytes(tagLen - 2);

            // assume mp3 for now
            //SoundData = new Mp3SoundData[SampleCount];
            //for (int i = 0; i < SampleCount; i++)
            //{
            //    SoundData[i] = new Mp3SoundData(r);
            //}
        }
예제 #21
0
        internal LineStyleArray(SwfReader r, ShapeType shapeType)
        {
            int lineCount = (int)r.GetByte();

            if (lineCount == 0xFF)
            {
                lineCount = (int)r.GetUI16();
            }

            for (int i = 0; i < lineCount; i++)
            {
                ParseLineStyle(r, shapeType);
            }
        }
예제 #22
0
        internal CSMTextSettingsTag(SwfReader r)
            : base(TagType.CSMTextSettings)
        {
            TextId       = r.GetUI16();
            UseFlashType = r.GetBits(2);
            GridFit      = r.GetBits(3);
            r.GetBits(3);             // reserved
            r.Align();

            Thickness = r.GetFixedNBits(32);
            Sharpness = r.GetFixedNBits(32);

            r.GetByte();             // reserved
        }
예제 #23
0
        internal FillStyleArray(SwfReader r, ShapeType shapeType)
        {
            int fillCount = (int)r.GetByte();

            if (fillCount == 0xFF)
            {
                fillCount = (int)r.GetUI16();
            }

            for (int i = 0; i < fillCount; i++)
            {
                FillStyles.Add(ParseFillStyle2(r, shapeType));
            }
        }
예제 #24
0
        internal DefineButton2(SwfReader r)
            : base(TagType.DefineButton2)
        {
            ButtonId = r.GetUI16();
            r.GetBits(7);
            TrackAsMenu  = r.GetBit();
            ActionOffset = r.GetUI16();

            while (r.PeekByte() != 0)
            {
                Characters.Add(new ButtonRecord(r, TagType.DefineButton2));
            }
            r.GetByte();// 0, end ButtonRecords

            if (ActionOffset > 0)
            {
                ButtonCondAction bca;
                do
                {
                    bca = new ButtonCondAction(r);
                    ButtonCondActions.Add(bca);
                }while (bca.CondActionSize > 0);
            }
        }
예제 #25
0
 internal GotoFrame2(SwfReader r)
 {
     r.GetBits(6);             // reserved
     SceneBiasFlag = r.GetBit();
     PlayFlag      = r.GetBit();
     r.Align();
     if (SceneBiasFlag)
     {
         SceneBias = r.GetUI16();
     }
     else
     {
         SceneBias = 0;
     }
 }
예제 #26
0
        internal DefineEditTextTag(SwfReader r)
            : base(TagType.DefineEditText)
        {
            CharacterID = r.GetUI16();
            Bounds      = new Rect(r);

            HasText      = r.GetBit();
            WordWrap     = r.GetBit();
            Multiline    = r.GetBit();
            Password     = r.GetBit();
            ReadOnly     = r.GetBit();
            HasTextColor = r.GetBit();
            HasMaxLength = r.GetBit();
            HasFont      = r.GetBit();
            r.GetBit();            // resreved
            AutoSize  = r.GetBit();
            HasLayout = r.GetBit();
            NoSelect  = r.GetBit();
            Border    = r.GetBit();
            r.GetBit();            // resreved
            HTML        = r.GetBit();
            UseOutlines = r.GetBit();

            if (HasFont)
            {
                FontID     = r.GetUI16();
                FontHeight = r.GetUI16();
            }
            if (HasTextColor)
            {
                TextColor = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte());
            }
            if (HasMaxLength)
            {
                MaxLength = r.GetUI16();
            }
            if (HasLayout)
            {
                Align       = (uint)r.GetByte();
                LeftMargin  = r.GetUI16();
                RightMargin = r.GetUI16();
                Indent      = r.GetUI16();
                Leading     = r.GetInt16();
            }
            VariableName = r.GetString();
            if (HasText)
            {
                InitialText = r.GetString();
            }
        }
예제 #27
0
        internal ClipActions(SwfReader r, bool isSwf6Plus)
        {
            r.GetUI16();             // reserved
            ClipEvents        = (ClipEvents)r.GetBits(32);
            ClipActionRecords = new List <ClipActionRecord>();

            bool hasMoreRecords = true;

            while (hasMoreRecords)
            {
                ClipActionRecord car = new ClipActionRecord(r, isSwf6Plus);
                ClipActionRecords.Add(car);
                if ((uint)car.ClipEvents == 0)
                {
                    hasMoreRecords = false;
                }
            }
        }
예제 #28
0
        internal ButtonCondAction(SwfReader r)
        {
            CondActionSize        = r.GetUI16();
            CondIdleToOverDown    = r.GetBit();
            CondOutDownToIdle     = r.GetBit();
            CondOutDownToOverDown = r.GetBit();
            CondOverDownToOutDown = r.GetBit();
            CondOverDownToOverUp  = r.GetBit();
            CondOverUpToOverDown  = r.GetBit();
            CondOverUpToIdle      = r.GetBit();
            CondIdleToOverUp      = r.GetBit();
            CondKeyPress          = r.GetBits(7);
            CondOverDownToIdle    = r.GetBit();

            uint start = r.Position;

            ActionRecords          = new ActionRecords(r, int.MaxValue);
            ActionRecords.CodeSize = r.Position - start;
        }
예제 #29
0
        internal DefineTextTag(SwfReader r, bool useAlpha)
            : base(TagType.DefineText)
        {
            if (useAlpha)
            {
                tagType = TagType.DefineText2;
            }
            CharacterId = r.GetUI16();
            TextBounds  = new Rect(r);
            TextMatrix  = new Matrix(r);
            glyphBits   = (uint)r.GetByte();
            advanceBits = (uint)r.GetByte();

            while (r.PeekByte() != 0x00)
            {
                TextRecords.Add(new TextRecord(r, glyphBits, advanceBits, useAlpha));
            }
            byte end = r.GetByte();
        }
예제 #30
0
 internal DefineShapeTag(SwfReader r, uint tagType)
     : base(tagType)
 {
     this.CharacterId = r.GetUI16();
     this.ShapeBounds = new Rect(r);
     if (tagType == TagType.DefineShape)
     {
         this.Shapes = new ShapeWithStyle(r, ShapeType.DefineShape1);
     }
     else if (tagType == TagType.DefineShape2)
     {
         this.Shapes = new ShapeWithStyle(r, ShapeType.DefineShape2);
     }
     else if (tagType == TagType.DefineShape3)
     {
         this.Shapes = new ShapeWithStyle(r, ShapeType.DefineShape3);
     }
     r.Align();
 }