예제 #1
0
        /// <summary>
        /// decompresses a gzipped OSD object
        /// </summary>
        /// <param name="decodedOsd"></param> the OSD object
        /// <param name="meshBytes"></param>
        /// <returns></returns>
        static OSD DecompressOsd(byte[] meshBytes)
        {
            OSD decodedOsd = null;

            using (MemoryStream outMs = new MemoryStream())
            {
                using (ZOutputStream zOut = new ZOutputStream(outMs))
                {
                    using (Stream inMs = new MemoryStream(meshBytes))
                     {
                        byte[] readBuffer = new byte[2000];
                        int readLen;

                        while ((readLen = inMs.Read(readBuffer, 0, readBuffer.Length)) > 0)
                        {
                            zOut.Write(readBuffer, 0, readLen);
                        }
                        zOut.Flush();
                        zOut.finish();
                        //outMs.Seek(0, SeekOrigin.Begin);

                        //byte[] decompressedBuf = outMs.GetBuffer();
                        byte[] decompressedBuf = outMs.ToArray();

                        decodedOsd = OSDParser.DeserializeLLSDBinary(decompressedBuf);
                    }
                }
            }

            return decodedOsd;
        }