internal IShape Parse(Tag tag, byte[] data, IImageFinder imageFinder)
{
this.ImageFinder = imageFinder;
SWFDataTypeReader shapeReader = new SWFDataTypeReader(new MemoryStream(data));
IShape newShape = null;
switch (tag)
{
case Tag.DefineShape:
case Tag.DefineShape2:
case Tag.DefineShape3:
newShape = this.ParseDefineShapeN(shapeReader, tag);
break;
case Tag.DefineFont3:
/* We do some hackery magic here. Because we happen to know that the only reason
* we parse shapes is to get bitmap references out of them, we skip the actual parsing
* of glyphs because they can't ever have bitmaps in them. We do this by creating
* a fundamentally broken shape which contains nothing but the original shape bytes.
* Oh, for shame. */
return new Shape() { OriginalBytes = data, OriginalFormat = tag };
case Tag.DefineShape4:
newShape = this.ParseDefineShape4(shapeReader);
break;
case Tag.DefineMorphShape:
case Tag.DefineMorphShape2:
newShape = this.ParseDefineMorphShape(shapeReader, tag);
break;
default:
throw new SWFModellerException(SWFModellerError.Internal, "Can't parse shapes with tag " + tag.ToString());
}
newShape.SetOriginalBytes(data, tag);
return newShape;
}