예제 #1
0
    public static SwfPackage FromStream(Stream source) {
      // get the header first so we know compression
      SwfHeader header = SwfHeader.FromStream(source);

      // uncompress the file based on compression method
      Stream uncompressed;
      if (header.Compression == SwfCompression.ZlibCompressed) {
        uncompressed = new ZlibStream(source, CompressionMode.Decompress);
      } else if (header.Compression == SwfCompression.LzmaCompressed {

      }
    }
예제 #2
0
        public static SwfHeader FromStream(Stream source)
        {
            byte[] buffer = new byte[4];

            source.Read(buffer, 0, 3);

            // Magic bytes are {}, 0x57, 0x53
            if (buffer[1] != 0x57 || buffer[2] != 0x53)
            {
                throw new SwfReadException("File is not a valid SWF file");
            }

            // Check for compression
            SwfCompression compression;

            switch (buffer[0])
            {
            case 0x46: // "F"
                compression = SwfCompression.Uncompressed;
                break;

            case 0x43: // "C"
                compression = SwfCompression.ZlibCompressed;
                break;

            case 0x5A: // "L"
                compression = SwfCompression.LzmaCompressed;
                break;

            default:
                throw new SwfReadException("Unable to recognize compression of SWF file");
            }

            // Check for version
            source.Read(buffer, 0, 1);
            byte version = buffer[0];

            // Check for size
            source.Read(buffer, 0, 4);
            uint fileLength = BitConverter.ToUInt32(buffer, 0);

            // Resolve for SwfHeader object
            SwfHeader header = new SwfHeader(compression, version, fileLength);

            Console.WriteLine("Resolved for header {0}", header);
            return(header);
        }
예제 #3
0
 public SwfPackage(SwfHeader header, Rectangle boundingRect)
 {
   Header = header;
   BoundingRect = boundingRect;
 }