Beispiel #1
0
        public bool Open(Stream fs)
        {
            Header = MarshalUtil.ReadStruct<CBMD>(fs); //read header

            //-- Graphics Reading --

            //Read ahead the size of the uncompressed file
            fs.Seek(Header.CompressedCGFXOffset + 1, SeekOrigin.Begin);
            var intBytes = new byte[4];
            fs.Read(intBytes, 0, 4);
            DecompressedCGFX = new byte[BitConverter.ToUInt32(intBytes, 0)];
            //Read again from the start
            fs.Seek(Header.CompressedCGFXOffset, SeekOrigin.Begin);
            var ms = new MemoryStream(DecompressedCGFX);
            try
            {
                var lz11 = new DSDecmp.Formats.Nitro.LZ11();
                lz11.Decompress(fs, Header.CBMDLength - fs.Position, ms);
            }
            catch
            { //might throw exception if size of compressed is bigger than it should be
            }
            ms.Seek(0, SeekOrigin.Begin);
            CGFXContext = new CGFXContext();
            CGFXContext.Open(ms);
            return true;
        }
Beispiel #2
0
        public bool Open(Stream fs)
        {
            Header = MarshalUtil.ReadStruct <CBMD>(fs); //read header

            //-- Graphics Reading --

            //Read ahead the size of the uncompressed file
            fs.Seek(Header.CompressedCGFXOffset + 1, SeekOrigin.Begin);
            var intBytes = new byte[4];

            fs.Read(intBytes, 0, 4);
            DecompressedCGFX = new byte[BitConverter.ToUInt32(intBytes, 0)];
            //Read again from the start
            fs.Seek(Header.CompressedCGFXOffset, SeekOrigin.Begin);
            var ms = new MemoryStream(DecompressedCGFX);

            try
            {
                var lz11 = new DSDecmp.Formats.Nitro.LZ11();
                lz11.Decompress(fs, Header.CBMDLength - fs.Position, ms);
            }
            catch
            { //might throw exception if size of compressed is bigger than it should be
            }
            ms.Seek(0, SeekOrigin.Begin);
            CGFXContext = new CGFXContext();
            CGFXContext.Open(ms);
            return(true);
        }