Beispiel #1
0
        private MorphGradientRecord ReadMorphGradientRecord(SWFDataTypeReader shapeReader)
        {
            MorphGradientRecord mgr = new MorphGradientRecord();

            mgr.StartRatio  = shapeReader.ReadUI8();
            mgr.StartColour = shapeReader.ReadRGBA();
            mgr.EndRatio    = shapeReader.ReadUI8();
            mgr.EndColour   = shapeReader.ReadRGBA();
            return(mgr);
        }
Beispiel #2
0
        private LineStyle[] ReadLineStyleArray(SWFDataTypeReader shapeReader, Tag format)
        {
            int lineCount = shapeReader.ReadUI8();

            if (lineCount == 0xFF)
            {
                lineCount = shapeReader.ReadUI16();
            }

            LineStyle[] lineStyles = new LineStyle[lineCount];
            if (format == Tag.DefineShape4)
            {
                for (int i = 0; i < lineCount; i++)
                {
                    lineStyles[i] = this.ReadLineStyle2(shapeReader, format);
                }
            }
            else
            {
                for (int i = 0; i < lineCount; i++)
                {
                    lineStyles[i] = this.ReadLineStyle(shapeReader, format);
                }
            }

            return(lineStyles);
        }
Beispiel #3
0
        private MorphLineStyle[] ReadMorphLineStyleArray(SWFDataTypeReader shapeReader, Tag format)
        {
            int lineCount = shapeReader.ReadUI8();

            if (lineCount == 0xFF)
            {
                lineCount = shapeReader.ReadUI16();
            }

            MorphLineStyle[] lineStyles = new MorphLineStyle[lineCount];
            if (format == Tag.DefineMorphShape)
            {
                for (int i = 0; i < lineCount; i++)
                {
                    lineStyles[i] = this.ReadMorphLineStyle(shapeReader);
                }
            }
            else /* Else Tag.DefineMorphShape2 */
            {
                for (int i = 0; i < lineCount; i++)
                {
                    lineStyles[i] = this.ReadMorphLineStyle2(shapeReader);
                }
            }

            return(lineStyles);
        }
Beispiel #4
0
        private FillStyle ReadFillStyle(SWFDataTypeReader shapeReader, Tag format)
        {
            FillStyle style = new FillStyle();

            style.Type = (FillType)shapeReader.ReadUI8();

            if (style.Type == FillType.Solid)
            {
                if (format == Tag.DefineShape3 || format == Tag.DefineShape4) /* Assuming shape4 goes here. Spec is ambiguous. */
                {
                    style.Colour = shapeReader.ReadRGBA();
                }
                else if (format == Tag.DefineShape || format == Tag.DefineShape2)
                {
                    style.Colour = shapeReader.ReadRGB();
                }
                else
                {
                    throw new SWFModellerException(SWFModellerError.SWFParsing, "Bad tag format for fill style");
                }
            }

            if (style.Type == FillType.LinearGradient ||
                style.Type == FillType.RadialGradient ||
                style.Type == FillType.FocalGradient)
            {
                style.FillMatrix = shapeReader.ReadMatrix();
                shapeReader.Align8();

                if (style.Type == FillType.LinearGradient ||
                    style.Type == FillType.RadialGradient)
                {
                    style.Gradient = this.ReadGradient(shapeReader, format);
                }
                else /* FocalGradient */
                {
                    style.Gradient = this.ReadFocalGradient(shapeReader);
                }
            }

            if (FillTypes.IsBitmap(style.Type))
            {
                int cid = shapeReader.ReadUI16();

                /* Some fills have this magic number in them which seems to deliberately not
                 * reference a bitmap. The spec is silent on the matter. Oh flash, you
                 * stammering ape. */
                if (cid != 0x0000FFFF)
                {
                    style.Bitmap = this.ImageFinder.FindImage(cid);
                }

                style.FillMatrix = shapeReader.ReadMatrix();
                shapeReader.Align8();
            }

            return(style);
        }
Beispiel #5
0
        private MorphFillStyle ReadMorphFillStyle(SWFDataTypeReader shapeReader)
        {
            MorphFillStyle style = new MorphFillStyle();

            style.Type = (FillType)shapeReader.ReadUI8();

            if (style.Type == FillType.Solid)
            {
                style.StartColour = shapeReader.ReadRGBA();
                style.EndColour   = shapeReader.ReadRGBA();
            }

            if (style.Type == FillType.LinearGradient ||
                style.Type == FillType.RadialGradient)
            {
                style.StartFillMatrix = shapeReader.ReadMatrix();
                shapeReader.Align8();

                style.EndFillMatrix = shapeReader.ReadMatrix();
                shapeReader.Align8();

                if (style.Type == FillType.LinearGradient ||
                    style.Type == FillType.RadialGradient)
                {
                    style.Gradient = this.ReadMorphGradient(shapeReader);
                }
            }

            if (FillTypes.IsBitmap(style.Type))
            {
                int cid = shapeReader.ReadUI16();

                /* Some fills have this magic number in them which seems to deliberately not
                 * reference a bitmap. The spec is silent on the matter. Oh flash, you
                 * bumbling simian. */
                if (cid != 0x0000FFFF)
                {
                    style.Bitmap = this.ImageFinder.FindImage(cid);
                }

                style.StartFillMatrix = shapeReader.ReadMatrix();
                shapeReader.Align8();

                style.EndFillMatrix = shapeReader.ReadMatrix();
                shapeReader.Align8();
            }

            return(style);
        }
Beispiel #6
0
        private MorphGradient ReadMorphGradient(SWFDataTypeReader shapeReader)
        {
            int numGrads = shapeReader.ReadUI8();

            MorphGradient mg = new MorphGradient()
            {
                Records = new MorphGradientRecord[numGrads]
            };

            for (int i = 0; i < numGrads; i++)
            {
                mg.Records[i] = this.ReadMorphGradientRecord(shapeReader);
            }

            return(mg);
        }
Beispiel #7
0
        /* ISSUE 20: Instead of passing the format and reader around, perhaps they should be
         * members? Perhaps? Hmm? */
        private FillStyle[] ReadFillStyleArray(SWFDataTypeReader shapeReader, Tag format)
        {
            int fillCount = shapeReader.ReadUI8();

            if (fillCount == 0xFF && (format == Tag.DefineShape3 || format == Tag.DefineShape2))
            {
                fillCount = shapeReader.ReadUI16();
            }

            FillStyle[] fillStyles = new FillStyle[fillCount];
            for (int i = 0; i < fillCount; i++)
            {
                fillStyles[i] = this.ReadFillStyle(shapeReader, format);
            }

            return(fillStyles);
        }
Beispiel #8
0
        private MorphFillStyle[] ReadMorphFillStyleArray(SWFDataTypeReader shapeReader)
        {
            int fillCount = shapeReader.ReadUI8();

            if (fillCount == 0xFF)
            {
                fillCount = shapeReader.ReadUI16();
            }

            MorphFillStyle[] fillStyles = new MorphFillStyle[fillCount];
            for (int i = 0; i < fillCount; i++)
            {
                fillStyles[i] = this.ReadMorphFillStyle(shapeReader);
            }

            return(fillStyles);
        }
Beispiel #9
0
        private Gradient ReadGradient(SWFDataTypeReader shapeReader, Tag format)
        {
            GradientSpread        spread = (GradientSpread)shapeReader.ReadUBits(2);
            GradientInterpolation interp = (GradientInterpolation)shapeReader.ReadUBits(2);

            int numRecs = (int)shapeReader.ReadUBits(4);

            GradientRecord[] recs = new GradientRecord[numRecs];

            for (int i = 0; i < recs.Length; i++)
            {
                GradientRecord rec = new GradientRecord();
                rec.Ratio = shapeReader.ReadUI8();
                if (format == Tag.DefineShape || format == Tag.DefineShape2)
                {
                    rec.Colour = shapeReader.ReadRGB();
                }
                else if (format == Tag.DefineShape3 || format == Tag.DefineShape4)
                {
                    rec.Colour = shapeReader.ReadRGBA();
                }
                else
                {
                    throw new SWFModellerException(SWFModellerError.Internal, "Can't read gradient in shape format " + format.ToString());
                }

                recs[i] = rec;
            }

            return(new Gradient()
            {
                Records = recs,
                Interpolation = interp,
                Spread = spread
            });
        }
Beispiel #10
0
        private Gradient ReadGradient(SWFDataTypeReader shapeReader, Tag format)
        {
            GradientSpread spread = (GradientSpread)shapeReader.ReadUBits(2);
            GradientInterpolation interp = (GradientInterpolation)shapeReader.ReadUBits(2);

            int numRecs = (int)shapeReader.ReadUBits(4);

            GradientRecord[] recs = new GradientRecord[numRecs];

            for (int i = 0; i < recs.Length; i++)
            {
                GradientRecord rec = new GradientRecord();
                rec.Ratio = shapeReader.ReadUI8();
                if (format == Tag.DefineShape || format == Tag.DefineShape2)
                {
                    rec.Colour = shapeReader.ReadRGB();
                }
                else if (format == Tag.DefineShape3 || format == Tag.DefineShape4)
                {
                    rec.Colour = shapeReader.ReadRGBA();
                }
                else
                {
                    throw new SWFModellerException(SWFModellerError.Internal, "Can't read gradient in shape format " + format.ToString());
                }

                recs[i] = rec;
            }

            return new Gradient()
            {
                Records = recs,
                Interpolation = interp,
                Spread = spread
            };
        }
Beispiel #11
0
        private FillStyle ReadFillStyle(SWFDataTypeReader shapeReader, Tag format)
        {
            FillStyle style = new FillStyle();

            style.Type = (FillType)shapeReader.ReadUI8();

            if (style.Type == FillType.Solid)
            {
                if (format == Tag.DefineShape3 || format == Tag.DefineShape4) /* Assuming shape4 goes here. Spec is ambiguous. */
                {
                    style.Colour = shapeReader.ReadRGBA();
                }
                else if (format == Tag.DefineShape || format == Tag.DefineShape2)
                {
                    style.Colour = shapeReader.ReadRGB();
                }
                else
                {
                    throw new SWFModellerException(SWFModellerError.SWFParsing, "Bad tag format for fill style");
                }
            }

            if (style.Type == FillType.LinearGradient
                    || style.Type == FillType.RadialGradient
                    || style.Type == FillType.FocalGradient)
            {
                style.FillMatrix = shapeReader.ReadMatrix();
                shapeReader.Align8();

                if (style.Type == FillType.LinearGradient
                        || style.Type == FillType.RadialGradient)
                {
                    style.Gradient = this.ReadGradient(shapeReader, format);
                }
                else /* FocalGradient */
                {
                    style.Gradient = this.ReadFocalGradient(shapeReader);
                }
            }

            if (FillTypes.IsBitmap(style.Type))
            {
                int cid = shapeReader.ReadUI16();
                /* Some fills have this magic number in them which seems to deliberately not
                 * reference a bitmap. The spec is silent on the matter. Oh flash, you
                 * stammering ape. */
                if (cid != 0x0000FFFF)
                {
                    style.Bitmap = this.ImageFinder.FindImage(cid);
                }

                style.FillMatrix = shapeReader.ReadMatrix();
                shapeReader.Align8();
            }

            return style;
        }
Beispiel #12
0
        private MorphFillStyle ReadMorphFillStyle(SWFDataTypeReader shapeReader)
        {
            MorphFillStyle style = new MorphFillStyle();

            style.Type = (FillType)shapeReader.ReadUI8();

            if (style.Type == FillType.Solid)
            {
                style.StartColour = shapeReader.ReadRGBA();
                style.EndColour = shapeReader.ReadRGBA();
            }

            if (style.Type == FillType.LinearGradient
                    || style.Type == FillType.RadialGradient)
            {
                style.StartFillMatrix = shapeReader.ReadMatrix();
                shapeReader.Align8();

                style.EndFillMatrix = shapeReader.ReadMatrix();
                shapeReader.Align8();

                if (style.Type == FillType.LinearGradient
                        || style.Type == FillType.RadialGradient)
                {
                    style.Gradient = this.ReadMorphGradient(shapeReader);
                }
            }

            if (FillTypes.IsBitmap(style.Type))
            {
                int cid = shapeReader.ReadUI16();
                /* Some fills have this magic number in them which seems to deliberately not
                 * reference a bitmap. The spec is silent on the matter. Oh flash, you
                 * bumbling simian. */
                if (cid != 0x0000FFFF)
                {
                    style.Bitmap = this.ImageFinder.FindImage(cid);
                }

                style.StartFillMatrix = shapeReader.ReadMatrix();
                shapeReader.Align8();

                style.EndFillMatrix = shapeReader.ReadMatrix();
                shapeReader.Align8();
            }

            return style;
        }
Beispiel #13
0
        private LineStyle[] ReadLineStyleArray(SWFDataTypeReader shapeReader, Tag format)
        {
            int lineCount = shapeReader.ReadUI8();
            if (lineCount == 0xFF)
            {
                lineCount = shapeReader.ReadUI16();
            }

            LineStyle[] lineStyles = new LineStyle[lineCount];
            if (format == Tag.DefineShape4)
            {
                for (int i = 0; i < lineCount; i++)
                {
                    lineStyles[i] = this.ReadLineStyle2(shapeReader, format);
                }
            }
            else
            {
                for (int i = 0; i < lineCount; i++)
                {
                    lineStyles[i] = this.ReadLineStyle(shapeReader, format);
                }
            }

            return lineStyles;
        }
Beispiel #14
0
        private MorphFillStyle[] ReadMorphFillStyleArray(SWFDataTypeReader shapeReader)
        {
            int fillCount = shapeReader.ReadUI8();
            if (fillCount == 0xFF)
            {
                fillCount = shapeReader.ReadUI16();
            }

            MorphFillStyle[] fillStyles = new MorphFillStyle[fillCount];
            for (int i = 0; i < fillCount; i++)
            {
                fillStyles[i] = this.ReadMorphFillStyle(shapeReader);
            }

            return fillStyles;
        }
Beispiel #15
0
        private MorphGradient ReadMorphGradient(SWFDataTypeReader shapeReader)
        {
            int numGrads = shapeReader.ReadUI8();

            MorphGradient mg = new MorphGradient()
            {
                Records = new MorphGradientRecord[numGrads]
            };

            for (int i = 0; i < numGrads; i++)
            {
                mg.Records[i] = this.ReadMorphGradientRecord(shapeReader);
            }

            return mg;
        }
Beispiel #16
0
 private MorphGradientRecord ReadMorphGradientRecord(SWFDataTypeReader shapeReader)
 {
     MorphGradientRecord mgr = new MorphGradientRecord();
     mgr.StartRatio = shapeReader.ReadUI8();
     mgr.StartColour = shapeReader.ReadRGBA();
     mgr.EndRatio = shapeReader.ReadUI8();
     mgr.EndColour = shapeReader.ReadRGBA();
     return mgr;
 }
Beispiel #17
0
        private MorphLineStyle[] ReadMorphLineStyleArray(SWFDataTypeReader shapeReader, Tag format)
        {
            int lineCount = shapeReader.ReadUI8();
            if (lineCount == 0xFF)
            {
                lineCount = shapeReader.ReadUI16();
            }

            MorphLineStyle[] lineStyles = new MorphLineStyle[lineCount];
            if (format == Tag.DefineMorphShape)
            {
                for (int i = 0; i < lineCount; i++)
                {
                    lineStyles[i] = this.ReadMorphLineStyle(shapeReader);
                }
            }
            else /* Else Tag.DefineMorphShape2 */
            {
                for (int i = 0; i < lineCount; i++)
                {
                    lineStyles[i] = this.ReadMorphLineStyle2(shapeReader);
                }
            }

            return lineStyles;
        }
Beispiel #18
0
        /* ISSUE 20: Instead of passing the format and reader around, perhaps they should be
         * members? Perhaps? Hmm? */
        private FillStyle[] ReadFillStyleArray(SWFDataTypeReader shapeReader, Tag format)
        {
            int fillCount = shapeReader.ReadUI8();
            if (fillCount == 0xFF && (format == Tag.DefineShape3 || format == Tag.DefineShape2))
            {
                fillCount = shapeReader.ReadUI16();
            }

            FillStyle[] fillStyles = new FillStyle[fillCount];
            for (int i = 0; i < fillCount; i++)
            {
                fillStyles[i] = this.ReadFillStyle(shapeReader, format);
            }

            return fillStyles;
        }