Ejemplo n.º 1
0
        public static bool IsResource(Stream stream)
        {
            var rh = new ResourceHeader();

            rh.Read(new BinaryReader(stream));
            return(rh.Magic == ResourceHeader.MagicValue);
        }
Ejemplo n.º 2
0
 public static void GetResourceData(Stream stream, out uint flags, out ResourceType type)
 {
     var rh = new ResourceHeader();
     rh.Read(new BinaryReader(stream));
     flags = rh.Flags;
     type = rh.Type;
 }
Ejemplo n.º 3
0
        public static void GetResourceData(Stream stream, out uint flags, out ResourceType type)
        {
            var rh = new ResourceHeader();

            rh.Read(new BinaryReader(stream));
            flags = rh.Flags;
            type  = rh.Type;
        }
Ejemplo n.º 4
0
        public void Read(Stream data)
        {
            _header = new ResourceHeader();

            var br = new BinaryReader(data);

            _header.Read(br);
            if (_header.Magic != ResourceHeader.MagicValue)
            {
                throw new Exception("Not a valid resource");
            }

            switch (_header.CompressCodec)
            {
            case CompressionType.LZX:
                _codec = CompressionCodecFactory.LZX;
                break;

            case CompressionType.Deflate:
                _codec = CompressionCodecFactory.Deflate;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            var ms = new MemoryStream();

            _codec.Decompress(data, ms);

            ms.Seek(0, SeekOrigin.Begin);

            _systemMemData = new byte[SystemMemSize];
            ms.Read(_systemMemData, 0, SystemMemSize);

            _graphicsMemData = new byte[GraphicsMemSize];
            ms.Read(_graphicsMemData, 0, GraphicsMemSize);

            ms.Close();
        }
Ejemplo n.º 5
0
        public void Read(Stream data)
        {
            _header = new ResourceHeader();

            var br = new BinaryReader(data);
            _header.Read(br);
            if (_header.Magic != ResourceHeader.MagicValue)
            {
                throw new Exception("Not a valid resource");
            }

            switch (_header.CompressCodec)
            {
                case CompressionType.LZX:
                    _codec = CompressionCodecFactory.LZX;
                    break;
                case CompressionType.Deflate:
                    _codec = CompressionCodecFactory.Deflate;
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            var ms = new MemoryStream();
            _codec.Decompress( data, ms );

            ms.Seek(0, SeekOrigin.Begin);

            _systemMemData = new byte[SystemMemSize];
            ms.Read(_systemMemData, 0, SystemMemSize);

            _graphicsMemData = new byte[GraphicsMemSize];
            ms.Read(_graphicsMemData, 0, GraphicsMemSize);

            ms.Close();
        }
Ejemplo n.º 6
0
 public static bool IsResource(Stream stream)
 {
     var rh = new ResourceHeader();
     rh.Read(new BinaryReader(stream));
     return rh.Magic == ResourceHeader.MagicValue;
 }