예제 #1
0
    /// <summary>
    /// 解压
    /// </summary>
    /// <param name="param"></param>
    /// <returns></returns>
    public static string Deompress(string param)
    {
        Debug.Log("11111111111111commonString:");
        string commonString = "";
        int    data         = 0;
        int    stopByte     = -1;

        byte[]       buffer = Convert.FromBase64String(param);// 解base64
        MemoryStream intms  = new MemoryStream(buffer);

        zlib.ZInputStream inZStream = new zlib.ZInputStream(intms);
        int count = 1024 * 1024;

        byte[] inByteList = new byte[count];
        int    i          = 0;

        while (stopByte != (data = inZStream.Read()))
        {
            inByteList[i] = (byte)data;
            i++;
        }
        inZStream.Close();
        commonString = System.Text.Encoding.UTF8.GetString(inByteList, 0, inByteList.Length);
        Debug.Log(commonString);
        Debug.Log("22222222222222commonString:");
        return(commonString);
    }
예제 #2
0
        public static byte[] DecompressData(byte[] inData)
        {
            int data     = 0;
            int stopByte = -1;

            byte[]       Buffer = inData; // 解base64
            MemoryStream intms  = new MemoryStream(Buffer);

            zlib.ZInputStream inZStream = new zlib.ZInputStream(intms);
            int count = 1024 * 1024;

            byte[] inByteList = new byte[count];
            int    i          = 0;

            while (stopByte != (data = inZStream.Read()))
            {
                inByteList[i] = (byte)data;
                i++;
            }
            inZStream.Close();
            return(inByteList.Take(i).ToArray());
        }
예제 #3
0
        public static OSD ZDecompressBytesToOsd(byte[] input)
        {
            OSD osd = null;

            using (MemoryStream msSinkUnCompressed = new MemoryStream())
            {
                using(ZInputStream zOut = new ZInputStream(msSinkUnCompressed))
                {
                    zOut.Read(input, 0, input.Length);
                    msSinkUnCompressed.Seek(0L, SeekOrigin.Begin);
                    osd = OSDParser.DeserializeLLSDBinary(msSinkUnCompressed.ToArray());
                    zOut.Close();
                }
            }

            return osd;
        }