Пример #1
0
        internal 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);
                }
            }
        }
Пример #2
0
        internal 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);
        }
Пример #3
0
        internal Rect(SwfReader r)
        {
            r.Align();
            byte minBits = (byte)r.GetBits(5);

            XMin = r.GetSignedNBits(minBits);
            XMax = r.GetSignedNBits(minBits);
            YMin = r.GetSignedNBits(minBits);
            YMax = r.GetSignedNBits(minBits);
            r.Align();
        }
Пример #4
0
        internal 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;
        }
Пример #5
0
        internal 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();
        }
Пример #6
0
        internal 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;
                }
            }
        }