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 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 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; }