public static ISwfStreamReader GetSwfStreamReader(SwfFileInfo info, Stream stream) { if (info.Format == SwfFormat.FWS) { return(new SwfStreamReader(stream)); } MemoryStream memoryStream = new MemoryStream(); SwfZip.Decompress(stream, memoryStream, info.Format); return(new SwfStreamReader(memoryStream)); }
public static void WriteSwfFileInfo(this ISwfStreamWriter writer, SwfFileInfo fileInfo) { string format = fileInfo.Format; if (format == null || format.Length != 3) throw new InvalidOperationException("Format should be of length 3"); writer.WriteByte((byte)format[0]); writer.WriteByte((byte)format[1]); writer.WriteByte((byte)format[2]); writer.WriteByte(fileInfo.Version); var len = fileInfo.FileLength; writer.WriteByte((byte)((len >> 0) & 0xff)); writer.WriteByte((byte)((len >> 8) & 0xff)); writer.WriteByte((byte)((len >> 16) & 0xff)); writer.WriteByte((byte)((len >> 24) & 0xff)); }
public static void WriteSwfFileInfo(this ISwfStreamWriter writer, SwfFileInfo fileInfo) { string format = fileInfo.Format.ToString(); if (string.IsNullOrEmpty(format) || format.Length != 3) { throw new InvalidOperationException("Format should be of length 3"); } writer.WriteByte((byte)format[0]); writer.WriteByte((byte)format[1]); writer.WriteByte((byte)format[2]); writer.WriteByte(fileInfo.Version); var len = fileInfo.FileLength; writer.WriteByte((byte)((len >> 0) & 0xff)); writer.WriteByte((byte)((len >> 8) & 0xff)); writer.WriteByte((byte)((len >> 16) & 0xff)); writer.WriteByte((byte)((len >> 24) & 0xff)); }
protected static ISwfStreamReader GetSwfStreamReader(SwfFileInfo info, Stream stream) { switch (info.Format) { case "CWS": var mem = new MemoryStream(); SwfZip.Decompress(stream, mem); return new SwfStreamReader(mem); case "FWS": return new SwfStreamReader(stream); default: throw new NotSupportedException("Illegal file format"); } }