示例#1
0
 public byte[] Decompress(byte[] compressed)
 {
     using (MemoryStream inStream = new MemoryStream(compressed))
     using (GZipStream gzipStream = new GZipStream(inStream, CompressionMode.Decompress))
     using (MemoryStream outStream = new MemoryStream())
     {
         CopyTo(gzipStream, outStream);
         //gzipStream.CopyTo(outStream);
         return outStream.ToArray();
     }
 }
示例#2
0
        public byte[] Compress(byte[] data)
        {
            Texture2D tex = new Texture2D(1, 1);
            tex.LoadImage(data);

            switch (Size)
            {
                case "Long":
                    TextureScale.Bilinear(tex, 1000, 200);
                    break;
                case "Wide":
                    TextureScale.Bilinear(tex, 500, 200);
                    break;
                case "Square":
                    TextureScale.Bilinear(tex, 200, 200);
                    break;

            }

            data = tex.EncodeToJPG();

            using (MemoryStream outStream = new MemoryStream())
            {
                using (GZipStream gzipStream = new GZipStream(outStream, CompressionMode.Compress))
                using (MemoryStream srcStream = new MemoryStream(data))
                {
                    CopyTo(srcStream, gzipStream);
                    //srcStream.CopyTo(gzipStream);
                }
                return outStream.ToArray();
            }
        }