private static SwfTag DecodeTag(SwfReader reader, int length, SwfTagCode tagCode) { if (length == 0) { return(new SwfTagEmpty(tagCode)); } var opts = reader.TagDecodeOptions; var tagData = reader.ReadUInt8(length); if (tagCode == SwfTagCode.DefineSprite && (opts & SwfTagDecodeOptions.DonotDecodeSprites) == 0) { var sprite = new SwfSprite(); sprite.ReadTagData(tagData, reader); return(sprite); } if ((opts & SwfTagDecodeOptions.DonotDecodeTags) != 0) { return(new SwfTagAny(tagCode, tagData)); } bool isChar = SwfTag.IsCharacter(tagCode); if (isChar && (opts & SwfTagDecodeOptions.DonotDecodeCharacters) != 0) { return(ReadChar(reader, tagCode, tagData)); } bool isImage = SwfTag.IsImage(tagCode); if (isImage && (opts & SwfTagDecodeOptions.DonotDecodeImages) != 0) { return(ReadChar(reader, tagCode, tagData)); } var tag = SwfTagFactory.Create(tagCode); if (tag != null) { tag.ReadTagData(tagData, reader); return(tag); } if (isChar) { return(ReadChar(reader, tagCode, tagData)); } return(new SwfTagAny(tagCode, tagData)); }
public virtual SwfTag Clone() { var tc = TagCode; var data = GetData(); var res = SwfTagFactory.Create(tc); if (res != null) { using (var reader = new SwfReader(data)) res.ReadTagData(reader); return(res); } if (IsCharacter(tc)) { using (var reader = new SwfReader(data)) { var c = new SwfCharacterAny(tc); c.ReadTagData(reader); return(c); } } return(new SwfTagAny(tc, data)); }