示例#1
0
        public ShapeRecord(SwfStream swf, bool hasAlpha, bool isExtended, bool extendedStyles, ShapeState state)
        {
            int f0 = 0, f1 = 0, l = 0;

            mFlags = swf.ReadBitUInt(6);

            Type = ConvertType(mFlags);
            switch (Type)
            {
                case ShapeRecordType.StyleChange:
                    {
                        if (NewMoveTo)
                        {
                            int bits = (int)swf.ReadBitUInt(5);
                            MoveDeltaX = swf.ReadBitInt(bits);
                            MoveDeltaY = swf.ReadBitInt(bits);
                        }
                        if (NewFillStyle0) f0 = ((int)swf.ReadBitUInt(state.FillBits));
                        if (NewFillStyle1) f1 = ((int)swf.ReadBitUInt(state.FillBits));
                        if (NewLineStyle) l = ((int)swf.ReadBitUInt(state.LineBits));
                        if (NewStyles && extendedStyles)
                        {
                            state.FillStyles = new FillStyleArray(swf, hasAlpha);
                            state.LineStyles = new LineStyleArray(swf, hasAlpha, isExtended);
                            state.FillBits = (int)swf.ReadBitUInt(4);
                            state.LineBits = (int)swf.ReadBitUInt(4);
                        }
                        if (NewFillStyle0) FillStyle0 = state.GetFill(f0);
                        if (NewFillStyle1) FillStyle1 = state.GetFill(f1);
                        if (NewLineStyle) LineStyle = state.GetLine(l);
                    }
                    break;
                case ShapeRecordType.StraightEdge:
                    {
                        int bits = 2 + (int)(mFlags & 0x0F);
                        bool general = swf.ReadBit();
                        bool vert = general || swf.ReadBit();
                        DrawDeltaX = (general || !vert) ? swf.ReadBitInt(bits) : 0;
                        DrawDeltaY = (general ||  vert) ? swf.ReadBitInt(bits) : 0;
                    }
                    break;
                case ShapeRecordType.CurvedEdge:
                    {
                        int bits = 2 + (int)(mFlags & 0x0F);
                        DrawControlX = swf.ReadBitInt(bits);
                        DrawControlY = swf.ReadBitInt(bits);
                        DrawDeltaX = swf.ReadBitInt(bits);
                        DrawDeltaY = swf.ReadBitInt(bits);
                    }
                    break;
            }
        }
示例#2
0
        public LineStyle(SwfStream swf, bool hasAlpha, bool isExtended, int index)
        {
            Index = index;

            if (isExtended)
            {
                Width = swf.ReadUShort();
                StartCapStyle = ReadCap(swf);
                JoinStyle = ReadJoin(swf);
                HasFill = swf.ReadBit();
                NoHScale = swf.ReadBit();
                NoVScale = swf.ReadBit();
                PixelHinting = swf.ReadBit();

                swf.ReadBitUInt(5); // Reserved

                NoClose = swf.ReadBit();
                EndCapStyle = ReadCap(swf);

                if (JoinStyle == VGLineJoin.Miter)
                    MiterLimit = swf.ReadFixedHalf();

                if (HasFill)
                    Fill = new FillStyle(swf, hasAlpha, -1);
                else
                    Color = swf.ReadRGBA();
            }
            else
            {
                Width = swf.ReadUShort();
                Color = hasAlpha ? swf.ReadRGBA() : swf.ReadRGB();

                StartCapStyle = VGLineCap.Round;
                EndCapStyle = VGLineCap.Round;
                JoinStyle = VGLineJoin.Round;
                HasFill = false;
                NoHScale = false;
                NoVScale = false;
                PixelHinting = false;
                NoClose = false;
                MiterLimit = 1m;
                Fill = null;
            }

            if (Width < 1) Width = 1;
        }