private MorphLineStyle ReadMorphLineStyle2(SWFDataTypeReader shapeReader) { int startwidth = shapeReader.ReadUI16(); int endwidth = shapeReader.ReadUI16(); CapStyle startCap = (CapStyle)shapeReader.ReadUBits(2); JoinStyle join = (JoinStyle)shapeReader.ReadUBits(2); bool hasFill = shapeReader.ReadBit(); bool noHScaling = shapeReader.ReadBit(); bool noVScaling = shapeReader.ReadBit(); bool hasPixelHints = shapeReader.ReadBit(); shapeReader.ReadUBits(5); // Reserved: 0 bool noClose = shapeReader.ReadBit(); CapStyle endCap = (CapStyle)shapeReader.ReadUBits(2); int?miterLimit = null; if (join == JoinStyle.Miter) { miterLimit = shapeReader.ReadUI16(); } Color? startColour = null; Color? endColour = null; MorphFillStyle fs = null; if (hasFill) { fs = this.ReadMorphFillStyle(shapeReader); } else { startColour = shapeReader.ReadRGBA(); endColour = shapeReader.ReadRGBA(); } return(new MorphLineStyle() { StartWidth = startwidth, EndWidth = endwidth, StartColour = startColour, EndColour = endColour, StartCap = startCap, EndCap = endCap, Join = join, HasFill = hasFill, NoHScaling = noHScaling, NoVScaling = noVScaling, HasPixelHints = hasPixelHints, FillStyle = fs, MiterLimit = miterLimit }); }
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); }
private MorphLineStyle ReadMorphLineStyle(SWFDataTypeReader shapeReader) { return(new MorphLineStyle() { StartWidth = shapeReader.ReadUI16(), EndWidth = shapeReader.ReadUI16(), StartColour = shapeReader.ReadRGBA(), EndColour = shapeReader.ReadRGBA() }); }
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); }
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); }
private LineStyle ReadLineStyle2(SWFDataTypeReader shapeReader, Tag format) { int width = shapeReader.ReadUI16(); CapStyle startCap = (CapStyle)shapeReader.ReadUBits(2); JoinStyle join = (JoinStyle)shapeReader.ReadUBits(2); bool hasFill = shapeReader.ReadBit(); bool noHScaling = shapeReader.ReadBit(); bool noVScaling = shapeReader.ReadBit(); bool hasPixelHints = shapeReader.ReadBit(); shapeReader.ReadUBits(5); /* Reserved: 0 */ bool noClose = shapeReader.ReadBit(); CapStyle endCap = (CapStyle)shapeReader.ReadUBits(2); int?miterLimit = null; if (join == JoinStyle.Miter) { miterLimit = shapeReader.ReadUI16(); } Color? c = null; FillStyle fs = null; if (hasFill) { fs = this.ReadFillStyle(shapeReader, format); } else { c = shapeReader.ReadRGBA(); } return(new LineStyle() { Width = width, StartCap = startCap, EndCap = endCap, Join = join, HasFill = hasFill, NoHScaling = noHScaling, NoVScaling = noVScaling, HasPixelHints = hasPixelHints, Colour = c, FillStyle = fs, MiterLimit = miterLimit }); }
private LineStyle ReadLineStyle(SWFDataTypeReader shapeReader, Tag format) { LineStyle ls = new LineStyle(); ls.Width = shapeReader.ReadUI16(); if (format == Tag.DefineShape || format == Tag.DefineShape2) { ls.Colour = shapeReader.ReadRGB(); } else if (format == Tag.DefineShape3 || format == Tag.DefineShape4) { ls.Colour = shapeReader.ReadRGBA(); } else { throw new SWFModellerException(SWFModellerError.Internal, "Can't line style in shape format " + format.ToString()); } return(ls); }
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 }); }
private MorphLineStyle ReadMorphLineStyle2(SWFDataTypeReader shapeReader) { int startwidth = shapeReader.ReadUI16(); int endwidth = shapeReader.ReadUI16(); CapStyle startCap = (CapStyle)shapeReader.ReadUBits(2); JoinStyle join = (JoinStyle)shapeReader.ReadUBits(2); bool hasFill = shapeReader.ReadBit(); bool noHScaling = shapeReader.ReadBit(); bool noVScaling = shapeReader.ReadBit(); bool hasPixelHints = shapeReader.ReadBit(); shapeReader.ReadUBits(5); // Reserved: 0 bool noClose = shapeReader.ReadBit(); CapStyle endCap = (CapStyle)shapeReader.ReadUBits(2); int? miterLimit = null; if (join == JoinStyle.Miter) { miterLimit = shapeReader.ReadUI16(); } Color? startColour = null; Color? endColour = null; MorphFillStyle fs = null; if (hasFill) { fs = this.ReadMorphFillStyle(shapeReader); } else { startColour = shapeReader.ReadRGBA(); endColour = shapeReader.ReadRGBA(); } return new MorphLineStyle() { StartWidth = startwidth, EndWidth = endwidth, StartColour = startColour, EndColour = endColour, StartCap = startCap, EndCap = endCap, Join = join, HasFill = hasFill, NoHScaling = noHScaling, NoVScaling = noVScaling, HasPixelHints = hasPixelHints, FillStyle = fs, MiterLimit = miterLimit }; }
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; }
private MorphLineStyle ReadMorphLineStyle(SWFDataTypeReader shapeReader) { return new MorphLineStyle() { StartWidth = shapeReader.ReadUI16(), EndWidth = shapeReader.ReadUI16(), StartColour = shapeReader.ReadRGBA(), EndColour = shapeReader.ReadRGBA() }; }
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; }
private LineStyle ReadLineStyle2(SWFDataTypeReader shapeReader, Tag format) { int width = shapeReader.ReadUI16(); CapStyle startCap = (CapStyle)shapeReader.ReadUBits(2); JoinStyle join = (JoinStyle)shapeReader.ReadUBits(2); bool hasFill = shapeReader.ReadBit(); bool noHScaling = shapeReader.ReadBit(); bool noVScaling = shapeReader.ReadBit(); bool hasPixelHints = shapeReader.ReadBit(); shapeReader.ReadUBits(5); /* Reserved: 0 */ bool noClose = shapeReader.ReadBit(); CapStyle endCap = (CapStyle)shapeReader.ReadUBits(2); int? miterLimit = null; if (join == JoinStyle.Miter) { miterLimit = shapeReader.ReadUI16(); } Color? c = null; FillStyle fs = null; if (hasFill) { fs = this.ReadFillStyle(shapeReader, format); } else { c = shapeReader.ReadRGBA(); } return new LineStyle() { Width = width, StartCap = startCap, EndCap = endCap, Join = join, HasFill = hasFill, NoHScaling = noHScaling, NoVScaling = noVScaling, HasPixelHints = hasPixelHints, Colour = c, FillStyle = fs, MiterLimit = miterLimit }; }
private LineStyle ReadLineStyle(SWFDataTypeReader shapeReader, Tag format) { LineStyle ls = new LineStyle(); ls.Width = shapeReader.ReadUI16(); if (format == Tag.DefineShape || format == Tag.DefineShape2) { ls.Colour = shapeReader.ReadRGB(); } else if (format == Tag.DefineShape3 || format == Tag.DefineShape4) { ls.Colour = shapeReader.ReadRGBA(); } else { throw new SWFModellerException(SWFModellerError.Internal, "Can't line style in shape format " + format.ToString()); } return ls; }
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 }; }
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; }