Last active
November 30, 2018 23:30
Star
You must be signed in to star a gist
Deflate圧縮
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System; | |
using System.Text; | |
using System.IO; | |
using System.IO.Compression; | |
// Unity2018.3.0b12 | |
namespace TSKT | |
{ | |
public static class DeflateUtil | |
{ | |
static public byte[] Compress(byte[] bytes) | |
{ | |
using (var compressed = new MemoryStream()) | |
{ | |
using (var deflateStream = new DeflateStream(compressed, CompressionMode.Compress)) | |
{ | |
deflateStream.Write(bytes, 0, bytes.Length); | |
} | |
return compressed.ToArray(); | |
} | |
} | |
static public byte[] Decompress(byte[] bytes) | |
{ | |
using (var compressed = new MemoryStream(bytes)) | |
{ | |
using (var deflateStream = new DeflateStream(compressed, CompressionMode.Decompress)) | |
{ | |
using (var decompressed = new MemoryStream()) | |
{ | |
deflateStream.CopyTo(decompressed); | |
return decompressed.ToArray(); | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment