Ejemplo n.º 1
0
        public DefineSoundTag(SwfReader r, uint tagLen)
        {
            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);
        }
Ejemplo n.º 2
0
        public 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());
            }
        }
Ejemplo n.º 3
0
        public 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());
            }
        }
Ejemplo n.º 4
0
        public DefineSoundTag(SwfReader r, uint tagLen)
        {
            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);
        }
Ejemplo n.º 5
0
        public bool TargetIsSprite; // or sprite

        #endregion Fields

        #region Constructors

        public GetURL2(SwfReader r)
        {
            SendVarsMethod = (SendVarsMethod)r.GetBits(2);
            r.GetBits(4); // reserved
            TargetIsSprite = r.GetBit();
            LoadVariables = r.GetBit();
            r.Align();
        }
Ejemplo n.º 6
0
        // only used for glyphs
        public Shape(SwfReader r)
        {
            r.Align();
            fillBits = r.GetBits(4); // always one
            lineBits = r.GetBits(4); // always zero

            ParseShapeRecords(r);
        }
Ejemplo n.º 7
0
 public FilterBlur(SwfReader r)
 {
     BlurX  = r.GetFixed16_16();
     BlurY  = r.GetFixed16_16();
     Passes = r.GetBits(5);
     r.GetBits(3);             // reserved
     r.Align();
 }
Ejemplo n.º 8
0
 public FilterBlur(SwfReader r)
 {
     BlurX = r.GetFixed16_16();
     BlurY = r.GetFixed16_16();
     Passes = r.GetBits(5);
     r.GetBits(3); // reserved
     r.Align();
 }
Ejemplo n.º 9
0
 public GetURL2(SwfReader r)
 {
     SendVarsMethod = (SendVarsMethod)r.GetBits(2);
     r.GetBits(4);             // reserved
     TargetIsSprite = r.GetBit();
     LoadVariables  = r.GetBit();
     r.Align();
 }
Ejemplo n.º 10
0
        // only used for glyphs
        public Shape(SwfReader r)
        {
            r.Align();
            fillBits = r.GetBits(4);             // always one
            lineBits = r.GetBits(4);             // always zero

            ParseShapeRecords(r);
        }
Ejemplo n.º 11
0
        public CSMTextSettingsTag(SwfReader r)
        {
            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
        }
Ejemplo n.º 12
0
        public CSMTextSettingsTag(SwfReader r)
        {
            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
        }
Ejemplo n.º 13
0
        public Gradient(SwfReader r, FillType fillType, bool useAlpha)
        {
            Records       = new List <GradientRecord>();
            this.fillType = fillType;

            GradientMatrix    = new Matrix(r);
            SpreadMode        = (SpreadMode)r.GetBits(2);
            InterpolationMode = (InterpolationMode)(r.GetBits(2) & 1);
            uint numGradients = r.GetBits(4);

            for (int i = 0; i < numGradients; i++)
            {
                Records.Add(new GradientRecord(r, useAlpha));
            }
        }
Ejemplo n.º 14
0
        public FilterGradientGlow(SwfReader r)
        {
            NumColors = (uint)r.GetByte();
            GradientColors = new RGBA[NumColors];
            for (int i = 0; i < NumColors; i++)
            {
                GradientColors[i] = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte());
            }

            GradientRatio = new uint[NumColors];
            for (int i = 0; i < NumColors; i++)
            {
                GradientRatio[i] = (uint)r.GetByte();
            }

            BlurX = r.GetFixed16_16();
            BlurY = r.GetFixed16_16();
            Angle = r.GetFixed16_16();
            Distance = r.GetFixed16_16();
            Strength = r.GetFixed8_8();

            InnerShadow = r.GetBit();
            Knockout = r.GetBit();
            CompositeSource = r.GetBit();
            OnTop = r.GetBit();
            Passes = r.GetBits(4);

            r.Align();
        }
Ejemplo n.º 15
0
        public StraightEdgeRecord(SwfReader r)
        {
            this.DeltaX = 0;
            this.DeltaY = 0;

            uint nbits = r.GetBits(4) + 2;
            bool isGeneralLine = r.GetBit(); // not vertical or horizontal
            if (isGeneralLine)
            {
                DeltaX = r.GetSignedNBits(nbits);
                DeltaY = r.GetSignedNBits(nbits);
            }
            else
            {
                bool isHorz = r.GetBit();
                if (isHorz)
                {
                    DeltaY = r.GetSignedNBits(nbits);
                }
                else
                {
                    DeltaX = r.GetSignedNBits(nbits);
                }
            }
        }
Ejemplo n.º 16
0
        private void ParseShapeRecords(SwfReader r)
        {
            bool hasMoreRecords = true;

            while (hasMoreRecords)
            {
                bool typeFlag = r.GetBit();

                if (typeFlag == false)                 // non edge record
                {
                    uint followFlags = r.GetBits(5);
                    if (followFlags == 0)
                    {
                        ShapeRecords.Add(new EndShapeRecord());
                        hasMoreRecords = false;
                    }
                    else
                    {
                        ShapeRecords.Add(new StyleChangedRecord(r, followFlags, ref fillBits, ref lineBits, shapeType));
                    }
                }
                else                 // edge record
                {
                    bool isStraight = r.GetBit();
                    if (isStraight)
                    {
                        ShapeRecords.Add(new StraightEdgeRecord(r));
                    }
                    else
                    {
                        ShapeRecords.Add(new CurvedEdgeRecord(r));
                    }
                }
            }
        }
Ejemplo n.º 17
0
        public FilterGradientGlow(SwfReader r)
        {
            NumColors      = (uint)r.GetByte();
            GradientColors = new RGBA[NumColors];
            for (int i = 0; i < NumColors; i++)
            {
                GradientColors[i] = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte());
            }

            GradientRatio = new uint[NumColors];
            for (int i = 0; i < NumColors; i++)
            {
                GradientRatio[i] = (uint)r.GetByte();
            }

            BlurX    = r.GetFixed16_16();
            BlurY    = r.GetFixed16_16();
            Angle    = r.GetFixed16_16();
            Distance = r.GetFixed16_16();
            Strength = r.GetFixed8_8();

            InnerShadow     = r.GetBit();
            Knockout        = r.GetBit();
            CompositeSource = r.GetBit();
            OnTop           = r.GetBit();
            Passes          = r.GetBits(4);

            r.Align();
        }
Ejemplo n.º 18
0
        public StraightEdgeRecord(SwfReader r)
        {
            this.DeltaX = 0;
            this.DeltaY = 0;

            uint nbits         = r.GetBits(4) + 2;
            bool isGeneralLine = r.GetBit();             // not vertical or horizontal

            if (isGeneralLine)
            {
                DeltaX = r.GetSignedNBits(nbits);
                DeltaY = r.GetSignedNBits(nbits);
            }
            else
            {
                bool isHorz = r.GetBit();
                if (isHorz)
                {
                    DeltaY = r.GetSignedNBits(nbits);
                }
                else
                {
                    DeltaX = r.GetSignedNBits(nbits);
                }
            }
        }
Ejemplo n.º 19
0
        public ShapeWithStyle(SwfReader r, ShapeType shapeType)
        {
            this.shapeType = shapeType;

            // parse fill defs
            FillStyles = new FillStyleArray(r, shapeType);

            // parse line defs
            LineStyles = new LineStyleArray(r, shapeType);

            r.Align();
            fillBits = r.GetBits(4);
            lineBits = r.GetBits(4);
            r.Align();

            ParseShapeRecords(r);
        }
Ejemplo n.º 20
0
        public ShapeWithStyle(SwfReader r, ShapeType shapeType)
        {
            this.shapeType = shapeType;

            // parse fill defs
            FillStyles = new FillStyleArray(r, shapeType);

            // parse line defs
            LineStyles = new LineStyleArray(r, shapeType);

            r.Align();
            fillBits = r.GetBits(4);
            lineBits = r.GetBits(4);
            r.Align();

            ParseShapeRecords(r);
        }
Ejemplo n.º 21
0
 public Rect(SwfReader r)
 {
     byte minBits = (byte)r.GetBits(5);
     XMin = r.GetSignedNBits(minBits);
     XMax = r.GetSignedNBits(minBits);
     YMin = r.GetSignedNBits(minBits);
     YMax = r.GetSignedNBits(minBits);
     r.Align();
 }
Ejemplo n.º 22
0
        public CurvedEdgeRecord(SwfReader r)
        {
            uint nbits = r.GetBits(4) + 2;

            this.ControlX = r.GetSignedNBits(nbits);
            this.ControlY = r.GetSignedNBits(nbits);
            this.AnchorX = r.GetSignedNBits(nbits);
            this.AnchorY = r.GetSignedNBits(nbits);
        }
Ejemplo n.º 23
0
        public CurvedEdgeRecord(SwfReader r)
        {
            uint nbits = r.GetBits(4) + 2;

            this.ControlX = r.GetSignedNBits(nbits);
            this.ControlY = r.GetSignedNBits(nbits);
            this.AnchorX  = r.GetSignedNBits(nbits);
            this.AnchorY  = r.GetSignedNBits(nbits);
        }
Ejemplo n.º 24
0
        public GlyphEntry[] GlyphEntries;               // GLYPHENTRY[GlyphCount]

        public TextRecord(SwfReader r, uint glyphBits, uint advanceBits, bool hasAlpha)
        {
            TextRecordType       = r.GetBit();
            StyleFlagsReserved   = r.GetBits(3);
            StyleFlagsHasFont    = r.GetBit();
            StyleFlagsHasColor   = r.GetBit();
            StyleFlagsHasYOffset = r.GetBit();
            StyleFlagsHasXOffset = r.GetBit();

            if (StyleFlagsHasFont)
            {
                FontID = r.GetUI16();
            }
            if (StyleFlagsHasColor)
            {
                TextColor = new RGBA(r.GetByte(), r.GetByte(), r.GetByte());
                if (hasAlpha)
                {
                    TextColor.A = r.GetByte();
                }
            }
            if (StyleFlagsHasXOffset)
            {
                XOffset = r.GetInt16();
            }
            if (StyleFlagsHasYOffset)
            {
                YOffset = r.GetInt16();
            }
            if (StyleFlagsHasFont)
            {
                TextHeight = r.GetUI16();
            }

            GlyphCount   = (uint)r.GetByte();
            GlyphEntries = new GlyphEntry[GlyphCount];
            for (int i = 0; i < GlyphCount; i++)
            {
                uint index   = r.GetBits(glyphBits);
                int  advance = r.GetSignedNBits(advanceBits);
                GlyphEntries[i] = new GlyphEntry(index, advance);
            }
            r.Align();//
        }
Ejemplo n.º 25
0
        private bool TextRecordType; // UB[1]

        #endregion Fields

        #region Constructors

        public TextRecord(SwfReader r,  uint glyphBits, uint advanceBits, bool hasAlpha)
        {
            TextRecordType = r.GetBit();
            StyleFlagsReserved = r.GetBits(3);
            StyleFlagsHasFont = r.GetBit();
            StyleFlagsHasColor = r.GetBit();
            StyleFlagsHasYOffset = r.GetBit();
            StyleFlagsHasXOffset = r.GetBit();

            if(StyleFlagsHasFont)
            {
                FontID = r.GetUI16();
            }
            if(StyleFlagsHasColor)
            {
                TextColor = new RGBA(r.GetByte(), r.GetByte(), r.GetByte());
                if(hasAlpha)
                {
                    TextColor.A = r.GetByte();
                }
            }
            if(StyleFlagsHasXOffset)
            {
                XOffset = r.GetInt16();
            }
            if(StyleFlagsHasYOffset)
            {
                YOffset = r.GetInt16();
            }
            if(StyleFlagsHasFont)
            {
                TextHeight = r.GetUI16();
            }

            GlyphCount = (uint)r.GetByte();
            GlyphEntries = new GlyphEntry[GlyphCount];
            for (int i = 0; i < GlyphCount; i++)
            {
                uint index = r.GetBits(glyphBits);
                int advance = r.GetSignedNBits(advanceBits);
                GlyphEntries[i] = new GlyphEntry(index, advance);
            }
            r.Align();//
        }
Ejemplo n.º 26
0
        public Rect(SwfReader r)
        {
            byte minBits = (byte)r.GetBits(5);

            XMin = r.GetSignedNBits(minBits);
            XMax = r.GetSignedNBits(minBits);
            YMin = r.GetSignedNBits(minBits);
            YMax = r.GetSignedNBits(minBits);
            r.Align();
        }
Ejemplo n.º 27
0
        public 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);
            }
            CodeSize = r.GetUI16();
        }
Ejemplo n.º 28
0
        public ClipActionRecord(SwfReader r, bool isSwf6Plus)
        {
            uint highClip    = r.GetBits(16) << 16;
            uint lowClip     = 0;
            bool isEndRecord = false;

            if (highClip == 0)
            {
                if (isSwf6Plus)
                {
                    lowClip = r.GetBits(16);
                    if (lowClip == 0)
                    {
                        ClipEvents       = (ClipEvents)0;
                        ActionRecordSize = 4;
                        isEndRecord      = true;
                    }
                }
                else
                {
                    ClipEvents       = (ClipEvents)0;
                    ActionRecordSize = 2;
                    isEndRecord      = true;
                }
            }
            else
            {
                lowClip = r.GetBits(16);
            }

            if (!isEndRecord)
            {
                ClipEvents       = (ClipEvents)(lowClip | highClip);
                ActionRecordSize = r.GetUI32();
                if ((ClipEvents & ClipEvents.KeyPress) > 0)
                {
                    KeyCode = r.GetByte();
                }
                ActionRecords = new ActionRecords(r, ActionRecordSize);                 // always is init tag?
            }
        }
Ejemplo n.º 29
0
        public 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);
            }
            CodeSize = r.GetUI16();
        }
Ejemplo n.º 30
0
        public Matrix(SwfReader r)
        {
            float sx = 1.0F;
            float sy = 1.0F;
            float r0 = 0.0F;
            float r1 = 0.0F;
            float tx = 0.0F;
            float ty = 0.0F;

            r.Align();
            bool hasScale = r.GetBit();

            if (hasScale)
            {
                uint scaleBits = r.GetBits(5);
                sx = r.GetFixedNBits(scaleBits);
                sy = r.GetFixedNBits(scaleBits);
            }
            bool hasRotate = r.GetBit();

            if (hasRotate)
            {
                uint nRotateBits = r.GetBits(5);
                r0 = r.GetFixedNBits(nRotateBits);
                r1 = r.GetFixedNBits(nRotateBits);
            }
            // always has translation
            uint nTranslateBits = r.GetBits(5);

            tx = r.GetSignedNBits(nTranslateBits);
            ty = r.GetSignedNBits(nTranslateBits);
            r.Align();

            this.ScaleX     = sx;
            this.Rotate0    = r0;
            this.Rotate1    = r1;
            this.ScaleY     = sy;
            this.TranslateX = tx;
            this.TranslateY = ty;
        }
Ejemplo n.º 31
0
        public ClipActionRecord(SwfReader r, bool isSwf6Plus)
        {
            uint highClip = r.GetBits(16) << 16;
            uint lowClip = 0;
            bool isEndRecord = false;
            if (highClip == 0)
            {
                if (isSwf6Plus)
                {
                    lowClip = r.GetBits(16);
                    if (lowClip == 0)
                    {
                        ClipEvents = (ClipEvents)0;
                        ActionRecordSize = 4;
                        isEndRecord = true;
                    }
                }
                else
                {
                    ClipEvents = (ClipEvents)0;
                    ActionRecordSize = 2;
                    isEndRecord = true;
                }
            }
            else
            {
                lowClip = r.GetBits(16);
            }

            if (!isEndRecord)
            {
                ClipEvents = (ClipEvents)(lowClip | highClip);
                ActionRecordSize = r.GetUI32();
                if ((ClipEvents & ClipEvents.KeyPress) > 0)
                {
                    KeyCode = r.GetByte();
                }
                ActionRecords = new ActionRecords(r, ActionRecordSize); // always is init tag?
            }
        }
Ejemplo n.º 32
0
        public ZoneRecord(SwfReader r)
        {
            NumZoneData = r.GetByte();
            AlignmentCoordinate1 = r.GetFixedNBits(16);
            Range1 = r.GetFixedNBits(16);
            AlignmentCoordinate2 = r.GetFixedNBits(16);
            Range2 = r.GetFixedNBits(16);

            r.GetBits(6); // reserved
            ZoneMaskX = r.GetBit();
            ZoneMaskY = r.GetBit();
            r.Align();
        }
Ejemplo n.º 33
0
        public ZoneRecord(SwfReader r)
        {
            NumZoneData          = r.GetByte();
            AlignmentCoordinate1 = r.GetFixedNBits(16);
            Range1 = r.GetFixedNBits(16);
            AlignmentCoordinate2 = r.GetFixedNBits(16);
            Range2 = r.GetFixedNBits(16);

            r.GetBits(6); // reserved
            ZoneMaskX = r.GetBit();
            ZoneMaskY = r.GetBit();
            r.Align();
        }
Ejemplo n.º 34
0
        public SoundStreamHeadTag(SwfReader r)
        {
            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();
            }
        }
Ejemplo n.º 35
0
        public Matrix(SwfReader r)
        {
            float sx = 1.0F;
            float sy = 1.0F;
            float r0 = 0.0F;
            float r1 = 0.0F;
            float tx = 0.0F;
            float ty = 0.0F;
            r.Align();
            bool hasScale = r.GetBit();
            if (hasScale)
            {
                uint scaleBits = r.GetBits(5);
                sx = r.GetFixedNBits(scaleBits);
                sy = r.GetFixedNBits(scaleBits);
            }
            bool hasRotate = r.GetBit();
            if (hasRotate)
            {
                uint nRotateBits = r.GetBits(5);
                r0 = r.GetFixedNBits(nRotateBits);
                r1 = r.GetFixedNBits(nRotateBits);
            }
            // always has translation
            uint nTranslateBits = r.GetBits(5);
            tx = r.GetSignedNBits(nTranslateBits);
            ty = r.GetSignedNBits(nTranslateBits);
            r.Align();

            this.ScaleX = sx;
            this.Rotate0 = r0;
            this.Rotate1 = r1;
            this.ScaleY = sy;
            this.TranslateX = tx;
            this.TranslateY = ty;
        }
Ejemplo n.º 36
0
 public GotoFrame2(SwfReader r)
 {
     r.GetBits(6); // reserved
     SceneBiasFlag = r.GetBit();
     PlayFlag = r.GetBit();
     r.Align();
     if (SceneBiasFlag)
     {
         SceneBias = r.GetUI16();
     }
     else
     {
         SceneBias = 0;
     }
 }
Ejemplo n.º 37
0
        public FilterGlow(SwfReader r)
        {
            GlowColor = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte());

            BlurX    = r.GetFixed16_16();
            BlurY    = r.GetFixed16_16();
            Strength = r.GetFixed8_8();

            InnerGlow       = r.GetBit();
            Knockout        = r.GetBit();
            CompositeSource = r.GetBit();
            Passes          = r.GetBits(5);

            r.Align();
        }
Ejemplo n.º 38
0
        public FilterGlow(SwfReader r)
        {
            GlowColor = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte());

            BlurX = r.GetFixed16_16();
            BlurY = r.GetFixed16_16();
            Strength = r.GetFixed8_8();

            InnerGlow = r.GetBit();
            Knockout = r.GetBit();
            CompositeSource = r.GetBit();
            Passes = r.GetBits(5);

            r.Align();
        }
Ejemplo n.º 39
0
 public GotoFrame2(SwfReader r)
 {
     r.GetBits(6);             // reserved
     SceneBiasFlag = r.GetBit();
     PlayFlag      = r.GetBit();
     r.Align();
     if (SceneBiasFlag)
     {
         SceneBias = r.GetUI16();
     }
     else
     {
         SceneBias = 0;
     }
 }
Ejemplo n.º 40
0
        public 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;
                }
            }
        }
Ejemplo n.º 41
0
        public FilterDropShadow(SwfReader r)
        {
            DropShadowColor = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte());

            BlurX    = r.GetFixed16_16();
            BlurY    = r.GetFixed16_16();
            Angle    = r.GetFixed16_16();
            Distance = r.GetFixed16_16();
            Strength = r.GetFixed8_8();

            InnerShadow     = r.GetBit();
            Knockout        = r.GetBit();
            CompositeSource = r.GetBit();
            Passes          = (uint)r.GetBits(5);

            r.Align();
        }
Ejemplo n.º 42
0
        public FilterDropShadow(SwfReader r)
        {
            DropShadowColor = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte());

            BlurX = r.GetFixed16_16();
            BlurY = r.GetFixed16_16();
            Angle = r.GetFixed16_16();
            Distance = r.GetFixed16_16();
            Strength = r.GetFixed8_8();

            InnerShadow = r.GetBit();
            Knockout = r.GetBit();
            CompositeSource = r.GetBit();
            Passes = (uint)r.GetBits(5);

            r.Align();
        }
Ejemplo n.º 43
0
        public DefineFontAlignZonesTag(SwfReader r, Dictionary <uint, DefineFont2_3> fonts)
        {
            Fonts = fonts;

            FontId       = r.GetUI16();
            CSMTableHint = r.GetBits(2);
            r.SkipBits(6);
            r.Align();

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

            ZoneTable = new ZoneRecord[glyphCount];
            for (int i = 0; i < glyphCount; i++)
            {
                ZoneTable[i] = new ZoneRecord(r);
            }
        }
Ejemplo n.º 44
0
        public 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;
                }
            }
        }
Ejemplo n.º 45
0
        public 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;
        }
Ejemplo n.º 46
0
        public DefineFontAlignZonesTag(SwfReader r, Dictionary<uint, DefineFont2_3> fonts)
        {
            Fonts = fonts;

            FontId = r.GetUI16();
            CSMTableHint = r.GetBits(2);
            r.SkipBits(6);
            r.Align();

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

            ZoneTable = new ZoneRecord[glyphCount];
            for (int i = 0; i < glyphCount; i++)
            {
                ZoneTable[i] = new ZoneRecord(r);
            }
        }
Ejemplo n.º 47
0
        public FilterBevel(SwfReader r)
        {
            ShadowColor = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte());
            HighlightColor = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte());

            BlurX = r.GetFixed16_16();
            BlurY = r.GetFixed16_16();
            Angle = r.GetFixed16_16();
            Distance = r.GetFixed16_16();
            Strength = r.GetFixed8_8();

            InnerShadow = r.GetBit();
            Knockout = r.GetBit();
            CompositeSource = r.GetBit();
            OnTop = r.GetBit();
            Passes = r.GetBits(4);

            r.Align();
        }
Ejemplo n.º 48
0
        public 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;
        }
Ejemplo n.º 49
0
        public FilterBevel(SwfReader r)
        {
            ShadowColor    = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte());
            HighlightColor = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte());

            BlurX    = r.GetFixed16_16();
            BlurY    = r.GetFixed16_16();
            Angle    = r.GetFixed16_16();
            Distance = r.GetFixed16_16();
            Strength = r.GetFixed8_8();

            InnerShadow     = r.GetBit();
            Knockout        = r.GetBit();
            CompositeSource = r.GetBit();
            OnTop           = r.GetBit();
            Passes          = r.GetBits(4);

            r.Align();
        }
Ejemplo n.º 50
0
        public 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);
                }
            }
        }
Ejemplo n.º 51
0
        public 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);
                }
            }
        }
Ejemplo n.º 52
0
        public FilterConvolution(SwfReader r)
        {
            MatrixX = (uint)r.GetByte();
            MatrixY = (uint)r.GetByte();
            Divisor = r.GetFloat32();
            Bias = r.GetFloat32();

            uint mxCount = MatrixX * MatrixY;
            Matrix = new float[mxCount];
            for (int i = 0; i < mxCount; i++)
            {
                Matrix[i] = r.GetFloat32();
            }

            DefaultColor = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte());

            r.GetBits(6);
            Clamp = r.GetBit();
            PreserveAlpha = r.GetBit();

            r.Align();
        }
Ejemplo n.º 53
0
        public FilterConvolution(SwfReader r)
        {
            MatrixX = (uint)r.GetByte();
            MatrixY = (uint)r.GetByte();
            Divisor = r.GetFloat32();
            Bias    = r.GetFloat32();

            uint mxCount = MatrixX * MatrixY;

            Matrix = new float[mxCount];
            for (int i = 0; i < mxCount; i++)
            {
                Matrix[i] = r.GetFloat32();
            }

            DefaultColor = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte());

            r.GetBits(6);
            Clamp         = r.GetBit();
            PreserveAlpha = r.GetBit();

            r.Align();
        }
Ejemplo n.º 54
0
        public DefineButton2(SwfReader r)
        {
            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);
            }
        }
Ejemplo n.º 55
0
        public void ParseShapeRecords(SwfReader r)
        {
            bool hasMoreRecords = true;
            while (hasMoreRecords)
            {
                bool typeFlag = r.GetBit();

                if (typeFlag == false) // non edge record
                {
                    uint followFlags = r.GetBits(5);
                    if (followFlags == 0)
                    {
                        ShapeRecords.Add(new EndShapeRecord());
                        hasMoreRecords = false;
                    }
                    else
                    {
                        StyleChangedRecord scr = new StyleChangedRecord(r, followFlags, ref fillBits, ref lineBits, ShapeType.Glyph);
                        ShapeRecords.Add(scr);
                    }
                }
                else // edge record
                {
                    bool isStraight = r.GetBit();
                    if (isStraight)
                    {
                        StraightEdgeRecord ser = new StraightEdgeRecord(r);
                        ShapeRecords.Add(ser);
                    }
                    else
                    {
                        CurvedEdgeRecord cer = new CurvedEdgeRecord(r);
                        ShapeRecords.Add(cer);
                    }
                }
            }
        }
Ejemplo n.º 56
0
        public DefineButton2(SwfReader r)
        {
            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);
            }
        }
Ejemplo n.º 57
0
        public ColorTransform(SwfReader r, bool useAlpha)
        {
            this.HasAddTerms = r.GetBit();
            this.HasMultTerms = r.GetBit();
            uint nbits = r.GetBits(4);

            if (HasMultTerms)
            {
                RMultTerm = r.GetSignedNBits(nbits);
                GMultTerm = r.GetSignedNBits(nbits);
                BMultTerm = r.GetSignedNBits(nbits);
                AMultTerm = (useAlpha) ? r.GetSignedNBits(nbits) : 0xFF;
            }
            else
            {
                RMultTerm = 0;
                GMultTerm = 0;
                BMultTerm = 0;
                AMultTerm = 0;
            }
            if (HasAddTerms)
            {
                RAddTerm = r.GetSignedNBits(nbits);
                GAddTerm = r.GetSignedNBits(nbits);
                BAddTerm = r.GetSignedNBits(nbits);
                AAddTerm = (useAlpha) ? r.GetSignedNBits(nbits) : 0xFF;
            }
            else
            {
                RAddTerm = 0;
                GAddTerm = 0;
                BAddTerm = 0;
                AAddTerm = 0;
            }
            r.Align();
        }
Ejemplo n.º 58
0
        public ColorTransform(SwfReader r, bool useAlpha)
        {
            this.HasAddTerms  = r.GetBit();
            this.HasMultTerms = r.GetBit();
            uint nbits = r.GetBits(4);

            if (HasMultTerms)
            {
                RMultTerm = r.GetSignedNBits(nbits);
                GMultTerm = r.GetSignedNBits(nbits);
                BMultTerm = r.GetSignedNBits(nbits);
                AMultTerm = (useAlpha) ? r.GetSignedNBits(nbits) : 0xFF;
            }
            else
            {
                RMultTerm = 0;
                GMultTerm = 0;
                BMultTerm = 0;
                AMultTerm = 0;
            }
            if (HasAddTerms)
            {
                RAddTerm = r.GetSignedNBits(nbits);
                GAddTerm = r.GetSignedNBits(nbits);
                BAddTerm = r.GetSignedNBits(nbits);
                AAddTerm = (useAlpha) ? r.GetSignedNBits(nbits) : 0xFF;
            }
            else
            {
                RAddTerm = 0;
                GAddTerm = 0;
                BAddTerm = 0;
                AAddTerm = 0;
            }
            r.Align();
        }
Ejemplo n.º 59
0
        public StyleChangedRecord(SwfReader r, uint flags, ref uint fillBits, ref uint lineBits, ShapeType shapeType)
        {
            MoveDeltaX = 0;
            MoveDeltaY = 0;
            FillStyle1 = 0;
            FillStyle0 = 0;
            LineStyle = 0;

            HasNewStyles    = (flags & 0x10) != 0;
            HasLineStyle    = (flags & 0x08) != 0;
            HasFillStyle1   = (flags & 0x04) != 0;
            HasFillStyle0   = (flags & 0x02) != 0;
            HasMove         = (flags & 0x01) != 0;

            if (shapeType == ShapeType.Glyph) // glyphs really should be a different style changed record imo : )
            {
                if (HasMove)
                {
                    uint moveBits = r.GetBits(5);
                    this.MoveDeltaX = r.GetSignedNBits(moveBits);
                    this.MoveDeltaY = r.GetSignedNBits(moveBits);
                }

                if (HasFillStyle0)
                {
                    this.FillStyle0 = r.GetBits(fillBits);
                }
            }
            else
            {
                if (HasMove)
                {
                    uint moveBits = r.GetBits(5);
                    this.MoveDeltaX = r.GetSignedNBits(moveBits);
                    this.MoveDeltaY = r.GetSignedNBits(moveBits);
                }
                if (HasFillStyle0)
                {
                    this.FillStyle0 = r.GetBits(fillBits);
                }

                if (HasFillStyle1)
                {
                    this.FillStyle1 = r.GetBits(fillBits);
                }

                if (HasLineStyle)
                {
                    this.LineStyle = r.GetBits(lineBits);
                }

                //r.Align();

                if (HasNewStyles)
                {
                    FillStyles = new FillStyleArray(r, shapeType);
                    LineStyles = new LineStyleArray(r, shapeType);
                    fillBits = r.GetBits(4);
                    lineBits = r.GetBits(4);
                }
                else
                {
                    FillStyles = new FillStyleArray();
                    LineStyles = new LineStyleArray();
                    HasNewStyles = false;
                }
            }
        }
Ejemplo n.º 60
0
        public SoundStreamHeadTag(SwfReader r)
        {
            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();
            }
        }